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


Java Attribute.NOT_ENUMERABLE属性代码示例

本文整理汇总了Java中jdk.nashorn.internal.objects.annotations.Attribute.NOT_ENUMERABLE属性的典型用法代码示例。如果您正苦于以下问题:Java Attribute.NOT_ENUMERABLE属性的具体用法?Java Attribute.NOT_ENUMERABLE怎么用?Java Attribute.NOT_ENUMERABLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在jdk.nashorn.internal.objects.annotations.Attribute的用法示例。


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

示例1: filter

/**
 * ECMA 15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )
 *
 * @param self        self reference
 * @param callbackfn  callback function per element
 * @param thisArg     this argument
 * @return filtered array
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
public static NativeArray filter(final Object self, final Object callbackfn, final Object thisArg) {
    return new IteratorAction<NativeArray>(Global.toObject(self), callbackfn, thisArg, new NativeArray()) {
        private long to = 0;
        private final MethodHandle filterInvoker = getFILTER_CALLBACK_INVOKER();

        @Override
        protected boolean forEach(final Object val, final double i) throws Throwable {
            if ((boolean)filterInvoker.invokeExact(callbackfn, thisArg, val, i, self)) {
                result.defineOwnProperty(ArrayIndex.getArrayIndex(to++), val);
            }
            return true;
        }
    }.apply();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:NativeArray.java

示例2: split

/**
 * ECMA 15.5.4.14 String.prototype.split (separator, limit)
 *
 * @param self      self reference
 * @param separator separator for split
 * @param limit     limit for splits
 * @return array object in which splits have been placed
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static ScriptObject split(final Object self, final Object separator, final Object limit) {
    final String str = checkObjectToString(self);
    final long lim = limit == UNDEFINED ? JSType.MAX_UINT : JSType.toUint32(limit);

    if (separator == UNDEFINED) {
        return lim == 0 ? new NativeArray() : new NativeArray(new Object[]{str});
    }

    if (separator instanceof NativeRegExp) {
        return ((NativeRegExp) separator).split(str, lim);
    }

    // when separator is a string, it is treated as a literal search string to be used for splitting.
    return splitString(str, JSType.toString(separator), lim);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:NativeString.java

示例3: __noSuchProperty__

/**
 * "No such property" handler.
 *
 * @param self self reference
 * @param name property name
 * @return value of the missing property
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object __noSuchProperty__(final Object self, final Object name) {
    if (! (self instanceof NativeJavaImporter)) {
        throw typeError("not.a.java.importer", ScriptRuntime.safeToString(self));
    }
    return ((NativeJavaImporter)self).createProperty(JSType.toString(name));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:NativeJavaImporter.java

示例4: bind

/**
 * ECMA 15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, ...]])
 *
 * @param self self reference
 * @param args arguments for bind
 * @return function with bound arguments
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
public static Object bind(final Object self, final Object... args) {
    final Object thiz = (args.length == 0) ? UNDEFINED : args[0];

    Object[] arguments;
    if (args.length > 1) {
        arguments = new Object[args.length - 1];
        System.arraycopy(args, 1, arguments, 0, arguments.length);
    } else {
        arguments = ScriptRuntime.EMPTY_ARRAY;
    }

    return Bootstrap.bindCallable(self, thiz, arguments);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:NativeFunction.java

示例5: isExtensible

/**
 * ECMA 15.2.3.13 Object.isExtensible ( O )
 *
 * @param self self reference
 * @param obj check whether an object is extensible
 * @return true if object is extensible, false otherwise
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static boolean isExtensible(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return ((ScriptObject)obj).isExtensible();
    } else if (obj instanceof ScriptObjectMirror) {
        return ((ScriptObjectMirror)obj).isExtensible();
    } else {
        throw notAnObject(obj);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:NativeObject.java

示例6: length

/**
 * Length getter
 * @param self self reference
 * @return length property value
 */
@Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE)
public static Object length(final Object self) {
    if (self instanceof ScriptObject) {
        return (double) JSType.toUint32(((ScriptObject)self).getArray().length());
    }

    return 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:NativeRegExpExecResult.java

示例7: setFloat64

/**
 * Set 64-bit float at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value double value to set
 * @param littleEndian (optional) flag indicating whether to write in little endian order
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 2)
public static Object setFloat64(final Object self, final Object byteOffset, final Object value, final Object littleEndian) {
    try {
        getBuffer(self, littleEndian).putDouble((int)JSType.toUint32(byteOffset), JSType.toNumber(value));
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:NativeDataView.java

示例8: setRangeError

/**
 * Setter for the RangeError property.
 * @param self self reference
 * @param value value for the RangeError property
 */
@Setter(name = "RangeError", attributes = Attribute.NOT_ENUMERABLE)
public static void setRangeError(final Object self, final Object value) {
    final Global global = Global.instanceFrom(self);
    global.rangeError = value;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Global.java

示例9: getRuntimeEvents

/**
 * Return all runtime events in the queue as an array
 * @param self self reference
 * @return array of events
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getRuntimeEvents(final Object self) {
    final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
    return q.toArray(new RuntimeEvent<?>[0]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NativeDebug.java

示例10: clearRuntimeEvents

/**
 * Clear the runtime event queue
 * @param self self reference
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static void clearRuntimeEvents(final Object self) {
    final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
    q.clear();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:NativeDebug.java

示例11: setHours

/**
 * ECMA 15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )
 *
 * @param self self reference
 * @param args hour (optional arguments after are minutes, seconds, milliseconds)
 * @return time
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 4)
public static double setHours(final Object self, final Object... args) {
    final NativeDate nd = getNativeDate(self);
    setFields(nd, HOUR, args, true);
    return nd.getTime();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:NativeDate.java

示例12: subarray

/**
 * Returns a new TypedArray view of the ArrayBuffer store for this TypedArray,
 * referencing the elements at begin, inclusive, up to end, exclusive. If either
 * begin or end is negative, it refers to an index from the end of the array,
 * as opposed to from the beginning.
 * <p>
 * If end is unspecified, the subarray contains all elements from begin to the end
 * of the TypedArray. The range specified by the begin and end values is clamped to
 * the valid index range for the current array. If the computed length of the new
 * TypedArray would be negative, it is clamped to zero.
 * <p>
 * The returned TypedArray will be of the same type as the array on which this
 * method is invoked.
 *
 * @param self self reference
 * @param begin begin position
 * @param end end position
 *
 * @return sub array
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
protected static NativeFloat64Array subarray(final Object self, final Object begin, final Object end) {
    return (NativeFloat64Array)ArrayBufferView.subarrayImpl(self, begin, end);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:NativeFloat64Array.java

示例13: valueOf

/**
 * ECMA 15.5.4.3 String.prototype.valueOf ( )
 * @param self self reference
 * @return self as string
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String valueOf(final Object self) {
    return getString(self);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:NativeString.java

示例14: random

/**
 * ECMA 15.8.2.14 random()
 *
 * @param self  self reference
 *
 * @return random number in the range [0..1)
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static double random(final Object self) {
    return Math.random();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:NativeMath.java

示例15: _super

/**
 * When given an object created using {@code Java.extend()} or equivalent mechanism (that is, any JavaScript-to-Java
 * adapter), returns an object that can be used to invoke superclass methods on that object. E.g.:
 * <pre>
 * var cw = new FilterWriterAdapter(sw) {
 *     write: function(s, off, len) {
 *         s = capitalize(s, off, len)
 *         cw_super.write(s, 0, s.length())
 *     }
 * }
 * var cw_super = Java.super(cw)
 * </pre>
 * @param self the {@code Java} object itself - not used.
 * @param adapter the original Java adapter instance for which the super adapter is created.
 * @return a super adapter for the original adapter
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR, name="super")
public static Object _super(final Object self, final Object adapter) {
    return Bootstrap.createSuperAdapter(adapter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:NativeJava.java


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