⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saximpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            case Axis.ANCESTOR:                return new AncestorIterator();            case Axis.ANCESTORORSELF:                return (new AncestorIterator()).includeSelf();            case Axis.ATTRIBUTE:                return new AttributeIterator();            case Axis.DESCENDANT:                return new DescendantIterator();            case Axis.DESCENDANTORSELF:                return (new DescendantIterator()).includeSelf();            case Axis.FOLLOWING:                return new FollowingIterator();            case Axis.PRECEDING:                return new PrecedingIterator();            case Axis.FOLLOWINGSIBLING:                return new FollowingSiblingIterator();            case Axis.PRECEDINGSIBLING:                return new PrecedingSiblingIterator();            case Axis.NAMESPACE:                return new NamespaceIterator();            case Axis.ROOT:                return new RootIterator();            default:                BasisLibrary.runTimeError(BasisLibrary.AXIS_SUPPORT_ERR,                         Axis.getNames(axis));        }        return null;    }    /**     * Similar to getAxisIterator, but this one returns an iterator     * containing nodes of a typed axis (ex.: child::foo)     */    public DTMAxisIterator getTypedAxisIterator(int axis, int type)    {        // Most common case handled first        if (axis == Axis.CHILD) {            return new TypedChildrenIterator(type);        }        if (type == NO_TYPE) {            return(EMPTYITERATOR);        }        switch (axis)        {            case Axis.SELF:                return new TypedSingletonIterator(type);            case Axis.CHILD:                return new TypedChildrenIterator(type);            case Axis.PARENT:                return new ParentIterator().setNodeType(type);            case Axis.ANCESTOR:                return new TypedAncestorIterator(type);            case Axis.ANCESTORORSELF:                return (new TypedAncestorIterator(type)).includeSelf();            case Axis.ATTRIBUTE:                return new TypedAttributeIterator(type);            case Axis.DESCENDANT:                return new TypedDescendantIterator(type);            case Axis.DESCENDANTORSELF:                return (new TypedDescendantIterator(type)).includeSelf();            case Axis.FOLLOWING:                return new TypedFollowingIterator(type);            case Axis.PRECEDING:                return new TypedPrecedingIterator(type);            case Axis.FOLLOWINGSIBLING:                return new TypedFollowingSiblingIterator(type);            case Axis.PRECEDINGSIBLING:                return new TypedPrecedingSiblingIterator(type);            case Axis.NAMESPACE:                return  new TypedNamespaceIterator(type);            case Axis.ROOT:                return new TypedRootIterator(type);            default:                BasisLibrary.runTimeError(BasisLibrary.TYPED_AXIS_SUPPORT_ERR,                         Axis.getNames(axis));        }        return null;    }    /**     * Do not think that this returns an iterator for the namespace axis.     * It returns an iterator with nodes that belong in a certain namespace,     * such as with <xsl:apply-templates select="blob/foo:*"/>     * The 'axis' specifies the axis for the base iterator from which the     * nodes are taken, while 'ns' specifies the namespace URI type.     */    public DTMAxisIterator getNamespaceAxisIterator(int axis, int ns)    {        DTMAxisIterator iterator = null;        if (ns == NO_TYPE) {            return EMPTYITERATOR;        }        else {            switch (axis) {                case Axis.CHILD:                    return new NamespaceChildrenIterator(ns);                case Axis.ATTRIBUTE:                    return new NamespaceAttributeIterator(ns);                default:                    return new NamespaceWildcardIterator(axis, ns);            }        }    }    /**     * Iterator that handles node tests that test for a namespace, but have     * a wild card for the local name of the node, i.e., node tests of the     * form <axis>::<prefix>:*     */    public final class NamespaceWildcardIterator        extends InternalAxisIteratorBase    {        /**         * The namespace type index.         */        protected int m_nsType;        /**         * A nested typed axis iterator that retrieves nodes of the principal         * node kind for that axis.         */        protected DTMAxisIterator m_baseIterator;        /**         * Constructor NamespaceWildcard         *         * @param axis The axis that this iterator will traverse         * @param nsType The namespace type index         */        public NamespaceWildcardIterator(int axis, int nsType) {            m_nsType = nsType;            // Create a nested iterator that will select nodes of            // the principal node kind for the selected axis.            switch (axis) {                case Axis.ATTRIBUTE: {                    // For "attribute::p:*", the principal node kind is                    // attribute                    m_baseIterator = getAxisIterator(axis);                }                case Axis.NAMESPACE: {                    // This covers "namespace::p:*".  It is syntactically                    // correct, though it doesn't make much sense.                    m_baseIterator = getAxisIterator(axis);                }                default: {                    // In all other cases, the principal node kind is                    // element                    m_baseIterator = getTypedAxisIterator(axis,                                                          DTM.ELEMENT_NODE);                }            }        }        /**         * Set start to END should 'close' the iterator,         * i.e. subsequent call to next() should return END.         *         * @param node Sets the root of the iteration.         *         * @return A DTMAxisIterator set to the start of the iteration.         */        public DTMAxisIterator setStartNode(int node) {            if (_isRestartable) {                _startNode = node;                m_baseIterator.setStartNode(node);                resetPosition();            }            return this;        }        /**         * Get the next node in the iteration.         *         * @return The next node handle in the iteration, or END.         */        public int next() {            int node;            while ((node = m_baseIterator.next()) != END) {                // Return only nodes that are in the selected namespace                if (getNSType(node) == m_nsType) {                    return returnNode(node);                }            }            return END;        }        /**         * Returns a deep copy of this iterator.  The cloned iterator is not         * reset.         *         * @return a deep copy of this iterator.         */        public DTMAxisIterator cloneIterator() {            try {                DTMAxisIterator nestedClone = m_baseIterator.cloneIterator();                NamespaceWildcardIterator clone =                    (NamespaceWildcardIterator) super.clone();                clone.m_baseIterator = nestedClone;                clone.m_nsType = m_nsType;                clone._isRestartable = false;                return clone;            } catch (CloneNotSupportedException e) {                BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,                                          e.toString());                return null;            }        }        /**         * True if this iterator has a reversed axis.         *         * @return <code>true</code> if this iterator is a reversed axis.         */        public boolean isReverse() {            return m_baseIterator.isReverse();        }        public void setMark() {            m_baseIterator.setMark();        }        public void gotoMark() {            m_baseIterator.gotoMark();        }    }    /**     * Iterator that returns children within a given namespace for a     * given node. The functionality chould be achieved by putting a     * filter on top of a basic child iterator, but a specialised     * iterator is used for efficiency (both speed and size of translet).     */    public final class NamespaceChildrenIterator        extends InternalAxisIteratorBase    {        /** The extended type ID being requested. */        private final int _nsType;        /**         * Constructor NamespaceChildrenIterator         *         *         * @param type The extended type ID being requested.         */        public NamespaceChildrenIterator(final int type) {            _nsType = type;        }        /**         * Set start to END should 'close' the iterator,         * i.e. subsequent call to next() should return END.         *         * @param node Sets the root of the iteration.         *         * @return A DTMAxisIterator set to the start of the iteration.         */        public DTMAxisIterator setStartNode(int node) {            //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily            if (node == DTMDefaultBase.ROOTNODE) {                node = getDocument();            }            if (_isRestartable) {                _startNode = node;                _currentNode = (node == DTM.NULL) ? DTM.NULL : NOTPROCESSED;                return resetPosition();            }            return this;        }        /**         * Get the next node in the iteration.         *         * @return The next node handle in the iteration, or END.         */        public int next() {            if (_currentNode != DTM.NULL) {                for (int node = (NOTPROCESSED == _currentNode)                                     ? _firstch(makeNodeIdentity(_startNode))                                     : _nextsib(_currentNode);                     node != END;                     node = _nextsib(node)) {                    int nodeHandle = makeNodeHandle(node);                    if (getNSType(nodeHandle) == _nsType) {                        _currentNode = node;                        return returnNode(nodeHandle);                    }                }            }            return END;        }    }  // end of NamespaceChildrenIterator    /**     * Iterator that returns attributes within a given namespace for a node.     */    public final class NamespaceAttributeIterator            extends InternalAxisIteratorBase    {        /** The extended type ID being requested. */        private final int _nsType;        /**         * Constructor NamespaceAttributeIterator         *         *         * @param nsType The extended type ID being requested.         */        public NamespaceAttributeIterator(int nsType) {            super();            _nsType = nsType;        }        /**         * Set start to END should 'close' the iterator,         * i.e. subsequent call to next() should return END.         *         * @param node Sets the root of the iteration.         *         * @return A DTMAxisIterator set to the start of the iteration.         */        public DTMAxisIterator setStartNode(int node) {            //%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily            if (node == DTMDefaultBase.ROOTNODE) {                node = getDocument();            }            if (_isRestartable) {                int nsType = _nsType;                _startNode = node;                for (node = getFirstAttribute(node);                     node != END;                     node = getNextAttribute(node)) {                    if (getNSType(node) == nsType) {                        break;                    }                }                _currentNode = node;                return resetPosition();            }            return this;        }        /**         * Get the next node in the iteration.         *         * @return The next node handle in the iteration, or END.         */        public int next() {            int node = _currentNode;            int nsType = _nsType;            int nextNode;            if (node == END) {                return END;            }            for (nextNode = getNextAttribute(node);                 nextNode != END;                 nextNode = getNextAttribute(nextNode)) {

⌨️ 快捷键说明

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