dtmdocumentimpl.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,655 行 · 第 1/5 页

JAVA
1,655
字号
                                                else                                                        break;                                        }                                } else if (!done) {                                        // Add wait logic here                                } else                                        break;                        } else {                                nodeHandle++;                        }                }                // Probably should throw error here like original instead of returning                return NULL;        }        /**         * Given a node handle, advance to the next node on the following axis.         *         * @param axisContextHandle the start of the axis that is being traversed.         * @param nodeHandle         * @return handle of next sibling,         * or DTM.NULL to indicate none exists.         */        public int getNextFollowing(int axisContextHandle, int nodeHandle) {                //###shs still working on                return NULL;        }        /**         * Given a node handle, advance to the next node on the preceding axis.         *         * @param axisContextHandle the start of the axis that is being traversed.         * @param nodeHandle the id of the node.         * @return int Node-number of preceding sibling,         * or DTM.NULL to indicate none exists.         */        public int getNextPreceding(int axisContextHandle, int nodeHandle) {                // ###shs copied from Xalan 1, what is this suppose to do?                nodeHandle &= NODEHANDLE_MASK;                while (nodeHandle > 1) {                        nodeHandle--;                        if (ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF))                                continue;                        // if nodeHandle is _not_ an ancestor of                        // axisContextHandle, specialFind will return it.                        // If it _is_ an ancestor, specialFind will return -1                        // %REVIEW% unconditional return defeats the                        // purpose of the while loop -- does this                        // logic make any sense?                        return (m_docHandle | nodes.specialFind(axisContextHandle, nodeHandle));                }                return NULL;        }        /**         * Given a node handle, find its parent node.         *         * @param nodeHandle the id of the node.         * @return int Node-number of parent,         * or DTM.NULL to indicate none exists.         */        public int getParent(int nodeHandle) {                // Should check to see within range?                // Document Root should not have to be handled differently                return (m_docHandle | nodes.readEntry(nodeHandle, 1));        }        /**         * Returns the root element of the document.         * @return nodeHandle to the Document Root.         */        public int getDocumentRoot() {                return (m_docHandle | m_docElement);        }        /**                * Given a node handle, find the owning document node.                *                * @param nodeHandle the id of the node.                * @return int Node handle of document, which should always be valid.                */        public int getDocument() {                return m_docHandle;        }        /**         * Given a node handle, find the owning document node.  This has the exact         * same semantics as the DOM Document method of the same name, in that if         * the nodeHandle is a document node, it will return NULL.         *         * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM         * binding layer. Included here as a convenience function and to         * aid porting of DOM code to DTM.</p>         *         * @param nodeHandle the id of the node.         * @return int Node handle of owning document, or NULL if the nodeHandle is         *             a document.         */        public int getOwnerDocument(int nodeHandle) {                // Assumption that Document Node is always in 0 slot                if ((nodeHandle & NODEHANDLE_MASK) == 0)                        return NULL;                return (nodeHandle & DOCHANDLE_MASK);        }        /**         * Given a node handle, find the owning document node.  This has the DTM         * semantics; a Document node is its own owner.         *         * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM         * binding layer. Included here as a convenience function and to         * aid porting of DOM code to DTM.</p>         *         * @param nodeHandle the id of the node.         * @return int Node handle of owning document, or NULL if the nodeHandle is         *             a document.         */        public int getDocumentRoot(int nodeHandle) {                // Assumption that Document Node is always in 0 slot                if ((nodeHandle & NODEHANDLE_MASK) == 0)                        return NULL;                return (nodeHandle & DOCHANDLE_MASK);        }        /**         * Get the string-value of a node as a String object         * (see http://www.w3.org/TR/xpath#data-model         * for the definition of a node's string-value).         *         * @param nodeHandle The node ID.         *         * @return A string object that represents the string-value of the given node.         */        public XMLString getStringValue(int nodeHandle) {        // ###zaj - researching        nodes.readSlot(nodeHandle, gotslot);        int nodetype=gotslot[0] & 0xFF;        String value=null;        switch (nodetype) {        case TEXT_NODE:        case COMMENT_NODE:        case CDATA_SECTION_NODE:                value= m_char.getString(gotslot[2], gotslot[3]);                break;        case PROCESSING_INSTRUCTION_NODE:        case ATTRIBUTE_NODE:        case ELEMENT_NODE:        case ENTITY_REFERENCE_NODE:        default:                break;        }        return m_xsf.newstr( value );        }        /**         * Get number of character array chunks in         * the string-value of a node.         * (see http://www.w3.org/TR/xpath#data-model         * for the definition of a node's string-value).         * Note that a single text node may have multiple text chunks.         *         * EXPLANATION: This method is an artifact of the fact that the         * underlying m_chars object may not store characters in a         * single contiguous array -- for example,the current         * FastStringBuffer may split a single node's text across         * multiple allocation units.  This call tells us how many         * separate accesses will be required to retrieve the entire         * content. PLEASE NOTE that this may not be the same as the         * number of SAX characters() events that caused the text node         * to be built in the first place, since m_chars buffering may         * be on different boundaries than the parser's buffers.         *         * @param nodeHandle The node ID.         *         * @return number of character array chunks in         *         the string-value of a node.         * */        //###zaj - tbd        public int getStringValueChunkCount(int nodeHandle)        {                //###zaj    return value                return 0;        }        /**         * Get a character array chunk in the string-value of a node.         * (see http://www.w3.org/TR/xpath#data-model         * for the definition of a node's string-value).         * Note that a single text node may have multiple text chunks.         *         * EXPLANATION: This method is an artifact of the fact that         * the underlying m_chars object may not store characters in a         * single contiguous array -- for example,the current         * FastStringBuffer may split a single node's text across         * multiple allocation units.  This call retrieves a single         * contiguous portion of the text -- as much as m-chars was         * able to store in a single allocation unit.  PLEASE NOTE         * that this may not be the same granularityas the SAX         * characters() events that caused the text node to be built         * in the first place, since m_chars buffering may be on         * different boundaries than the parser's buffers.         *         * @param nodeHandle The node ID.         * @param chunkIndex Which chunk to get.         * @param startAndLen An array of 2 where the start position and length of         *                    the chunk will be returned.         *         * @return The character array reference where the chunk occurs.  */        //###zaj - tbd        public char[] getStringValueChunk(int nodeHandle, int chunkIndex,                                                                                                                                                int[] startAndLen) {return new char[0];}        /**         * Given a node handle, return an ID that represents the node's expanded name.         *         * @param nodeHandle The handle to the node in question.         *         * @return the expanded-name id of the node.         */        public int getExpandedTypeID(int nodeHandle) {           nodes.readSlot(nodeHandle, gotslot);           String qName = m_localNames.indexToString(gotslot[3]);           // Remove prefix from qName           // %TBD% jjk This is assuming the elementName is the qName.           int colonpos = qName.indexOf(":");           String localName = qName.substring(colonpos+1);           // Get NS           String namespace = m_nsNames.indexToString(gotslot[0] << 16);           // Create expanded name           String expandedName = namespace + ":" + localName;           int expandedNameID = m_nsNames.stringToIndex(expandedName);        return expandedNameID;        }        /**         * Given an expanded name, return an ID.  If the expanded-name does not         * exist in the internal tables, the entry will be created, and the ID will         * be returned.  Any additional nodes that are created that have this         * expanded name will use this ID.         *         * @param nodeHandle The handle to the node in question.         *         * @return the expanded-name id of the node.         */        public int getExpandedTypeID(String namespace, String localName, int type) {           // Create expanded name          // %TBD% jjk Expanded name is bitfield-encoded as          // typeID[6]nsuriID[10]localID[16]. Switch to that form, and to          // accessing the ns/local via their tables rather than confusing          // nsnames and expandednames.           String expandedName = namespace + ":" + localName;           int expandedNameID = m_nsNames.stringToIndex(expandedName);           return expandedNameID;        }        /**         * Given an expanded-name ID, return the local name part.         *         * @param ExpandedNameID an ID that represents an expanded-name.         * @return String Local name of this node.         */        public String getLocalNameFromExpandedNameID(int ExpandedNameID) {           // Get expanded name           String expandedName = m_localNames.indexToString(ExpandedNameID);           // Remove prefix from expanded name           int colonpos = expandedName.indexOf(":");           String localName = expandedName.substring(colonpos+1);           return localName;        }        /**         * Given an expanded-name ID, return the namespace URI part.         *         * @param ExpandedNameID an ID that represents an expanded-name.         * @return String URI value of this node's namespace, or null if no         * namespace was resolved.        */        public String getNamespaceFromExpandedNameID(int ExpandedNameID) {           String expandedName = m_localNames.indexToString(ExpandedNameID);           // Remove local name from expanded name           int colonpos = expandedName.indexOf(":");           String nsName = expandedName.substring(0, colonpos);        return nsName;        }        /**         * fixednames        */        static final String[] fixednames=        {                null,null,							// nothing, Element                null,"#text",						// Attr, Text                "#cdata_section",null,	// CDATA, EntityReference                null,null,							// Entity, PI                "#comment","#document",	// Comment, Document                null,"#document-fragment", // Doctype, DocumentFragment                null};									// Notation        /**         * Given a node handle, return its DOM-style node name. This will         * include names such as #text or #document.         *         * @param nodeHandle the id of the node.         * @return String Name of this node, which may be an empty string.         * %REVIEW% Document when empty string is possible...         */        public String getNodeName(int nodeHandle) {                nodes.readSlot(nodeHandle, gotslot);                short type = (short) (gotslot[0] & 0xFFFF);                String name = fixednames[type];                if (null == name) {                  int i=gotslot[3];                  /**/System.out.println("got i="+i+" "+(i>>16)+"/"+(i&0xffff));                  name=m_localNames.indexToString(i & 0xFFFF);                  St

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?