コード例 #1
0
ファイル: XMLLib.java プロジェクト: smartfeeling/smartly
 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);
 }
コード例 #2
0
ファイル: XMLLib.java プロジェクト: smartfeeling/smartly
  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);
  }