dtmnodeproxy.java
来自「JAVA 所有包」· Java 代码 · 共 2,314 行 · 第 1/5 页
JAVA
2,314 行
} /** * * * @see org.w3c.dom.Node */ public final Document getOwnerDocument() { // Note that this uses the DOM-compatable version of the call return (Document)(dtm.getNode(dtm.getOwnerDocument(node))); } /** * * @param newChild * @param refChild * * * * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ public final Node insertBefore(Node newChild, Node refChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); } /** * * @param newChild * @param oldChild * * * * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ public final Node replaceChild(Node newChild, Node oldChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); } /** * * @param oldChild * * * * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ public final Node removeChild(Node oldChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); } /** * * @param newChild * * * * @throws DOMException * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ public final Node appendChild(Node newChild) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); } /** * * * @see org.w3c.dom.Node */ public final boolean hasChildNodes() { return (DTM.NULL != dtm.getFirstChild(node)); } /** * * @param deep * * * @see org.w3c.dom.Node -- DTMNodeProxy is read-only */ public final Node cloneNode(boolean deep) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * * @see org.w3c.dom.Document */ public final DocumentType getDoctype() { return null; } /** * * * @see org.w3c.dom.Document */ public final DOMImplementation getImplementation() { return implementation; } /** This is a bit of a problem in DTM, since a DTM may be a Document * Fragment and hence not have a clear-cut Document Element. We can * make it work in the well-formed cases but would that be confusing for others? * * * @see org.w3c.dom.Document */ public final Element getDocumentElement() { int dochandle=dtm.getDocument(); int elementhandle=DTM.NULL; for(int kidhandle=dtm.getFirstChild(dochandle); kidhandle!=DTM.NULL; kidhandle=dtm.getNextSibling(kidhandle)) { switch(dtm.getNodeType(kidhandle)) { case Node.ELEMENT_NODE: if(elementhandle!=DTM.NULL) { elementhandle=DTM.NULL; // More than one; ill-formed. kidhandle=dtm.getLastChild(dochandle); // End loop } else elementhandle=kidhandle; break; // These are harmless; document is still wellformed case Node.COMMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.DOCUMENT_TYPE_NODE: break; default: elementhandle=DTM.NULL; // ill-formed kidhandle=dtm.getLastChild(dochandle); // End loop break; } } if(elementhandle==DTM.NULL) throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); else return (Element)(dtm.getNode(elementhandle)); } /** * * @param tagName * * * * @throws DOMException * @see org.w3c.dom.Document */ public final Element createElement(String tagName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * * @see org.w3c.dom.Document */ public final DocumentFragment createDocumentFragment() { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param data * * * @see org.w3c.dom.Document */ public final Text createTextNode(String data) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param data * * * @see org.w3c.dom.Document */ public final Comment createComment(String data) { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param data * * * * @throws DOMException * @see org.w3c.dom.Document */ public final CDATASection createCDATASection(String data) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param target * @param data * * * * @throws DOMException * @see org.w3c.dom.Document */ public final ProcessingInstruction createProcessingInstruction( String target, String data) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param name * * * * @throws DOMException * @see org.w3c.dom.Document */ public final Attr createAttribute(String name) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param name * * * * @throws DOMException * @see org.w3c.dom.Document */ public final EntityReference createEntityReference(String name) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param tagname * * * @see org.w3c.dom.Document */ public final NodeList getElementsByTagName(String tagname) { Vector listVector = new Vector(); Node retNode = dtm.getNode(node); if (retNode != null) { boolean isTagNameWildCard = "*".equals(tagname); if (DTM.ELEMENT_NODE == retNode.getNodeType()) { NodeList nodeList = retNode.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { traverseChildren(listVector, nodeList.item(i), tagname, isTagNameWildCard); } } else if (DTM.DOCUMENT_NODE == retNode.getNodeType()) { traverseChildren(listVector, dtm.getNode(node), tagname, isTagNameWildCard); } } int size = listVector.size(); NodeSet nodeSet = new NodeSet(size); for (int i = 0; i < size; i++) { nodeSet.addNode((Node) listVector.elementAt(i)); } return (NodeList) nodeSet; } /** * * @param listVector * @param tempNode * @param tagname * @param isTagNameWildCard * * * Private method to be used for recursive iterations to obtain elements by tag name. */ private final void traverseChildren ( Vector listVector, Node tempNode, String tagname, boolean isTagNameWildCard) { if (tempNode == null) { return; } else { if (tempNode.getNodeType() == DTM.ELEMENT_NODE && (isTagNameWildCard || tempNode.getNodeName().equals(tagname))) { listVector.add(tempNode); } if(tempNode.hasChildNodes()) { NodeList nodeList = tempNode.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { traverseChildren(listVector, nodeList.item(i), tagname, isTagNameWildCard); } } } } /** * * @param importedNode * @param deep * * * * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only */ public final Node importNode(Node importedNode, boolean deep) throws DOMException { throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); } /** * * @param namespaceURI * @param qualifiedName * * * * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 */ public final Element createElementNS( String namespaceURI, String qualifiedName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param namespaceURI * @param qualifiedName * * * * @throws DOMException * @see org.w3c.dom.Document as of DOM Level 2 */ public final Attr createAttributeNS( String namespaceURI, String qualifiedName) throws DOMException { throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); } /** * * @param namespaceURI * @param localName * * * @see org.w3c.dom.Document as of DOM Level 2 */ public final NodeList getElementsByTagNameNS(String namespaceURI, String localName) { Vector listVector = new Vector(); Node retNode = dtm.getNode(node); if (retNode != null) { boolean isNamespaceURIWildCard = "*".equals(namespaceURI); boolean isLocalNameWildCard = "*".equals(localName); if (DTM.ELEMENT_NODE == retNode.getNodeType()) { NodeList nodeList = retNode.getChildNodes(); for(int i = 0; i < nodeList.getLength(); i++) { traverseChildren(listVector, nodeList.item(i), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard); } } else if(DTM.DOCUMENT_NODE == retNode.getNodeType()) { traverseChildren(listVector, dtm.getNode(node), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard); } } int size = listVector.size(); NodeSet nodeSet = new NodeSet(size); for (int i = 0; i < size; i++) { nodeSet.addNode((Node)listVector.elementAt(i)); } return (NodeList) nodeSet; } /** * * @param listVector * @param tempNode * @param namespaceURI * @param localname * @param isNamespaceURIWildCard * @param isLocalNameWildCard * * Private method to be used for recursive iterations to obtain elements by tag name * and namespaceURI. */ private final void traverseChildren ( Vector listVector, Node tempNode, String namespaceURI, String localname, boolean isNamespaceURIWildCard, boolean isLocalNameWildCard) { if (tempNode == null) { return; } else { if (tempNode.getNodeType() == DTM.ELEMENT_NODE && (isLocalNameWildCard || tempNode.getLocalName().equals(localname))) { String nsURI = tempNode.getNamespaceURI(); if ((namespaceURI == null && nsURI == null)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?