com.sun.org.apache.xml.internal.dtm.DTMAxisIterator Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMAxisIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyIndex.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Return the node at the given position.
 *
 * @param position The position
 * @return The node at the given position.
 */
public int getNodeByPosition(int position) {
    int node = DTMAxisIterator.END;

    // If nodes are stored in _nodes, take advantage of the fact that
    // there are no duplicates and they are stored in document order.
    // Otherwise, fall back to the base heap implementation to do a
    // good job with this.
    if (_nodes != null) {
        if (position > 0) {
            if (position <= _nodes.cardinality()) {
                _position = position;
                node = _nodes.at(position-1);
            } else {
                _position = _nodes.cardinality();
            }
        }
    } else {
        node = super.getNodeByPosition(position);
    }

    return node;
}
 
Example #2
Source File: MultiDOM.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public DTMAxisIterator setStartNode(final int node) {
    if (node == DTM.NULL) {
        return this;
    }

    int dom = node >>> DTMManager.IDENT_DTM_NODE_BITS;

    // Get a new source first time and when mask changes
    if (_source == null || _dtmId != dom) {
        if (_type == NO_TYPE) {
            _source = _adapters[dom].getAxisIterator(_axis);
        } else if (_axis == Axis.CHILD) {
            _source = _adapters[dom].getTypedChildren(_type);
        } else {
            _source = _adapters[dom].getTypedAxisIterator(_axis, _type);
        }
    }

    _dtmId = dom;
    _source.setStartNode(node);
    return this;
}
 
Example #3
Source File: SAXImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: SimpleResultTreeImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DTMAxisIterator setStartNode(int nodeHandle)
{
    int nodeID = getNodeIdent(nodeHandle);
    _startNode = nodeID;

    // Increase the node ID by 1 if self is not included.
    if (!_includeSelf && nodeID != DTM.NULL) {
        if (_direction == DIRECTION_DOWN)
            nodeID++;
        else if (_direction == DIRECTION_UP)
            nodeID--;
    }

    _currentNode = nodeID;
    return this;
}
 
Example #5
Source File: MultiDOM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public NodeList makeNodeList(DTMAxisIterator iter) {
    int index = iter.next();
    if (index == DTM.NULL) {
        return new DTMAxisIterNodeList(null, null);
    }
    iter.reset();
    return _adapters[getDTMId(index)].makeNodeList(iter);
}
 
Example #6
Source File: BasisLibrary.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void copy(Object obj,
                        SerializationHandler handler,
                        int node,
                        DOM dom) {
    try {
        if (obj instanceof DTMAxisIterator)
  {
            DTMAxisIterator iter = (DTMAxisIterator) obj;
            dom.copy(iter.reset(), handler);
        }
        else if (obj instanceof Node) {
            dom.copy(((Node) obj).node, handler);
        }
        else if (obj instanceof DOM) {
            //((DOM)obj).copy(((com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase)((DOMAdapter)obj).getDOMImpl()).getDocument(), handler);
            DOM newDom = (DOM)obj;
            newDom.copy(newDom.getDocument(), handler);
        }
        else {
            String string = obj.toString();         // or call stringF()
            final int length = string.length();
            if (length > _characterArray.length)
                _characterArray = new char[length];
            string.getChars(0, length, _characterArray, 0);
            handler.characters(_characterArray, 0, length);
        }
    }
    catch (SAXException e) {
        runTimeError(RUN_TIME_COPY_ERR);
    }
}
 
Example #7
Source File: AbsoluteIterator.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public DTMAxisIterator cloneIterator() {
    try {
        final AbsoluteIterator clone = (AbsoluteIterator) super.clone();
        clone._source = _source.cloneIterator();    // resets source
        clone.resetPosition();
        clone._isRestartable = false;
        return clone;
    }
    catch (CloneNotSupportedException e) {
        BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
                                  e.toString());
        return null;
    }
}
 
Example #8
Source File: SimpleResultTreeImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL)
    {
        copy(node, handler);
    }
}
 
Example #9
Source File: MultiValuedNodeHeapIterator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator reset() {
    for (int i = 0; i < _free; i++) {
        _heap[i].reset();
        _heap[i].step();
    }

    // build heap
    for (int i = (_heapSize = _free)/2; i >= 0; i--) {
        heapify(i);
    }

    _returnedLast = END;
    return resetPosition();
}
 
Example #10
Source File: MatchingIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator cloneIterator() {

        try {
            final MatchingIterator clone = (MatchingIterator) super.clone();
            clone._source = _source.cloneIterator();
            clone._isRestartable = false;
            return clone.reset();
        }
        catch (CloneNotSupportedException e) {
            BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
                                      e.toString());
            return null;
        }
    }
 
Example #11
Source File: CurrentNodeListIterator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public CurrentNodeListIterator(DTMAxisIterator source, boolean docOrder,
                               CurrentNodeListFilter filter,
                               int currentNode,
                               AbstractTranslet translet)
{
    _source = source;
    _filter = filter;
    _translet = translet;
    _docOrder = docOrder;
    _currentNode = currentNode;
}
 
Example #12
Source File: AdaptiveResultTreeImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
{
    if (_dom != null) {
        return _dom.orderNodes(source, node);
    }
    else {
        return super.orderNodes(source, node);
    }
}
 
Example #13
Source File: AdaptiveResultTreeImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator getAxisIterator(final int axis)
{
    if (_dom != null) {
        return _dom.getAxisIterator(axis);
    }
    else {
        return super.getAxisIterator(axis);
    }
}
 
Example #14
Source File: SAXImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy a node-set to an output handler
 */
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        copy(node, handler);
    }
}
 
Example #15
Source File: AdaptiveResultTreeImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)
{
    if (_dom != null) {
        return _dom.getNthDescendant(node, n, includeself);
    }
    else {
        return super.getNthDescendant(node, n, includeself);
    }
}
 
Example #16
Source File: AdaptiveResultTreeImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator getChildren(final int node)
{
    if (_dom != null) {
        return _dom.getChildren(node);
    }
    else {
        return super.getChildren(node);
    }
}
 
Example #17
Source File: AdaptiveResultTreeImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    if (_dom != null) {
        _dom.copy(nodes, handler);
    }
    else {
        super.copy(nodes, handler);
    }
}
 
Example #18
Source File: MultiDOM.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator setStartNode(int node) {
    if (_isRestartable) {
        _source.setStartNode(_startNode = node);
        return resetPosition();
    }
    return this;
}
 
Example #19
Source File: SAXImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * This is a shortcut to the iterators that implement the
 * supported XPath axes (only namespace::) is not supported.
 * Returns a bare-bones iterator that must be initialized
 * with a start node (using iterator.setStartNode()).
 */
public DTMAxisIterator getAxisIterator(final int axis)
{
    switch (axis)
    {
        case Axis.SELF:
            return new SingletonIterator();
        case Axis.CHILD:
            return new ChildrenIterator();
        case Axis.PARENT:
            return new ParentIterator();
        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;
}
 
Example #20
Source File: MultiDOM.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
        throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
    }
}
 
Example #21
Source File: SAX2DTM2.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
    _currentNode = getTypedAttribute(node, _nodeType);
    return resetPosition();
  }

  return this;
}
 
Example #22
Source File: AdaptiveResultTreeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)
{
    if (_dom != null) {
        return _dom.getNthDescendant(node, n, includeself);
    }
    else {
        return super.getNthDescendant(node, n, includeself);
    }
}
 
Example #23
Source File: BasisLibrary.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * XSLT Standard function string(value)
 */
public static String stringF(Object obj, DOM dom) {
    if (obj instanceof DTMAxisIterator) {
        return dom.getStringValueX(((DTMAxisIterator)obj).reset().next());
    }
    else if (obj instanceof Node) {
        return dom.getStringValueX(((Node)obj).node);
    }
    else if (obj instanceof DOM) {
        return ((DOM)obj).getStringValue();
    }
    else {
        return obj.toString();
    }
}
 
Example #24
Source File: MultipleNodeCounter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public DefaultMultipleNodeCounter(Translet translet,
                                  DOM document,
                                  DTMAxisIterator iterator) {
    super(translet, document, iterator);
}
 
Example #25
Source File: ForwardPositionIterator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public DTMAxisIterator reset() {
    _source.reset();
    return resetPosition();
}
 
Example #26
Source File: AbsoluteIterator.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public DTMAxisIterator reset() {
    _source.reset();
    return resetPosition();
}
 
Example #27
Source File: SimpleResultTreeImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public DTMAxisIterator setStartNode(int nodeHandle)
{
    _currentNode = _startNode = getNodeIdent(nodeHandle);
    return this;
}
 
Example #28
Source File: CurrentNodeListIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public DTMAxisIterator forceNaturalOrder() {
    _docOrder = true;
    return this;
}
 
Example #29
Source File: MultipleNodeCounter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public MultipleNodeCounter(Translet translet,
                           DOM document, DTMAxisIterator iterator) {
    super(translet, document, iterator);
}
 
Example #30
Source File: SAXImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns an iterator with all children of a specific type
 * for a given node (element)
 */
public DTMAxisIterator getTypedChildren(final int type)
{
    return(new TypedChildrenIterator(type));
}