| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package org.mozilla.javascript.xml; |
| 8 |
|
| 9 |
import org.mozilla.javascript.*; |
| 10 |
|
| 11 |
public abstract class XMLLib |
| 12 |
{ |
| 13 |
private static final Object XML_LIB_KEY = new Object(); |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public static abstract class Factory { |
| 25 |
|
| 26 |
public static Factory create(final String className) { |
| 27 |
return new Factory() { |
| 28 |
@Override |
| 29 |
public String getImplementationClassName() { |
| 30 |
return className; |
| 31 |
} |
| 32 |
}; |
| 33 |
} |
| 34 |
|
| 35 |
public abstract String getImplementationClassName(); |
| 36 |
} |
| 37 |
|
| 38 |
public static XMLLib extractFromScopeOrNull(Scriptable scope) |
| 39 |
{ |
| 40 |
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); |
| 41 |
if (so == null) { |
| 42 |
|
| 43 |
return null; |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
ScriptableObject.getProperty(so, "XML"); |
| 49 |
|
| 50 |
return (XMLLib)so.getAssociatedValue(XML_LIB_KEY); |
| 51 |
} |
| 52 |
|
| 53 |
public static XMLLib extractFromScope(Scriptable scope) |
| 54 |
{ |
| 55 |
XMLLib lib = extractFromScopeOrNull(scope); |
| 56 |
if (lib != null) { |
| 57 |
return lib; |
| 58 |
} |
| 59 |
String msg = ScriptRuntime.getMessage0("msg.XML.not.available"); |
| 60 |
throw Context.reportRuntimeError(msg); |
| 61 |
} |
| 62 |
|
| 63 |
protected final XMLLib bindToScope(Scriptable scope) |
| 64 |
{ |
| 65 |
ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); |
| 66 |
if (so == null) { |
| 67 |
|
| 68 |
throw new IllegalStateException(); |
| 69 |
} |
| 70 |
return (XMLLib)so.associateValue(XML_LIB_KEY, this); |
| 71 |
} |
| 72 |
|
| 73 |
public abstract boolean isXMLName(Context cx, Object name); |
| 74 |
|
| 75 |
public abstract Ref nameRef(Context cx, Object name, |
| 76 |
Scriptable scope, int memberTypeFlags); |
| 77 |
|
| 78 |
public abstract Ref nameRef(Context cx, Object namespace, Object name, |
| 79 |
Scriptable scope, int memberTypeFlags); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public abstract String escapeAttributeValue(Object value); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
public abstract String escapeTextValue(Object value); |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public abstract Object toDefaultXmlNamespace(Context cx, Object uriValue); |
| 102 |
|
| 103 |
public void setIgnoreComments(boolean b) { |
| 104 |
throw new UnsupportedOperationException(); |
| 105 |
} |
| 106 |
|
| 107 |
public void setIgnoreWhitespace(boolean b) { |
| 108 |
throw new UnsupportedOperationException(); |
| 109 |
} |
| 110 |
|
| 111 |
public void setIgnoreProcessingInstructions(boolean b) { |
| 112 |
throw new UnsupportedOperationException(); |
| 113 |
} |
| 114 |
|
| 115 |
public void setPrettyPrinting(boolean b) { |
| 116 |
throw new UnsupportedOperationException(); |
| 117 |
} |
| 118 |
|
| 119 |
public void setPrettyIndent(int i) { |
| 120 |
throw new UnsupportedOperationException(); |
| 121 |
} |
| 122 |
|
| 123 |
public boolean isIgnoreComments() { |
| 124 |
throw new UnsupportedOperationException(); |
| 125 |
} |
| 126 |
|
| 127 |
public boolean isIgnoreProcessingInstructions() { |
| 128 |
throw new UnsupportedOperationException(); |
| 129 |
} |
| 130 |
|
| 131 |
public boolean isIgnoreWhitespace() { |
| 132 |
throw new UnsupportedOperationException(); |
| 133 |
} |
| 134 |
|
| 135 |
public boolean isPrettyPrinting() { |
| 136 |
throw new UnsupportedOperationException(); |
| 137 |
} |
| 138 |
|
| 139 |
public int getPrettyIndent() { |
| 140 |
throw new UnsupportedOperationException(); |
| 141 |
} |
| 142 |
} |