📄 xmlobjectimpl.java
字号:
public final Object ecmaGet(Context cx, Object id) { if (cx == null) cx = Context.getCurrentContext(); XMLName xmlName = lib.toXMLNameOrIndex(cx, id); if (xmlName == null) { long index = ScriptRuntime.lastUint32Result(cx); // XXX Fix this cast Object result = get((int)index, this); if (result == Scriptable.NOT_FOUND) { result = Undefined.instance; } return result; } return getXMLProperty(xmlName); } /** * Implementation of ECMAScript [[Put]] */ public final void ecmaPut(Context cx, Object id, Object value) { if (cx == null) cx = Context.getCurrentContext(); XMLName xmlName = lib.toXMLNameOrIndex(cx, id); if (xmlName == null) { long index = ScriptRuntime.lastUint32Result(cx); // XXX Fix this cast put((int)index, this, value); return; } putXMLProperty(xmlName, value); } /** * Implementation of ECMAScript [[Delete]]. */ public final boolean ecmaDelete(Context cx, Object id) { if (cx == null) cx = Context.getCurrentContext(); XMLName xmlName = lib.toXMLNameOrIndex(cx, id); if (xmlName == null) { long index = ScriptRuntime.lastUint32Result(cx); // XXX Fix this delete((int)index); return true; } deleteXMLProperty(xmlName); return true; } // TODO Can this be made more strongly typed? public Ref memberRef(Context cx, Object elem, int memberTypeFlags) { boolean attribute = (memberTypeFlags & Node.ATTRIBUTE_FLAG) != 0; boolean descendants = (memberTypeFlags & Node.DESCENDANTS_FLAG) != 0; if (!attribute && !descendants) { // Code generation would use ecma(Get|Has|Delete|Set) for // normal name identifiers so one ATTRIBUTE_FLAG // or DESCENDANTS_FLAG has to be set throw Kit.codeBug(); } XmlNode.QName qname = lib.toNodeQName(cx, elem, attribute); XMLName rv = XMLName.create(qname, attribute, descendants); rv.initXMLObject(this); return rv; } /** * Generic reference to implement x::ns, x.@ns::y, x..@ns::y etc. */ public Ref memberRef(Context cx, Object namespace, Object elem, int memberTypeFlags) { boolean attribute = (memberTypeFlags & Node.ATTRIBUTE_FLAG) != 0; boolean descendants = (memberTypeFlags & Node.DESCENDANTS_FLAG) != 0; XMLName rv = XMLName.create(lib.toNodeQName(cx, namespace, elem), attribute, descendants); rv.initXMLObject(this); return rv; } public NativeWith enterWith(Scriptable scope) { return new XMLWithScope(lib, scope, this); } public NativeWith enterDotQuery(Scriptable scope) { XMLWithScope xws = new XMLWithScope(lib, scope, this); xws.initAsDotQuery(); return xws; } public final Object addValues(Context cx, boolean thisIsLeft, Object value) { if (value instanceof XMLObject) { XMLObject v1, v2; if (thisIsLeft) { v1 = this; v2 = (XMLObject)value; } else { v1 = (XMLObject)value; v2 = this; } return lib.addXMLObjects(cx, v1, v2); } if (value == Undefined.instance) { // both "xml + undefined" and "undefined + xml" gives String(xml) return ScriptRuntime.toString(this); } return super.addValues(cx, thisIsLeft, value); } // // // IdScriptableObject machinery // // final void exportAsJSClass(boolean sealed) { prototypeFlag = true; exportAsJSClass(MAX_PROTOTYPE_ID, getParentScope(), sealed); }// #string_id_map# private final static int Id_constructor = 1, Id_addNamespace = 2, Id_appendChild = 3, Id_attribute = 4, Id_attributes = 5, Id_child = 6, Id_childIndex = 7, Id_children = 8, Id_comments = 9, Id_contains = 10, Id_copy = 11, Id_descendants = 12, Id_elements = 13, Id_inScopeNamespaces = 14, Id_insertChildAfter = 15, Id_insertChildBefore = 16, Id_hasOwnProperty = 17, Id_hasComplexContent = 18, Id_hasSimpleContent = 19, Id_length = 20, Id_localName = 21, Id_name = 22, Id_namespace = 23, Id_namespaceDeclarations = 24, Id_nodeKind = 25, Id_normalize = 26, Id_parent = 27, Id_prependChild = 28, Id_processingInstructions = 29, Id_propertyIsEnumerable = 30, Id_removeNamespace = 31, Id_replace = 32, Id_setChildren = 33, Id_setLocalName = 34, Id_setName = 35, Id_setNamespace = 36, Id_text = 37, Id_toString = 38, Id_toXMLString = 39, Id_valueOf = 40, MAX_PROTOTYPE_ID = 40; protected int findPrototypeId(String s) { int id;// #generated# Last update: 2007-08-20 09:04:06 EDT L0: { id = 0; String X = null; int c; L: switch (s.length()) { case 4: c=s.charAt(0); if (c=='c') { X="copy";id=Id_copy; } else if (c=='n') { X="name";id=Id_name; } else if (c=='t') { X="text";id=Id_text; } break L; case 5: X="child";id=Id_child; break L; case 6: c=s.charAt(0); if (c=='l') { X="length";id=Id_length; } else if (c=='p') { X="parent";id=Id_parent; } break L; case 7: c=s.charAt(0); if (c=='r') { X="replace";id=Id_replace; } else if (c=='s') { X="setName";id=Id_setName; } else if (c=='v') { X="valueOf";id=Id_valueOf; } break L; case 8: switch (s.charAt(2)) { case 'S': X="toString";id=Id_toString; break L; case 'd': X="nodeKind";id=Id_nodeKind; break L; case 'e': X="elements";id=Id_elements; break L; case 'i': X="children";id=Id_children; break L; case 'm': X="comments";id=Id_comments; break L; case 'n': X="contains";id=Id_contains; break L; } break L; case 9: switch (s.charAt(2)) { case 'c': X="localName";id=Id_localName; break L; case 'm': X="namespace";id=Id_namespace; break L; case 'r': X="normalize";id=Id_normalize; break L; case 't': X="attribute";id=Id_attribute; break L; } break L; case 10: c=s.charAt(0); if (c=='a') { X="attributes";id=Id_attributes; } else if (c=='c') { X="childIndex";id=Id_childIndex; } break L; case 11: switch (s.charAt(0)) { case 'a': X="appendChild";id=Id_appendChild; break L; case 'c': X="constructor";id=Id_constructor; break L; case 'd': X="descendants";id=Id_descendants; break L; case 's': X="setChildren";id=Id_setChildren; break L; case 't': X="toXMLString";id=Id_toXMLString; break L; } break L; case 12: c=s.charAt(0); if (c=='a') { X="addNamespace";id=Id_addNamespace; } else if (c=='p') { X="prependChild";id=Id_prependChild; } else if (c=='s') { c=s.charAt(3); if (c=='L') { X="setLocalName";id=Id_setLocalName; } else if (c=='N') { X="setNamespace";id=Id_setNamespace; } } break L; case 14: X="hasOwnProperty";id=Id_hasOwnProperty; break L; case 15: X="removeNamespace";id=Id_removeNamespace; break L; case 16: c=s.charAt(0); if (c=='h') { X="hasSimpleContent";id=Id_hasSimpleContent; } else if (c=='i') { X="insertChildAfter";id=Id_insertChildAfter; } break L; case 17: c=s.charAt(3); if (c=='C') { X="hasComplexContent";id=Id_hasComplexContent; } else if (c=='c') { X="inScopeNamespaces";id=Id_inScopeNamespaces; } else if (c=='e') { X="insertChildBefore";id=Id_insertChildBefore; } break L; case 20: X="propertyIsEnumerable";id=Id_propertyIsEnumerable; break L; case 21: X="namespaceDeclarations";id=Id_namespaceDeclarations; break L; case 22: X="processingInstructions";id=Id_processingInstructions; break L; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; }// #/generated# return id; }// #/string_id_map# protected void initPrototypeId(int id) { String s; int arity; switch (id) { case Id_constructor: { IdFunctionObject ctor; if (this instanceof XML) { ctor = new XMLCtor((XML)this, XMLOBJECT_TAG, id, 1); } else { ctor = new IdFunctionObject(this, XMLOBJECT_TAG, id, 1); } initPrototypeConstructor(ctor); return; } case Id_addNamespace: arity=1; s="addNamespace"; break; case Id_appendChild: arity=1; s="appendChild"; break; case Id_attribute: arity=1; s="attribute"; break; case Id_attributes: arity=0; s="attributes"; break; case Id_child: arity=1; s="child"; break; case Id_childIndex: arity=0; s="childIndex"; break; case Id_children: arity=0; s="children"; break; case Id_comments: arity=0; s="comments"; break; case Id_contains: arity=1; s="contains"; break; case Id_copy: arity=0; s="copy"; break; case Id_descendants: arity=1; s="descendants"; break; case Id_elements: arity=1; s="elements"; break; case Id_hasComplexContent: arity=0; s="hasComplexContent"; break; case Id_hasOwnProperty: arity=1; s="hasOwnProperty"; break; case Id_hasSimpleContent: arity=0; s="hasSimpleContent"; break; case Id_inScopeNamespaces: arity=0; s="inScopeNamespaces"; break; case Id_insertChildAfter: arity=2; s="insertChildAfter"; break; case Id_insertChildBefore: arity=2; s="insertChildBefore"; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -