--- old/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java 2013-05-29 18:22:00.000000000 +0200 +++ new/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java 2013-05-29 18:22:00.000000000 +0200 @@ -24,6 +24,7 @@ import java.util.Vector; +import com.sun.org.apache.xalan.internal.utils.Objects; import com.sun.org.apache.xml.internal.dtm.DTM; import com.sun.org.apache.xml.internal.dtm.DTMDOMException; import com.sun.org.apache.xpath.internal.NodeSet; @@ -141,21 +142,21 @@ * * @return true if the given node has the same handle as this node. */ + @Override public final boolean equals(Object node) { - - try - { - // DTMNodeProxy dtmp = (DTMNodeProxy)node; // return (dtmp.node == this.node); // Patch attributed to Gary L Peskin - return equals((Node) node); - } - catch (ClassCastException cce) - { - return false; - } + return node instanceof Node && equals((Node) node); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + Objects.hashCode(this.dtm); + hash = 29 * hash + this.node; + return hash; } /** @@ -181,6 +182,7 @@ * * @see org.w3c.dom.Node */ + @Override public final String getNodeName() { return dtm.getNodeName(node); @@ -199,6 +201,7 @@ * * */ + @Override public final String getTarget() { return dtm.getNodeName(node); @@ -209,6 +212,7 @@ * * @see org.w3c.dom.Node as of DOM Level 2 */ + @Override public final String getLocalName() { return dtm.getLocalName(node); @@ -218,6 +222,7 @@ * @return The prefix for this node. * @see org.w3c.dom.Node as of DOM Level 2 */ + @Override public final String getPrefix() { return dtm.getPrefix(node); @@ -230,6 +235,7 @@ * @throws DOMException * @see org.w3c.dom.Node as of DOM Level 2 -- DTMNodeProxy is read-only */ + @Override public final void setPrefix(String prefix) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); @@ -240,6 +246,7 @@ * * @see org.w3c.dom.Node as of DOM Level 2 */ + @Override public final String getNamespaceURI() { return dtm.getNamespaceURI(node); @@ -277,6 +284,7 @@ * @return false * @see org.w3c.dom.Node as of DOM Level 2 */ + @Override public final boolean isSupported(String feature, String version) { return implementation.hasFeature(feature,version); @@ -290,6 +298,7 @@ * @throws DOMException * @see org.w3c.dom.Node */ + @Override public final String getNodeValue() throws DOMException { return dtm.getNodeValue(node); @@ -312,6 +321,7 @@ * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final void setNodeValue(String nodeValue) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); @@ -322,6 +332,7 @@ * * @see org.w3c.dom.Node */ + @Override public final short getNodeType() { return (short) dtm.getNodeType(node); @@ -332,6 +343,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Node getParentNode() { @@ -361,6 +373,7 @@ * * @see org.w3c.dom.Node */ + @Override public final NodeList getChildNodes() { @@ -377,6 +390,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Node getFirstChild() { @@ -390,6 +404,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Node getLastChild() { @@ -403,6 +418,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Node getPreviousSibling() { @@ -416,6 +432,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Node getNextSibling() { @@ -435,6 +452,7 @@ * * @see org.w3c.dom.Node */ + @Override public final NamedNodeMap getAttributes() { @@ -448,6 +466,7 @@ * @param name * */ + @Override public boolean hasAttribute(String name) { return DTM.NULL != dtm.getAttributeNode(node,null,name); @@ -462,6 +481,7 @@ * * */ + @Override public boolean hasAttributeNS(String namespaceURI, String localName) { return DTM.NULL != dtm.getAttributeNode(node,namespaceURI,localName); @@ -472,6 +492,7 @@ * * @see org.w3c.dom.Node */ + @Override public final Document getOwnerDocument() { // Note that this uses the DOM-compatable version of the call @@ -488,6 +509,7 @@ * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final Node insertBefore(Node newChild, Node refChild) throws DOMException { @@ -504,6 +526,7 @@ * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final Node replaceChild(Node newChild, Node oldChild) throws DOMException { @@ -519,6 +542,7 @@ * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final Node removeChild(Node oldChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); @@ -533,6 +557,7 @@ * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final Node appendChild(Node newChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); @@ -543,6 +568,7 @@ * * @see org.w3c.dom.Node */ + @Override public final boolean hasChildNodes() { return (DTM.NULL != dtm.getFirstChild(node)); @@ -555,6 +581,7 @@ * * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ + @Override public final Node cloneNode(boolean deep) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -565,6 +592,7 @@ * * @see org.w3c.dom.Document */ + @Override public final DocumentType getDoctype() { return null; @@ -575,6 +603,7 @@ * * @see org.w3c.dom.Document */ + @Override public final DOMImplementation getImplementation() { return implementation; @@ -587,6 +616,7 @@ * * @see org.w3c.dom.Document */ + @Override public final Element getDocumentElement() { int dochandle=dtm.getDocument(); @@ -634,6 +664,7 @@ * @throws DOMException * @see org.w3c.dom.Document */ + @Override public final Element createElement(String tagName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -644,6 +675,7 @@ * * @see org.w3c.dom.Document */ + @Override public final DocumentFragment createDocumentFragment() { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -656,6 +688,7 @@ * * @see org.w3c.dom.Document */ + @Override public final Text createTextNode(String data) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -668,6 +701,7 @@ * * @see org.w3c.dom.Document */ + @Override public final Comment createComment(String data) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -682,6 +716,7 @@ * @throws DOMException * @see org.w3c.dom.Document */ + @Override public final CDATASection createCDATASection(String data) throws DOMException { @@ -698,8 +733,9 @@ * @throws DOMException * @see org.w3c.dom.Document */ + @Override public final ProcessingInstruction createProcessingInstruction( - String target, String data) throws DOMException + String target, String data) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -713,6 +749,7 @@ * @throws DOMException * @see org.w3c.dom.Document */ + @Override public final Attr createAttribute(String name) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -727,6 +764,7 @@ * @throws DOMException * @see org.w3c.dom.Document */ + @Override public final EntityReference createEntityReference(String name) throws DOMException { @@ -739,6 +777,7 @@ * * @see org.w3c.dom.Document */ + @Override public final NodeList getElementsByTagName(String tagname) { Vector listVector = new Vector(); @@ -819,6 +858,7 @@ * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only */ + @Override public final Node importNode(Node importedNode, boolean deep) throws DOMException { @@ -835,8 +875,9 @@ * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 */ + @Override public final Element createElementNS( - String namespaceURI, String qualifiedName) throws DOMException + String namespaceURI, String qualifiedName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -851,8 +892,9 @@ * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 */ + @Override public final Attr createAttributeNS( - String namespaceURI, String qualifiedName) throws DOMException + String namespaceURI, String qualifiedName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -865,6 +907,7 @@ * * @see org.w3c.dom.Document as of DOM Level 2 */ + @Override public final NodeList getElementsByTagNameNS(String namespaceURI, String localName) { @@ -952,6 +995,7 @@ * * @see org.w3c.dom.Document as of DOM Level 2 */ + @Override public final Element getElementById(String elementId) { return (Element) dtm.getNode(dtm.getElementById(elementId)); @@ -966,6 +1010,7 @@ * @throws DOMException * @see org.w3c.dom.Text */ + @Override public final Text splitText(int offset) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -978,6 +1023,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final String getData() throws DOMException { return dtm.getNodeValue(node); @@ -990,6 +1036,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final void setData(String data) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1000,6 +1047,7 @@ * * @see org.w3c.dom.CharacterData */ + @Override public final int getLength() { // %OPT% This should do something smarter? @@ -1016,6 +1064,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final String substringData(int offset, int count) throws DOMException { return getData().substring(offset,offset+count); @@ -1028,6 +1077,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final void appendData(String arg) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1041,6 +1091,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final void insertData(int offset, String arg) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1054,6 +1105,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final void deleteData(int offset, int count) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1068,6 +1120,7 @@ * @throws DOMException * @see org.w3c.dom.CharacterData */ + @Override public final void replaceData(int offset, int count, String arg) throws DOMException { @@ -1079,6 +1132,7 @@ * * @see org.w3c.dom.Element */ + @Override public final String getTagName() { return dtm.getNodeName(node); @@ -1091,12 +1145,13 @@ * * @see org.w3c.dom.Element */ + @Override public final String getAttribute(String name) { - DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node); - Node node = map.getNamedItem(name); - return (null == node) ? EMPTYSTRING : node.getNodeValue(); } + Node n = map.getNamedItem(name); + return (null == n) ? EMPTYSTRING : n.getNodeValue(); + } /** * @@ -1106,6 +1161,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final void setAttribute(String name, String value) throws DOMException { @@ -1119,6 +1175,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final void removeAttribute(String name) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1131,9 +1188,9 @@ * * @see org.w3c.dom.Element */ + @Override public final Attr getAttributeNode(String name) { - DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node); return (Attr)map.getNamedItem(name); } @@ -1147,6 +1204,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final Attr setAttributeNode(Attr newAttr) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1161,6 +1219,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final Attr removeAttributeNode(Attr oldAttr) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1171,12 +1230,14 @@ * * */ + @Override public boolean hasAttributes() { return DTM.NULL != dtm.getFirstAttribute(node); } /** @see org.w3c.dom.Element */ + @Override public final void normalize() { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1190,6 +1251,7 @@ * * @see org.w3c.dom.Element */ + @Override public final String getAttributeNS(String namespaceURI, String localName) { Node retNode = null; @@ -1208,6 +1270,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final void setAttributeNS( String namespaceURI, String qualifiedName, String value) throws DOMException @@ -1223,6 +1286,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final void removeAttributeNS(String namespaceURI, String localName) throws DOMException { @@ -1237,6 +1301,7 @@ * * @see org.w3c.dom.Element */ + @Override public final Attr getAttributeNodeNS(String namespaceURI, String localName) { Attr retAttr = null; @@ -1256,6 +1321,7 @@ * @throws DOMException * @see org.w3c.dom.Element */ + @Override public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1266,6 +1332,7 @@ * * @see org.w3c.dom.Attr */ + @Override public final String getName() { return dtm.getNodeName(node); @@ -1276,6 +1343,7 @@ * * @see org.w3c.dom.Attr */ + @Override public final boolean getSpecified() { // We really don't know which attributes might have come from the @@ -1290,6 +1358,7 @@ * * @see org.w3c.dom.Attr */ + @Override public final String getValue() { return dtm.getNodeValue(node); @@ -1300,6 +1369,7 @@ * @param value * @see org.w3c.dom.Attr */ + @Override public final void setValue(String value) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1311,6 +1381,7 @@ * * @see org.w3c.dom.Attr as of DOM Level 2 */ + @Override public final Element getOwnerElement() { if (getNodeType() != Node.ATTRIBUTE_NODE) @@ -1331,9 +1402,9 @@ * * @throws DOMException */ + @Override public Node adoptNode(Node source) throws DOMException { - throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -1348,9 +1419,9 @@ * * NEEDSDOC ($objectName$) @return */ + @Override public String getInputEncoding() { - throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -1383,7 +1454,6 @@ */ public boolean getStandalone() { - throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -1418,9 +1488,9 @@ * * NEEDSDOC ($objectName$) @return */ + @Override public boolean getStrictErrorChecking() { - throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -1439,6 +1509,7 @@ * * NEEDSDOC @param strictErrorChecking */ + @Override public void setStrictErrorChecking(boolean strictErrorChecking) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); @@ -1457,7 +1528,6 @@ */ public String getVersion() { - throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } @@ -1482,10 +1552,12 @@ */ static class DTMNodeProxyImplementation implements DOMImplementation { + @Override public DocumentType createDocumentType(String qualifiedName,String publicId, String systemId) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } + @Override public Document createDocument(String namespaceURI,String qualfiedName,DocumentType doctype) { // Could create a DTM... but why, when it'd have to be permanantly empty? @@ -1500,6 +1572,7 @@ * methods we can't support. I'm not sure which would be more useful * to the caller. */ + @Override public boolean hasFeature(String feature,String version) { if( ("CORE".equals(feature.toUpperCase()) || "XML".equals(feature.toUpperCase())) @@ -1530,6 +1603,7 @@ * childNodes, etc. * @since DOM Level 3 */ + @Override public Object getFeature(String feature, String version) { // we don't have any alternate node, either this node does the job // or we don't have anything that does @@ -1542,6 +1616,7 @@ //RAMESH : Pending proper implementation of DOM Level 3 + @Override public Object setUserData(String key, Object data, UserDataHandler handler) { @@ -1557,6 +1632,7 @@ * on this node, or null if there was none. * @since DOM Level 3 */ + @Override public Object getUserData(String key) { return getOwnerDocument().getUserData( key); } @@ -1581,6 +1657,7 @@ * childNodes, etc. * @since DOM Level 3 */ + @Override public Object getFeature(String feature, String version) { // we don't have any alternate node, either this node does the job // or we don't have anything that does @@ -1629,6 +1706,7 @@ * true otherwise false. * @since DOM Level 3 */ + @Override public boolean isEqualNode(Node arg) { if (arg == this) { return true; @@ -1705,6 +1783,7 @@ * @return th URI for the namespace * @since DOM Level 3 */ + @Override public String lookupNamespaceURI(String specifiedPrefix) { short type = this.getNodeType(); switch (type) { @@ -1797,6 +1876,7 @@ * is the default namespace, false otherwise. * @since DOM Level 3 */ + @Override public boolean isDefaultNamespace(String namespaceURI){ /* // REVISIT: remove casts when DOM L3 becomes REC. @@ -1871,6 +1951,7 @@ * @param namespaceURI * @return the prefix for the namespace */ + @Override public String lookupPrefix(String namespaceURI){ // REVISIT: When Namespaces 1.1 comes out this may not be true @@ -1932,6 +2013,7 @@ * false otherwise. * @since DOM Level 3 */ + @Override public boolean isSameNode(Node other) { // we do not use any wrapper so the answer is obvious return this == other; @@ -1980,8 +2062,9 @@ * DOMSTRING_SIZE_ERR: Raised when it would return more characters than * fit in a DOMString variable on the implementation * platform. - * @since DOM Level 3 + * @since DOM Level 3 */ + @Override public void setTextContent(String textContent) throws DOMException { setNodeValue(textContent); @@ -2031,6 +2114,7 @@ * platform. * @since DOM Level 3 */ + @Override public String getTextContent() throws DOMException { return getNodeValue(); // overriden in some subclasses } @@ -2043,6 +2127,7 @@ * node. * @since DOM Level 3 */ + @Override public short compareDocumentPosition(Node other) throws DOMException { return 0; } @@ -2071,14 +2156,16 @@ * Yes. (F2F 26 Sep 2001) * @since DOM Level 3 */ + @Override public String getBaseURI() { return null; } - /** + /** * DOM Level 3 * Renaming node */ + @Override public Node renameNode(Node n, String namespaceURI, String name) @@ -2091,14 +2178,16 @@ * DOM Level 3 * Normalize document. */ + @Override public void normalizeDocument(){ } /** - * The configuration used when Document.normalizeDocument is + * The configuration used when Document.normalizeDocument is * invoked. * @since DOM Level 3 */ + @Override public DOMConfiguration getDomConfig(){ return null; } @@ -2110,8 +2199,8 @@ /** * DOM Level 3 */ + @Override public void setDocumentURI(String documentURI){ - fDocumentURI= documentURI; } @@ -2123,6 +2212,7 @@ * over this attribute. * @since DOM Level 3 */ + @Override public String getDocumentURI(){ return fDocumentURI; } @@ -2154,9 +2244,10 @@ actualEncoding = value; } - /** + /** * DOM Level 3 */ + @Override public Text replaceWholeText(String content) throws DOMException{ /* @@ -2210,6 +2301,7 @@ * nodes to this node, concatenated in document order. * @since DOM Level 3 */ + @Override public String getWholeText(){ /* @@ -2235,13 +2327,11 @@ * Returns whether this text node contains whitespace in element content, * often abusively called "ignorable whitespace". */ + @Override public boolean isElementContentWhitespace(){ return false; } - - - /** * NON-DOM: set the type of this attribute to be ID type. * @@ -2254,6 +2344,7 @@ /** * DOM Level 3: register the given attribute node as an ID attribute */ + @Override public void setIdAttribute(String name, boolean makeId) { //PENDING } @@ -2262,6 +2353,7 @@ /** * DOM Level 3: register the given attribute node as an ID attribute */ + @Override public void setIdAttributeNode(Attr at, boolean makeId) { //PENDING } @@ -2269,6 +2361,7 @@ /** * DOM Level 3: register the given attribute node as an ID attribute */ + @Override public void setIdAttributeNS(String namespaceURI, String localName, boolean makeId) { //PENDING @@ -2277,16 +2370,19 @@ * Method getSchemaTypeInfo. * @return TypeInfo */ + @Override public TypeInfo getSchemaTypeInfo(){ return null; //PENDING } + @Override public boolean isId() { return false; //PENDING } private String xmlEncoding; + @Override public String getXmlEncoding( ) { return xmlEncoding; } @@ -2295,23 +2391,25 @@ } private boolean xmlStandalone; + @Override public boolean getXmlStandalone() { return xmlStandalone; } + @Override public void setXmlStandalone(boolean xmlStandalone) throws DOMException { this.xmlStandalone = xmlStandalone; } private String xmlVersion; + @Override public String getXmlVersion() { return xmlVersion; } + @Override public void setXmlVersion(String xmlVersion) throws DOMException { this.xmlVersion = xmlVersion; } - - }