public static XMLLib extractFromScope(Scriptable scope) { XMLLib lib = extractFromScopeOrNull(scope); if (lib != null) { return lib; } String msg = ScriptRuntime.getMessage0("msg.XML.not.available"); throw Context.reportRuntimeError(msg); }
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); }
public static XMLLib extractFromScopeOrNull(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // If librray is not yet initialized, return null return null; } // Ensure lazily initialization of real XML library instance // which is done on first access to XML property ScriptableObject.getProperty(so, "XML"); return (XMLLib) so.getAssociatedValue(XML_LIB_KEY); }