• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Attribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: expandEventQueueCapacity

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Expands the event queue capacity, or truncates if capacity is lower than
 * current capacity. Then only the newest entries are kept
 * @param self self reference
 * @param newCapacity new capacity
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static void expandEventQueueCapacity(final Object self, final Object newCapacity) {
    final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
    final int nc = JSType.toInt32(newCapacity);
    while (q.size() > nc) {
        q.removeFirst();
    }
    setEventQueueCapacity(self, nc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:NativeDebug.java


示例2: map

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )
 *
 * @param self        self reference
 * @param callbackfn  callback function per element
 * @param thisArg     this argument
 * @return array with elements transformed by map function
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
public static NativeArray map(final Object self, final Object callbackfn, final Object thisArg) {
    return new IteratorAction<NativeArray>(Global.toObject(self), callbackfn, thisArg, null) {
        private final MethodHandle mapInvoker = getMAP_CALLBACK_INVOKER();

        @Override
        protected boolean forEach(final Object val, final long i) throws Throwable {
            final Object r = mapInvoker.invokeExact(callbackfn, thisArg, val, i, self);
            result.defineOwnProperty(ArrayIndex.getArrayIndex(index), r);
            return true;
        }

        @Override
        public void applyLoopBegin(final ArrayLikeIterator<Object> iter0) {
            // map return array should be of same length as source array
            // even if callback reduces source array length
            result = new NativeArray(iter0.getLength());
        }
    }.apply();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:NativeArray.java


示例3: getUint8

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Get 8-bit unsigned int from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @return 8-bit unsigned int value at the byteOffset
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static int getUint8(final Object self, final Object byteOffset) {
    try {
        return 0xFF & getBuffer(self).get(JSType.toInt32(byteOffset));
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NativeDataView.java


示例4: charCodeAt

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.5.4.5 String.prototype.charCodeAt (pos)
 * @param self self reference
 * @param pos  position in string
 * @return number representing charcode at position
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static double charCodeAt(final Object self, final Object pos) {
    final String str = checkObjectToString(self);
    final int    idx = JSType.toInteger(pos);
    return idx < 0 || idx >= str.length() ? Double.NaN : str.charAt(idx);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:NativeString.java


示例5: localeCompare

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.5.4.9 String.prototype.localeCompare (that)
 * @param self self reference
 * @param that comparison object
 * @return result of locale sensitive comparison operation between {@code self} and {@code that}
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static double localeCompare(final Object self, final Object that) {

    final String   str      = checkObjectToString(self);
    final Collator collator = Collator.getInstance(Global.getEnv()._locale);

    collator.setStrength(Collator.IDENTICAL);
    collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);

    return collator.compare(str, JSType.toString(that));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeString.java


示例6: toJSON

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.9.5.44 Date.prototype.toJSON ( key )
 *
 * Provides a string representation of this Date for use by {@link NativeJSON#stringify(Object, Object, Object, Object)}
 *
 * @param self self reference
 * @param key ignored
 * @return JSON representation of this date
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toJSON(final Object self, final Object key) {
    // NOTE: Date.prototype.toJSON is generic. Accepts other objects as well.
    final Object selfObj = Global.toObject(self);
    if (!(selfObj instanceof ScriptObject)) {
        return null;
    }
    final ScriptObject sobj  = (ScriptObject)selfObj;
    final Object       value = sobj.getDefaultValue(Number.class);
    if (value instanceof Number) {
        final double num = ((Number)value).doubleValue();
        if (isInfinite(num) || isNaN(num)) {
            return null;
        }
    }

    try {
        final InvokeByName toIsoString = getTO_ISO_STRING();
        final Object func = toIsoString.getGetter().invokeExact(sobj);
        if (Bootstrap.isCallable(func)) {
            return toIsoString.getInvoker().invokeExact(func, sobj, key);
        }
        throw typeError("not.a.function", ScriptRuntime.safeToString(func));
    } catch (final RuntimeException | Error e) {
        throw e;
    } catch (final Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:NativeDate.java


示例7: getOwnPropertyNames

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.2.3.4 Object.getOwnPropertyNames ( O )
 *
 * @param self self reference
 * @param obj  object to query for property names
 * @return array of property names
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static ScriptObject getOwnPropertyNames(final Object self, final Object obj) {
    if (obj instanceof ScriptObject) {
        return new NativeArray(((ScriptObject)obj).getOwnKeys(true));
    } else if (obj instanceof ScriptObjectMirror) {
        return new NativeArray(((ScriptObjectMirror)obj).getOwnKeys(true));
    } else {
        throw notAnObject(obj);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeObject.java


示例8: getStackTrace

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Nashorn extension: Error.prototype.getStackTrace()
 * "stack" property is an array typed value containing {@link StackTraceElement}
 * objects of JavaScript stack frames.
 *
 * @param self  self reference
 *
 * @return      stack trace as a script array.
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object getStackTrace(final Object self) {
    final ScriptObject sobj = Global.checkObject(self);
    final Object exception = ECMAException.getException(sobj);
    Object[] res;
    if (exception instanceof Throwable) {
        res = NashornException.getScriptFrames((Throwable)exception);
    } else {
        res = ScriptRuntime.EMPTY_ARRAY;
    }

    return new NativeArray(res);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:NativeError.java


示例9: substring

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.5.4.15 String.prototype.substring (start, end)
 *
 * @param self  self reference
 * @param start start position of substring
 * @param end   end position of substring
 * @return substring given start and end indexes
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String substring(final Object self, final Object start, final Object end) {

    final String str = checkObjectToString(self);
    if (end == UNDEFINED) {
        return substring(str, JSType.toInteger(start));
    }
    return substring(str, JSType.toInteger(start), JSType.toInteger(end));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeString.java


示例10: setFloat64

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * 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:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeDataView.java


示例11: getInt16

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Get 16-bit signed int from given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to read from
 * @param littleEndian (optional) flag indicating whether to read in little endian order
 * @return 16-bit signed int value at the byteOffset
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
public static int getInt16(final Object self, final Object byteOffset, final Object littleEndian) {
    try {
        return getBuffer(self, littleEndian).getShort(JSType.toInt32(byteOffset));
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:NativeDataView.java


示例12: round

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.8.2.15 round(x)
 *
 * @param self  self reference
 * @param x     argument
 *
 * @return x rounded
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static double round(final Object self, final Object x) {
    final double d = JSType.toNumber(x);
    if (Math.getExponent(d) >= 52) {
        return d;
    }
    return Math.copySign(Math.floor(d + 0.5), d);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:NativeMath.java


示例13: setInt32

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Set 32-bit signed int at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value int 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 setInt32(final Object self, final Object byteOffset, final Object value, final Object littleEndian) {
    try {
        getBuffer(self, littleEndian).putInt(JSType.toInt32(byteOffset), JSType.toInt32(value));
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeDataView.java


示例14: getArrayData

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Return the ArrayData for this ScriptObject
 * @param self self
 * @param obj script object to check
 * @return ArrayData, ArrayDatas have toString methods, return Undefined if data missing
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object getArrayData(final Object self, final Object obj) {
    try {
        return ((ScriptObject)obj).getArray();
    } catch (final ClassCastException e) {
        return ScriptRuntime.UNDEFINED;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:NativeDebug.java


示例15: setUint16

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Set 16-bit unsigned int at the given byteOffset
 *
 * @param self DataView object
 * @param byteOffset byte offset to write at
 * @param value short 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 setUint16(final Object self, final Object byteOffset, final Object value, final Object littleEndian) {
    try {
        getBuffer(self, littleEndian).putShort(JSType.toInt32(byteOffset), (short)JSType.toInt32(value));
        return UNDEFINED;
    } catch (final IllegalArgumentException iae) {
        throw rangeError(iae, "dataview.offset");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NativeDataView.java


示例16: isExtensible

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * 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:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NativeObject.java


示例17: reverse

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.4.4.8 Array.prototype.reverse ()
 *
 * @param self self reference
 * @return reversed array
 */
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object reverse(final Object self) {
    try {
        final ScriptObject sobj   = (ScriptObject)self;
        final long         len    = JSType.toUint32(sobj.getLength());
        final long         middle = len / 2;

        for (long lower = 0; lower != middle; lower++) {
            final long    upper       = len - lower - 1;
            final Object  lowerValue  = sobj.get(lower);
            final Object  upperValue  = sobj.get(upper);
            final boolean lowerExists = sobj.has(lower);
            final boolean upperExists = sobj.has(upper);

            if (lowerExists && upperExists) {
                sobj.set(lower, upperValue, CALLSITE_STRICT);
                sobj.set(upper, lowerValue, CALLSITE_STRICT);
            } else if (!lowerExists && upperExists) {
                sobj.set(lower, upperValue, CALLSITE_STRICT);
                sobj.delete(upper, true);
            } else if (lowerExists && !upperExists) {
                sobj.delete(lower, true);
                sobj.set(upper, lowerValue, CALLSITE_STRICT);
            }
        }
        return sobj;
    } catch (final ClassCastException | NullPointerException e) {
        throw typeError("not.an.object", ScriptRuntime.safeToString(self));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:NativeArray.java


示例18: getWeakMap

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Getter for the WeakMap property.
 *
 * @param self self reference
 * @return  the value of the WeakMap property
 */
@Getter(name = "WeakMap", attributes = Attribute.NOT_ENUMERABLE)
public static Object getWeakMap(final Object self) {
    final Global global = Global.instanceFrom(self);
    if (global.weakMap == LAZY_SENTINEL) {
        global.weakMap = global.getBuiltinWeakMap();
    }
    return global.weakMap;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Global.java


示例19: captureStackTrace

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
 *
 * @param self self reference
 * @param errorObj the error object
 * @return undefined
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
    final ScriptObject sobj = Global.checkObject(errorObj);
    initException(sobj);
    sobj.delete(STACK, false);
    if (! sobj.has("stack")) {
        final ScriptFunction getStack = ScriptFunction.createBuiltin("getStack", GET_STACK);
        final ScriptFunction setStack = ScriptFunction.createBuiltin("setStack", SET_STACK);
        sobj.addOwnProperty("stack", Attribute.NOT_ENUMERABLE, getStack, setStack);
    }
    return UNDEFINED;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:NativeError.java


示例20: concat

import jdk.nashorn.internal.objects.annotations.Attribute; //导入依赖的package包/类
/**
 * ECMA 15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , ... ] ] ] )
 *
 * @param self self reference
 * @param args arguments
 * @return resulting NativeArray
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, arity = 1)
public static NativeArray concat(final Object self, final Object... args) {
    final ArrayList<Object> list = new ArrayList<>();

    concatToList(list, Global.toObject(self));

    for (final Object obj : args) {
        concatToList(list, obj);
    }

    return new NativeArray(list.toArray());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:NativeArray.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OutputObject类代码示例发布时间:2022-05-22
下一篇:
Java ThrowNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap