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


Java Undefined类代码示例

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


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

示例1: doMethod

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
public Object doMethod(String httpMethod,
					   String path,
					   EndpointRequest request,
					   EndpointResponse response) throws NasapiException {
	if (methods.containsKey(httpMethod)) {
		Object result = methods.get(httpMethod).call(this, request, response);
		if (result != null && result instanceof Undefined) {
			return null;
		}
		return result;
	} else if (METHOD_OPTIONS.equals(httpMethod)) {
		// build default options into response...
		response.setStatus(200);
		response.setHeader(HttpHeaders.ALLOW, allowedMethods);
		response.setBody(null);
	} else {
		throw new MethodNotAllowedException("URI '" + path + "' does not support method '" + httpMethod + "'", allowedMethods);
	}
	return null;
}
 
开发者ID:marrow16,项目名称:Nasapi,代码行数:21,代码来源:Mapping.java

示例2: getHandle

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
/**
 * Given a JS script object, retrieves a function from it by name, binds it to the script object as its "this", and
 * adapts its parameter types, return types, and arity to the specified type and arity. This method is public mainly
 * for implementation reasons, so the adapter classes can invoke it from their constructors that take a Object
 * in its first argument to obtain the method handles for their method implementations.
 * @param obj the script obj
 * @param name the name of the property that contains the function
 * @param type the method type it has to conform to
 * @return the appropriately adapted method handle for invoking the script function, or null if the value of the
 * property is either null or undefined, or "toString" was requested as the name, but the object doesn't directly
 * define it but just inherits it through prototype.
 */
public static MethodHandle getHandle(final Object obj, final String name, final MethodType type) {
    if (! (obj instanceof ScriptObject)) {
        throw typeError("not.an.object", ScriptRuntime.safeToString(obj));
    }

    final ScriptObject sobj = (ScriptObject)obj;
    // Since every JS Object has a toString, we only override "String toString()" it if it's explicitly specified
    if ("toString".equals(name) && !sobj.hasOwnProperty("toString")) {
        return null;
    }

    final Object fnObj = sobj.get(name);
    if (fnObj instanceof ScriptFunction) {
        return bindAndAdaptHandle((ScriptFunction)fnObj, sobj, type);
    } else if(fnObj == null || fnObj instanceof Undefined) {
        return null;
    } else {
        throw typeError("not.a.function", name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:JavaAdapterServices.java

示例3: ldc

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
@Override
public Type ldc(final MethodVisitor method, final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ObjectType.java

示例4: next

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(), Boolean.TRUE, global);
    }

    final LinkedMap.Node node = iterator.next();

    if (node == null) {
        iterator = null;
        return makeResult(Undefined.getUndefined(), Boolean.TRUE, global);
    }

    if (iterationKind == IterationKind.KEY_VALUE) {
        final NativeArray array = new NativeArray(new Object[] {node.getKey(), node.getValue()});
        return makeResult(array, Boolean.FALSE, global);
    }

    return makeResult(iterationKind == IterationKind.KEY ? node.getKey() : node.getValue(), Boolean.FALSE, global);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:MapIterator.java

示例5: next

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
@Override
protected  IteratorResult next(final Object arg) {
    if (iterator == null) {
        return makeResult(Undefined.getUndefined(), Boolean.TRUE, global);
    }

    final LinkedMap.Node node = iterator.next();

    if (node == null) {
        iterator = null;
        return makeResult(Undefined.getUndefined(), Boolean.TRUE, global);
    }

    if (iterationKind == IterationKind.KEY_VALUE) {
        final NativeArray array = new NativeArray(new Object[] {node.getKey(), node.getKey()});
        return makeResult(array, Boolean.FALSE, global);
    }

    return makeResult(node.getKey(), Boolean.FALSE, global);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SetIterator.java

示例6: next

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
@Override
protected IteratorResult next(final Object arg) {
    final int index = nextIndex;
    final String string = iteratedString;

    if (string == null || index >= string.length()) {
        // ES6 21.1.5.2.1 step 8
        iteratedString = null;
        return makeResult(Undefined.getUndefined(), Boolean.TRUE, global);
    }

    final char first = string.charAt(index);
    if (first >= 0xd800 && first <= 0xdbff && index < string.length() - 1) {
        final char second = string.charAt(index + 1);
        if (second >= 0xdc00 && second <= 0xdfff) {
            nextIndex += 2;
            return makeResult(String.valueOf(new char[] {first, second}), Boolean.FALSE, global);
        }
    }

    nextIndex++;
    return makeResult(String.valueOf(first), Boolean.FALSE, global);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:StringIterator.java

示例7: toJSValue

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
public static Object toJSValue(Value value){
    if(value == null)
        return Undefined.getUndefined();

    if(value == Value.VOID)
        return Undefined.getUndefined();

    if(value.isString())
        return new JSStringValue(value);

    if(value.isBoolean()|| value.isNumber())
        return value.get();

    if(value.isFunction())
        return new JSFunction(value);

    if(value.isArray())
        return new JSArray(value);

    if(value.isMap())
        return new JSMap(value);

    return Undefined.getUndefined();
}
 
开发者ID:djxy,项目名称:MultiScripts,代码行数:25,代码来源:Util.java

示例8: getGuardedInvocation

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv, linkerServices, desc);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:23,代码来源:NashornLinker.java

示例9: getHandle

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
/**
 * Given a JS script object, retrieves a function from it by name, binds it to the script object as its "this", and
 * adapts its parameter types, return types, and arity to the specified type and arity. This method is public mainly
 * for implementation reasons, so the adapter classes can invoke it from their constructors that take a Object
 * in its first argument to obtain the method handles for their method implementations.
 * @param obj the script obj
 * @param name the name of the property that contains the function
 * @param type the method type it has to conform to
 * @return the appropriately adapted method handle for invoking the script function, or null if the value of the
 * property is either null or undefined, or "toString" was requested as the name, but the object doesn't directly
 * define it but just inherits it through prototype.
 */
public static MethodHandle getHandle(final Object obj, final String name, final MethodType type) {
    if (! (obj instanceof ScriptObject)) {
        throw typeError("not.an.object", ScriptRuntime.safeToString(obj));
    }

    final ScriptObject sobj = (ScriptObject)obj;
    // Since every JS Object has a toString, we only override "String toString()" it if it's explicitly specified
    if ("toString".equals(name) && !sobj.hasOwnProperty("toString")) {
        return null;
    }

    final Object fnObj = sobj.get(name);
    if (fnObj instanceof ScriptFunction) {
        return adaptHandle(((ScriptFunction)fnObj).getBoundInvokeHandle(sobj), type);
    } else if(fnObj == null || fnObj instanceof Undefined) {
        return null;
    } else {
        throw typeError("not.a.function", name);
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:33,代码来源:JavaAdapterServices.java

示例10: getREDUCE_CALLBACK_INVOKER

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
private static MethodHandle getREDUCE_CALLBACK_INVOKER() {
    return Global.instance().getDynamicInvoker(REDUCE_CALLBACK_INVOKER,
            new Callable<MethodHandle>() {
                @Override
                public MethodHandle call() {
                    return Bootstrap.createDynamicInvoker("dyn:call", Object.class, Object.class,
                         Undefined.class, Object.class, Object.class, long.class, Object.class);
                }
            });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:NativeArray.java

示例11: getGuardedInvocation

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
private static GuardedInvocation getGuardedInvocation(final Object self, final LinkRequest request, final CallSiteDescriptor desc) {
    final GuardedInvocation inv;
    if (self instanceof ScriptObject) {
        inv = ((ScriptObject)self).lookup(desc, request);
    } else if (self instanceof Undefined) {
        inv = Undefined.lookup(desc);
    } else {
        throw new AssertionError(self.getClass().getName()); // Should never reach here.
    }

    return inv;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:NashornLinker.java

示例12: constructor

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
/**
 * ECMA 6 19.4.1.1 Symbol ( [ description ] )
 *
 * @param newObj is this function invoked with the new operator
 * @param self   self reference
 * @param args   arguments
 * @return new symbol value
 */
@Constructor(arity = 1)
public static Object constructor(final boolean newObj, final Object self, final Object... args) {
    if (newObj) {
        throw typeError("symbol.as.constructor");
    }
    final String description = args.length > 0 && args[0] != Undefined.getUndefined() ?
            JSType.toString(args[0]) : "";
    return new Symbol(description);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:NativeSymbol.java

示例13: keyFor

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
/**
 * ES6 19.4.2.5 Symbol.keyFor ( sym )
 *
 * @param self self reference
 * @param arg the argument
 * @return the symbol name
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public synchronized static Object keyFor(final Object self, final Object arg) {
    if (!(arg instanceof Symbol)) {
        throw typeError("not.a.symbol", ScriptRuntime.safeToString(arg));
    }
    final String name = ((Symbol) arg).getName();
    return globalSymbolRegistry.get(name) == arg ? name : Undefined.getUndefined();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NativeSymbol.java

示例14: populateWeakSet

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
static void populateWeakSet(final Map<Object, Boolean> set, final Object arg, final Global global) {
    if (arg != null && arg != Undefined.getUndefined()) {
        AbstractIterator.iterate(arg, global, value -> {
                set.put(checkKey(value), Boolean.TRUE);
        });
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:NativeWeakSet.java

示例15: getREDUCE_CALLBACK_INVOKER

import jdk.nashorn.internal.runtime.Undefined; //导入依赖的package包/类
private static MethodHandle getREDUCE_CALLBACK_INVOKER() {
    return Global.instance().getDynamicInvoker(REDUCE_CALLBACK_INVOKER,
            new Callable<MethodHandle>() {
                @Override
                public MethodHandle call() {
                    return Bootstrap.createDynamicCallInvoker(Object.class, Object.class,
                         Undefined.class, Object.class, Object.class, double.class, Object.class);
                }
            });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:NativeArray.java


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