当前位置: 首页>>代码示例>>Java>>正文


Java FunctionObject类代码示例

本文整理汇总了Java中org.mozilla.javascript.FunctionObject的典型用法代码示例。如果您正苦于以下问题:Java FunctionObject类的具体用法?Java FunctionObject怎么用?Java FunctionObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FunctionObject类属于org.mozilla.javascript包,在下文中一共展示了FunctionObject类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFunctionObject

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
private static FunctionObject getFunctionObject( Class aClass, String methodName, Scriptable scriptable ) {
    Hashtable functionMap = (Hashtable) _classFunctionMaps.get( aClass );
    if (functionMap == null) {
        _classFunctionMaps.put( aClass, functionMap = new Hashtable() );
    }

    Object result = functionMap.get( methodName );
    if (result == NO_SUCH_PROPERTY) return null;
    if (result != null) return (FunctionObject) result;

    Method[] methods = aClass.getMethods();
    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];
        if (method.getName().equalsIgnoreCase( methodName )) {
            FunctionObject function = new FunctionObject( methodName, method, scriptable );
            functionMap.put( methodName, function );
            return function;
        }
    }
    functionMap.put( methodName, NO_SUCH_PROPERTY );
    return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ScriptingSupport.java

示例2: locateFunction

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
/**
 * Convenience method to locate a function name for this object and
 * create an appriate Function instance to represent it. It assumes that
 * the name you give it is the normal name and will add a "jsFunction_"
 * prefix to locate that from the method details. There is also the
 * implicit assumption that you have made a check for this name being a
 * valid function for this object before you call this method. If a
 * function object is found for this method, it will automatically be
 * registered and you can also have a copy of it returned to use.
 *
 * @param name The real method name to look for
 * @return The function object corresponding to the munged method name
 */
protected FunctionObject locateFunction(String name) {
    String real_name = JS_FUNCTION_PREFIX + name;
    Method[] methods = FunctionObject.findMethods(getClass(), real_name);

    if (methods == null) {
        errorReporter.warningReport("Unknown function: " + real_name +
                                    " on: " + getClass(), null);
        return null;
    }

    FunctionObject function = new FunctionObject(name, methods[0], this);

    functionObjects.put(name, function);

    return function;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:30,代码来源:X3DExecutionContext.java

示例3: toJavaValue

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
public static Object toJavaValue(Object object) {
    if (object == null || object.equals(Context.getUndefinedValue())) {
        return null;
    } else if (object.getClass().getPackage().getName().startsWith("java.")) {
        return object;
    } else if (object instanceof FunctionObject) {
        throw new IllegalArgumentException(String.format("Cannot convert function object to value (object: %s)", object));
    } else if (object instanceof Scriptable) {
        return toMap((Scriptable) object);
    } else {
        throw new IllegalArgumentException(String.format("Can't convert JS object %s (type: %s) to native Java object", object, object.getClass().getName()));
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:RhinoWorkerUtils.java

示例4: exportMethod

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
/**
 * Exports a Java method as a Javascript (top-level-)function. Only works
 * with methods in this class (because scope is used as value for 'this'
 * when invoking methods).
 * 
 * @param methodName
 * @param parameterSignature
 */
private void exportMethod(String methodName, Class[] parameterSignature) {
	try {
		Method m = JavascriptScope.class.getMethod(methodName,
				parameterSignature);
		while (methodName.charAt(0) == '_') {
			methodName = methodName.substring(1);
		} // remove leading _ for JS name
		FunctionObject functionJS = new FunctionObject(methodName, m, this);
		ScriptableObject.putProperty(this, methodName, functionJS);
	} catch (NoSuchMethodException nse) {
		nse.printStackTrace();
	}
}
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:22,代码来源:JavascriptScope.java

示例5: finishInit

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
public static void finishInit(Scriptable scope, FunctionObject constructor,
		Scriptable prototype) {
	int flags = DONTENUM | READONLY | PERMANENT;
	/* for horizontalSize, verticalSize */
	constructor.defineProperty("wrap_view", WRAP_VIEW, flags);
	constructor.defineProperty("fill_container", FILL_CONTAINER, flags);
	
	/* for verticalAlignment, horizontalAlignment */
	constructor.defineProperty("left", LEFT, flags);
	constructor.defineProperty("center", CENTER, flags);
	constructor.defineProperty("right", RIGHT, flags);
	constructor.defineProperty("top", TOP, flags);
	constructor.defineProperty("bottom", BOTTOM, flags);
}
 
开发者ID:joeywatts,项目名称:native.js,代码行数:15,代码来源:View.java

示例6: getFunctions

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
public List<FunctionObject> getFunctions(Scriptable scope) {
	List<String> names = this.getMethodNames();
	List<FunctionObject> functions = new ArrayList<FunctionObject>();

	Method[] methods = this.getClass().getMethods();
	for (Method method : methods)
		if (names.contains(method.getName()))
			functions.add(new FunctionObject(method.getName(), method, scope));

	return functions;
}
 
开发者ID:wsky,项目名称:pacman-dsl,代码行数:12,代码来源:FunctionExtension.java

示例7: finishInit

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
public static void finishInit(Scriptable scope, FunctionObject constructor, Scriptable prototype) {
    System.out.println("finishInit is called.");
    globalPrototype = prototype;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:5,代码来源:StyleProperties.java

示例8: addFunctionExtension

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
private void addFunctionExtension(Scriptable scope, FunctionExtension extension) {
	List<FunctionObject> functions = extension.getFunctions(scope);
	if (functions != null)
		for (FunctionObject func : functions)
			ScriptableObject.putProperty(scope, func.getFunctionName(), func);
}
 
开发者ID:wsky,项目名称:pacman-dsl,代码行数:7,代码来源:Converter.java

示例9: locateFunction

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
/**
 * Convenience method to locate a function name for this object and
 * create an appriate Function instance to represent it. It assumes that
 * the name you give it is the normal name and will add a "jsFunction_"
 * prefix to locate that from the method details. There is also the
 * implicit assumption that you have made a check for this name being a
 * valid function for this object before you call this method. If a
 * function object is found for this method, it will automatically be
 * registered and you can also have a copy of it returned to use.
 *
 * @param name The real method name to look for
 * @return The function object corresponding to the munged method name
 */
private FunctionObject locateFunction(String name) {
    String real_name = JS_FUNCTION_PREFIX + name;
    Method[] methods = FunctionObject.findMethods(getClass(), real_name);

    FunctionObject function = new FunctionObject(name, methods[0], this);

    functionObjects.put(name, function);

    return function;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:24,代码来源:ExternProtoDeclaration.java

示例10: locateFunction

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
/**
 * Convenience method to locate a function name for this object and
 * create an appriate Function instance to represent it. It assumes that
 * the name you give it is the normal name and will add a "jsFunction_"
 * prefix to locate that from the method details. There is also the
 * implicit assumption that you have made a check for this name being a
 * valid function for this object before you call this method. If a
 * function object is found for this method, it will automatically be
 * registered and you can also have a copy of it returned to use.
 *
 * @param name The real method name to look for
 * @return The function object corresponding to the munged method name
 */
protected FunctionObject locateFunction(String name) {
    String real_name = JS_FUNCTION_PREFIX + name;
    Method[] methods = FunctionObject.findMethods(getClass(), real_name);

    FunctionObject function = new FunctionObject(name, methods[0], this);

    registerFunction(name, function);

    return function;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:24,代码来源:FieldScriptableObject.java

示例11: locateFunction

import org.mozilla.javascript.FunctionObject; //导入依赖的package包/类
/**
 * Convenience method to locate a function name for this object and
 * create an appriate Function instance to represent it. It assumes that
 * the name you give it is the normal name and will add a "jsFunction_"
 * prefix to locate that from the method details. There is also the
 * implicit assumption that you have made a check for this name being a
 * valid function for this object before you call this method. If a
 * function object is found for this method, it will automatically be
 * registered and you can also have a copy of it returned to use.
 *
 * @param name The real method name to look for
 * @return The function object corresponding to the munged method name
 */
protected FunctionObject locateFunction(String name) {
    String real_name = JS_FUNCTION_PREFIX + name;

    Method[] methods = FunctionObject.findMethods(getClass(), real_name);

    FunctionObject function = new FunctionObject(name, methods[0], this);

    functionObjects.put(name, function);

    return function;
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:25,代码来源:Browser.java


注:本文中的org.mozilla.javascript.FunctionObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。