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


Java ArrayIndex.getArrayIndex方法代码示例

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


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

示例1: get

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static Object get(final Object self, final Object key) {
    final CharSequence cs = JSType.toCharSequence(self);
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    if (index >= 0 && index < cs.length()) {
        return String.valueOf(cs.charAt(index));
    }
    return ((ScriptObject) Global.toObject(self)).get(primitiveKey);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:NativeString.java

示例2: get

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public Object get(final Object key) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    if (index >= 0 && index < value.length()) {
        return String.valueOf(value.charAt(index));
    }
    return super.get(primitiveKey);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NativeString.java

示例3: getOwnPropertyDescriptor

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public Object getOwnPropertyDescriptor(final Object key) {
    final int index = ArrayIndex.getArrayIndex(key);
    if (index >= 0 && index < value.length()) {
        final Global global = Global.instance();
        return global.newDataDescriptor(String.valueOf(value.charAt(index)), false, true, false);
    }

    return super.getOwnPropertyDescriptor(key);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:NativeString.java

示例4: setPropertyValue

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value) {
    final int index = ArrayIndex.getArrayIndex(name);
    if (ArrayIndex.isValidArrayIndex(index)) {
        // array index key
        sobj.defineOwnProperty(index, value);
    } else if (sobj.getMap().findProperty(name) != null) {
        // pre-existing non-inherited property, call set
        sobj.set(name, value, 0);
    } else {
        // add new property
        sobj.addOwnProperty(name, Property.WRITABLE_ENUMERABLE_CONFIGURABLE, value);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:JSONFunctions.java

示例5: getOwnPropertyDescriptor

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public Object getOwnPropertyDescriptor(final String key) {
    final int index = ArrayIndex.getArrayIndex(key);
    if (index >= 0 && index < value.length()) {
        final Global global = Global.instance();
        return global.newDataDescriptor(String.valueOf(value.charAt(index)), false, true, false);
    }

    return super.getOwnPropertyDescriptor(key);
}
 
开发者ID:JetBrains,项目名称:jdk8u_nashorn,代码行数:11,代码来源:NativeString.java

示例6: defineOwnProperty

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
/**
 * ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw ) as specialized in
 * ECMA 10.6 for Arguments object.
 */
@Override
public boolean defineOwnProperty(final String key, final Object propertyDesc, final boolean reject) {
    final int index = ArrayIndex.getArrayIndex(key);
    if (index >= 0) {
        final boolean isMapped = isMapped(index);
        final Object oldValue = isMapped ? getArray().getObject(index) : null;

        if (!super.defineOwnProperty(key, propertyDesc, false)) {
            if (reject) {
                throw typeError("cant.redefine.property",  key, ScriptRuntime.safeToString(this));
            }
            return false;
        }

        if (isMapped) {
            // When mapped argument is redefined, if new descriptor is accessor property
            // or data-non-writable property, we have to "unmap" (unlink).
            final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
            if (desc.type() == PropertyDescriptor.ACCESSOR) {
                setDeleted(index, oldValue);
            } else if (desc.has(PropertyDescriptor.WRITABLE) && !desc.isWritable()) {
                // delete and set value from new descriptor if it has one, otherwise use old value
                setDeleted(index, desc.has(PropertyDescriptor.VALUE) ? desc.getValue() : oldValue);
            } else if (desc.has(PropertyDescriptor.VALUE)) {
                setArray(getArray().set(index, desc.getValue(), false));
            }
        }

        return true;
    }

    return super.defineOwnProperty(key, propertyDesc, reject);
}
 
开发者ID:malaporte,项目名称:kaziranga,代码行数:38,代码来源:NativeArguments.java

示例7: defineOwnProperty

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
/**
 * ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw ) as specialized in
 * ECMA 10.6 for Arguments object.
 */
@Override
public boolean defineOwnProperty(final Object key, final Object propertyDesc, final boolean reject) {
    final int index = ArrayIndex.getArrayIndex(key);
    if (index >= 0) {
        final boolean isMapped = isMapped(index);
        final Object oldValue = isMapped ? getArray().getObject(index) : null;

        if (!super.defineOwnProperty(key, propertyDesc, false)) {
            if (reject) {
                throw typeError("cant.redefine.property",  key.toString(), ScriptRuntime.safeToString(this));
            }
            return false;
        }

        if (isMapped) {
            // When mapped argument is redefined, if new descriptor is accessor property
            // or data-non-writable property, we have to "unmap" (unlink).
            final PropertyDescriptor desc = toPropertyDescriptor(Global.instance(), propertyDesc);
            if (desc.type() == PropertyDescriptor.ACCESSOR) {
                setDeleted(index, oldValue);
            } else if (desc.has(PropertyDescriptor.WRITABLE) && !desc.isWritable()) {
                // delete and set value from new descriptor if it has one, otherwise use old value
                setDeleted(index, desc.has(PropertyDescriptor.VALUE) ? desc.getValue() : oldValue);
            } else if (desc.has(PropertyDescriptor.VALUE)) {
                setArray(getArray().set(index, desc.getValue(), false));
            }
        }

        return true;
    }

    return super.defineOwnProperty(key, propertyDesc, reject);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:38,代码来源:NativeArguments.java

示例8: has

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean has(final Object key) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    return isValidStringIndex(index) || super.has(primitiveKey);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:NativeString.java

示例9: hasOwnProperty

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean hasOwnProperty(final Object key) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    return isValidStringIndex(index) || super.hasOwnProperty(primitiveKey);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:NativeString.java

示例10: delete

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean delete(final double key, final boolean strict) {
    final int index = ArrayIndex.getArrayIndex(key);
    return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:NativeArguments.java

示例11: delete

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean delete(final double key, final boolean strict) {
    final int index = ArrayIndex.getArrayIndex(key);
    return checkDeleteIndex(index, strict)? false : super.delete(key, strict);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:NativeString.java

示例12: delete

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean delete(final Object key, final boolean strict) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    return checkDeleteIndex(index, strict)? false : super.delete(primitiveKey, strict);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:NativeString.java

示例13: has

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean has(final double key) {
    final int index = ArrayIndex.getArrayIndex(key);
    return isValidStringIndex(index) || super.has(key);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:NativeString.java

示例14: delete

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean delete(final long key, final boolean strict) {
    final int index = ArrayIndex.getArrayIndex(key);
    return isMapped(index) ? deleteMapped(index, strict) : super.delete(key, strict);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:NativeArguments.java

示例15: delete

import jdk.nashorn.internal.runtime.arrays.ArrayIndex; //导入方法依赖的package包/类
@Override
public boolean delete(final Object key, final boolean strict) {
    final Object primitiveKey = JSType.toPrimitive(key, String.class);
    final int index = ArrayIndex.getArrayIndex(primitiveKey);
    return isMapped(index) ? deleteMapped(index, strict) : super.delete(primitiveKey, strict);
}
 
开发者ID:JetBrains,项目名称:jdk8u_nashorn,代码行数:7,代码来源:NativeArguments.java


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