本文整理了Java中org.mozilla.javascript.ScriptableObject.associateValue()
方法的一些代码示例,展示了ScriptableObject.associateValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScriptableObject.associateValue()
方法的具体详情如下:
包路径:org.mozilla.javascript.ScriptableObject
类名称:ScriptableObject
方法名:associateValue
[英]Associate arbitrary application-specific value with this object. Value can only be associated with the given object and key only once. The method ignores any subsequent attempts to change the already associated value.
The associated values are not serialized.
[中]将任意特定于应用程序的值与此对象关联。值只能与给定对象和键关联一次。该方法将忽略任何后续更改已关联值的尝试。
关联的值未序列化。
代码示例来源:origin: geogebra/geogebra
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: rhino/js
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: io.apigee/rhino
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: com.github.tntim96/rhino
protected final XMLLib bindToScope(Scriptable scope)
{
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope);
if (so == null) {
// standard library should be initialized at this point
throw new IllegalStateException();
}
return (XMLLib)so.associateValue(XML_LIB_KEY, this);
}
代码示例来源:origin: rhino/js
/**
* Associate ClassCache object with the given top-level scope.
* The ClassCache object can only be associated with the given scope once.
*
* @param topScope scope to associate this ClassCache object with.
* @return true if no previous ClassCache objects were embedded into
* the scope and this ClassCache were successfully associated
* or false otherwise.
*
* @see #get(Scriptable scope)
*/
public boolean associate(ScriptableObject topScope)
{
if (topScope.getParentScope() != null) {
// Can only associate cache with top level scope
throw new IllegalArgumentException();
}
if (this == topScope.associateValue(AKEY, this)) {
return true;
}
return false;
}
代码示例来源:origin: io.apigee.trireme/trireme-util
@JSFunction
@SuppressWarnings("unused")
public static Object createDocument(Context cx, Scriptable thisObj, Object[] args, Function funObj)
{
ensureArg(args, 0);
XmlWrapImpl self = (XmlWrapImpl)thisObj;
Source src = self.getSource(cx, args[0]);
ScriptableObject ret = (ScriptableObject)cx.newObject(thisObj);
ret.associateValue("document", src);
return ret;
}
代码示例来源:origin: geogebra/geogebra
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) {
// XXX: Currently only instances of ScriptableObject are
// supported since the resulting interface proxies should
// be reused next time conversion is made and generic
// Callable has no storage for it. Weak references can
// address it but for now use this restriction.
Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type);
Object old = so.getAssociatedValue(key);
if (old != null) {
// Function was already wrapped
return old;
}
Context cx = Context.getContext();
Object glue = InterfaceAdapter.create(cx, type, so);
// Store for later retrieval
glue = so.associateValue(key, glue);
return glue;
}
代码示例来源:origin: io.apigee/rhino
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) {
// XXX: Currently only instances of ScriptableObject are
// supported since the resulting interface proxies should
// be reused next time conversion is made and generic
// Callable has no storage for it. Weak references can
// address it but for now use this restriction.
Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type);
Object old = so.getAssociatedValue(key);
if (old != null) {
// Function was already wrapped
return old;
}
Context cx = Context.getContext();
Object glue = InterfaceAdapter.create(cx, type, so);
// Store for later retrieval
glue = so.associateValue(key, glue);
return glue;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) {
// XXX: Currently only instances of ScriptableObject are
// supported since the resulting interface proxies should
// be reused next time conversion is made and generic
// Callable has no storage for it. Weak references can
// address it but for now use this restriction.
Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type);
Object old = so.getAssociatedValue(key);
if (old != null) {
// Function was already wrapped
return old;
}
Context cx = Context.getContext();
Object glue = InterfaceAdapter.create(cx, type, so);
// Store for later retrieval
glue = so.associateValue(key, glue);
return glue;
}
代码示例来源:origin: com.github.tntim96/rhino
protected static Object createInterfaceAdapter(Class<?>type, ScriptableObject so) {
// XXX: Currently only instances of ScriptableObject are
// supported since the resulting interface proxies should
// be reused next time conversion is made and generic
// Callable has no storage for it. Weak references can
// address it but for now use this restriction.
Object key = Kit.makeHashKeyFromPair(COERCED_INTERFACE_KEY, type);
Object old = so.getAssociatedValue(key);
if (old != null) {
// Function was already wrapped
return old;
}
Context cx = Context.getContext();
Object glue = InterfaceAdapter.create(cx, type, so);
// Store for later retrieval
glue = so.associateValue(key, glue);
return glue;
}
代码示例来源:origin: io.apigee.trireme/trireme-util
@JSFunction
@SuppressWarnings("unused")
public static Object createStylesheet(Context cx, Scriptable thisObj, Object[] args, Function funObj)
{
ensureArg(args, 0);
XmlWrapImpl self = (XmlWrapImpl)thisObj;
Source src = self.getSource(cx, args[0]);
try {
// Keep in mind that we are in Node.js and the factory will be single-threaded.
// Set the error listener to prevent stuff being written to standard error.
Err errs = new Err();
self.transFactory.setErrorListener(errs);
Templates tmpl = self.transFactory.newTemplates(src);
ScriptableObject ret = (ScriptableObject)cx.newObject(thisObj);
ret.associateValue("template", tmpl);
return ret;
} catch (TransformerConfigurationException e) {
throw Utils.makeError(cx, thisObj, "XSLT transformer exception: " + e);
}
}
代码示例来源:origin: rhino/js
static NativeGenerator init(ScriptableObject scope, boolean sealed) {
// Generator
// Can't use "NativeGenerator().exportAsJSClass" since we don't want
// to define "Generator" as a constructor in the top-level scope.
NativeGenerator prototype = new NativeGenerator();
if (scope != null) {
prototype.setParentScope(scope);
prototype.setPrototype(getObjectPrototype(scope));
}
prototype.activatePrototypeMap(MAX_PROTOTYPE_ID);
if (sealed) {
prototype.sealObject();
}
// Need to access Generator prototype when constructing
// Generator instances, but don't have a generator constructor
// to use to find the prototype. Use the "associateValue"
// approach instead.
if (scope != null) {
scope.associateValue(GENERATOR_TAG, prototype);
}
return prototype;
}
代码示例来源:origin: geogebra/geogebra
static NativeGenerator init(ScriptableObject scope, boolean sealed) {
// Generator
// Can't use "NativeGenerator().exportAsJSClass" since we don't want
// to define "Generator" as a constructor in the top-level scope.
NativeGenerator prototype = new NativeGenerator();
if (scope != null) {
prototype.setParentScope(scope);
prototype.setPrototype(getObjectPrototype(scope));
}
prototype.activatePrototypeMap(MAX_PROTOTYPE_ID);
if (sealed) {
prototype.sealObject();
}
// Need to access Generator prototype when constructing
// Generator instances, but don't have a generator constructor
// to use to find the prototype. Use the "associateValue"
// approach instead.
if (scope != null) {
scope.associateValue(GENERATOR_TAG, prototype);
}
return prototype;
}
代码示例来源:origin: rhino/js
static void init(ScriptableObject scope, boolean sealed) {
// Iterator
NativeIterator iterator = new NativeIterator();
iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// Generator
NativeGenerator.init(scope, sealed);
// StopIteration
NativeObject obj = new StopIteration();
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }
ScriptableObject.defineProperty(scope, STOP_ITERATION, obj,
ScriptableObject.DONTENUM);
// Use "associateValue" so that generators can continue to
// throw StopIteration even if the property of the global
// scope is replaced or deleted.
scope.associateValue(ITERATOR_TAG, obj);
}
代码示例来源:origin: io.apigee/rhino
static void init(ScriptableObject scope, boolean sealed) {
// Iterator
NativeIterator iterator = new NativeIterator();
iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// Generator
NativeGenerator.init(scope, sealed);
// StopIteration
NativeObject obj = new StopIteration();
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }
ScriptableObject.defineProperty(scope, STOP_ITERATION, obj,
ScriptableObject.DONTENUM);
// Use "associateValue" so that generators can continue to
// throw StopIteration even if the property of the global
// scope is replaced or deleted.
scope.associateValue(ITERATOR_TAG, obj);
}
代码示例来源:origin: geogebra/geogebra
static void init(ScriptableObject scope, boolean sealed) {
// Iterator
NativeIterator iterator = new NativeIterator();
iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// Generator
NativeGenerator.init(scope, sealed);
// StopIteration
NativeObject obj = new StopIteration();
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }
ScriptableObject.defineProperty(scope, STOP_ITERATION, obj,
ScriptableObject.DONTENUM);
// Use "associateValue" so that generators can continue to
// throw StopIteration even if the property of the global
// scope is replaced or deleted.
scope.associateValue(ITERATOR_TAG, obj);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
static void init(ScriptableObject scope, boolean sealed) {
// Iterator
NativeIterator iterator = new NativeIterator();
iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// Generator
NativeGenerator.init(scope, sealed);
// StopIteration
NativeObject obj = new StopIteration();
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }
ScriptableObject.defineProperty(scope, STOP_ITERATION, obj,
ScriptableObject.DONTENUM);
// Use "associateValue" so that generators can continue to
// throw StopIteration even if the property of the global
// scope is replaced or deleted.
scope.associateValue(ITERATOR_TAG, obj);
}
代码示例来源:origin: com.github.tntim96/rhino
static void init(ScriptableObject scope, boolean sealed) {
// Iterator
NativeIterator iterator = new NativeIterator();
iterator.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed);
// Generator
NativeGenerator.init(scope, sealed);
// StopIteration
NativeObject obj = new StopIteration();
obj.setPrototype(getObjectPrototype(scope));
obj.setParentScope(scope);
if (sealed) { obj.sealObject(); }
ScriptableObject.defineProperty(scope, STOP_ITERATION, obj,
ScriptableObject.DONTENUM);
// Use "associateValue" so that generators can continue to
// throw StopIteration even if the property of the global
// scope is replaced or deleted.
scope.associateValue(ITERATOR_TAG, obj);
}
内容来源于网络,如有侵权,请联系作者删除!