本文整理汇总了Java中jdk.nashorn.internal.runtime.PropertyDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java PropertyDescriptor类的具体用法?Java PropertyDescriptor怎么用?Java PropertyDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDescriptor类属于jdk.nashorn.internal.runtime包,在下文中一共展示了PropertyDescriptor类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillFrom
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
if (sobj.has(CONFIGURABLE)) {
this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
} else {
delete(CONFIGURABLE, false);
}
if (sobj.has(ENUMERABLE)) {
this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
} else {
delete(ENUMERABLE, false);
}
return this;
}
示例2: hasAndEquals
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public boolean hasAndEquals(final PropertyDescriptor other) {
if (has(CONFIGURABLE) && other.has(CONFIGURABLE)) {
if (isConfigurable() != other.isConfigurable()) {
return false;
}
}
if (has(ENUMERABLE) && other.has(ENUMERABLE)) {
if (isEnumerable() != other.isEnumerable()) {
return false;
}
}
return true;
}
示例3: defineOwnProperty
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的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);
}
示例4: newAccessorDescriptor
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
/**
* Create a new ECMAScript AccessorPropertyDescriptor object.
*
* @param get getter function of the user accessor property
* @param set setter function of the user accessor property
* @param configurable is the property configurable?
* @param enumerable is the property enumerable?
* @return newly created AccessorPropertyDescriptor object
*/
public PropertyDescriptor newAccessorDescriptor(final Object get, final Object set, final boolean configurable, final boolean enumerable) {
final AccessorPropertyDescriptor desc = new AccessorPropertyDescriptor(configurable, enumerable, get == null ? UNDEFINED : get, set == null ? UNDEFINED : set, this);
if (get == null) {
desc.delete(PropertyDescriptor.GET, false);
}
if (set == null) {
desc.delete(PropertyDescriptor.SET, false);
}
return desc;
}
示例5: fillFrom
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
if (sobj.has(CONFIGURABLE)) {
this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
} else {
delete(CONFIGURABLE, false);
}
if (sobj.has(ENUMERABLE)) {
this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
} else {
delete(ENUMERABLE, false);
}
if (sobj.has(WRITABLE)) {
this.writable = JSType.toBoolean(sobj.get(WRITABLE));
} else {
delete(WRITABLE, false);
}
if (sobj.has(VALUE)) {
this.value = sobj.get(VALUE);
} else {
delete(VALUE, false);
}
return this;
}
示例6: hasAndEquals
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public boolean hasAndEquals(final PropertyDescriptor otherDesc) {
if (! (otherDesc instanceof DataPropertyDescriptor)) {
return false;
}
final DataPropertyDescriptor other = (DataPropertyDescriptor)otherDesc;
return (!has(CONFIGURABLE) || sameValue(configurable, other.configurable)) &&
(!has(ENUMERABLE) || sameValue(enumerable, other.enumerable)) &&
(!has(WRITABLE) || sameValue(writable, other.writable)) &&
(!has(VALUE) || sameValue(value, other.value));
}
示例7: fillFrom
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public PropertyDescriptor fillFrom(final ScriptObject sobj) {
if (sobj.has(CONFIGURABLE)) {
this.configurable = JSType.toBoolean(sobj.get(CONFIGURABLE));
} else {
delete(CONFIGURABLE, false);
}
if (sobj.has(ENUMERABLE)) {
this.enumerable = JSType.toBoolean(sobj.get(ENUMERABLE));
} else {
delete(ENUMERABLE, false);
}
if (sobj.has(GET)) {
final Object getter = sobj.get(GET);
if (getter == UNDEFINED || getter instanceof ScriptFunction) {
this.get = getter;
} else {
throw typeError("not.a.function", ScriptRuntime.safeToString(getter));
}
} else {
delete(GET, false);
}
if (sobj.has(SET)) {
final Object setter = sobj.get(SET);
if (setter == UNDEFINED || setter instanceof ScriptFunction) {
this.set = setter;
} else {
throw typeError("not.a.function", ScriptRuntime.safeToString(setter));
}
} else {
delete(SET, false);
}
return this;
}
示例8: hasAndEquals
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的package包/类
@Override
public boolean hasAndEquals(final PropertyDescriptor otherDesc) {
if (! (otherDesc instanceof AccessorPropertyDescriptor)) {
return false;
}
final AccessorPropertyDescriptor other = (AccessorPropertyDescriptor)otherDesc;
return (!has(CONFIGURABLE) || sameValue(configurable, other.configurable)) &&
(!has(ENUMERABLE) || sameValue(enumerable, other.enumerable)) &&
(!has(GET) || sameValue(get, other.get)) &&
(!has(SET) || sameValue(set, other.set));
}
示例9: defineOwnProperty
import jdk.nashorn.internal.runtime.PropertyDescriptor; //导入依赖的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);
}