Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTMAxisIterator#END

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMAxisIterator#END . 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 openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Callers should not call next() after it returns END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public int next() {
    if (_nodes == null) return DTMAxisIterator.END;

    return (_position < _nodes.cardinality()) ?
        _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
}
 
Example 2
Source File: BasisLibrary.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: KeyIndex.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Advance to the next node represented by this {@link HeapNode}
 *
 * @return the next DTM node.
 */
public int step() {
    if (_position < _nodes.cardinality()) {
        _node = _nodes.at(_position);
        _position++;
    } else {
        _node = DTMAxisIterator.END;
    }

    return _node;
}
 
Example 4
Source File: BitArray.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the next set bit from a given position
 */
public final int getNextBit(int startBit) {
    for (int i = (startBit >>> 5) ; i<=_intSize; i++) {
        int bits = _bits[i];
        if (bits != 0) {
            for (int b = (startBit % 32); b<32; b++) {
                if ((bits & _masks[b]) != 0) {
                    return((i << 5) + b);
                }
            }
        }
        startBit = 0;
    }
    return(DTMAxisIterator.END);
}
 
Example 5
Source File: BasisLibrary.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/node-set compare.
 */
public static boolean compare(DTMAxisIterator left, DTMAxisIterator right,
                              int op, DOM dom) {
    int lnode;
    left.reset();

    while ((lnode = left.next()) != DTMAxisIterator.END) {
        final String lvalue = dom.getStringValueX(lnode);

        int rnode;
        right.reset();
        while ((rnode = right.next()) != DTMAxisIterator.END) {
            // String value must be the same if both nodes are the same
            if (lnode == rnode) {
                if (op == Operators.EQ) {
                    return true;
                } else if (op == Operators.NE) {
                    continue;
                }
            }
            if (compareStrings(lvalue, dom.getStringValueX(rnode), op,
                               dom)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 6
Source File: DTMAxisIteratorBase.java    From JDKSourceCode1.8 with MIT License 5 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)
{
  if (position > 0) {
    final int pos = isReverse() ? getLast() - position + 1
                                 : position;
    int node;
    while ((node = next()) != DTMAxisIterator.END) {
      if (pos == getPosition()) {
        return node;
      }
    }
  }
  return END;
}
 
Example 7
Source File: LoadDocument.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 2 arguments arg1 and arg2.  document(Obj, node-set) call
 */
public static DTMAxisIterator documentF(Object arg1, DTMAxisIterator arg2,
                        String xslURI, AbstractTranslet translet, DOM dom)
throws TransletException {
    String baseURI = null;
    final int arg2FirstNode = arg2.next();
    if (arg2FirstNode == DTMAxisIterator.END) {
        //  the second argument node-set is empty
        return EmptyIterator.getInstance();
    } else {
        //System.err.println("arg2FirstNode name: "
        //                   + dom.getNodeName(arg2FirstNode )+"["
        //                   +Integer.toHexString(arg2FirstNode )+"]");
        baseURI = dom.getDocumentURI(arg2FirstNode);
        if (!SystemIDResolver.isAbsoluteURI(baseURI))
           baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
    }

    try {
        if (arg1 instanceof String) {
            if (((String)arg1).length() == 0) {
                return document(xslURI, "", translet, dom);
            } else {
                return document((String)arg1, baseURI, translet, dom);
            }
        } else if (arg1 instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg1, baseURI, translet, dom);
        } else {
            final String err = "document("+arg1.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example 8
Source File: KeyIndex.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Callers should not call next() after it returns END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public int next() {
    if (_nodes == null) return DTMAxisIterator.END;

    return (_position < _nodes.cardinality()) ?
        _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
}
 
Example 9
Source File: KeyIndex.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Callers should not call next() after it returns END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public int next() {
    if (_nodes == null) return DTMAxisIterator.END;

    return (_position < _nodes.cardinality()) ?
        _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
}
 
Example 10
Source File: KeyIndex.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Set start to END should 'close' the iterator,
 * i.e. subsequent call to next() should return END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public DTMAxisIterator setStartNode(int start) {
    if (start == DTMAxisIterator.END) {
        _nodes = null;
    }
    else if (_nodes != null) {
        _position = 0;
    }
    return (DTMAxisIterator) this;
}
 
Example 11
Source File: DTMAxisIterNodeList.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The number of nodes in the list. The range of valid child node indices
 * is 0 to <code>length-1</code> inclusive.
 */
public int getLength() {
    if (m_last == -1) {
        int node;
        while ((node = m_iter.next()) != DTMAxisIterator.END) {
            m_cachedNodes.addElement(node);
        }
        m_last = m_cachedNodes.size();
    }
    return m_last;
}
 
Example 12
Source File: KeyIndex.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Advance to the next node represented by this {@link HeapNode}
 *
 * @return the next DTM node.
 */
public int step() {
    if (_position < _nodes.cardinality()) {
        _node = _nodes.at(_position);
        _position++;
    } else {
        _node = DTMAxisIterator.END;
    }

    return _node;
}
 
Example 13
Source File: BasisLibrary.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 14
Source File: KeyIndex.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Set start to END should 'close' the iterator,
 * i.e. subsequent call to next() should return END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public DTMAxisIterator setStartNode(int start) {
    if (start == DTMAxisIterator.END) {
        _nodes = null;
    }
    else if (_nodes != null) {
        _position = 0;
    }
    return (DTMAxisIterator) this;
}
 
Example 15
Source File: KeyIndex.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Callers should not call next() after it returns END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public int next() {
    if (_nodes == null) return DTMAxisIterator.END;

    return (_position < _nodes.cardinality()) ?
        _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
}
 
Example 16
Source File: KeyIndex.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Set start to END should 'close' the iterator,
 * i.e. subsequent call to next() should return END.</p>
 * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is
 * <b>deprecated.</b></em></p>
 * @deprecated
 */
public DTMAxisIterator setStartNode(int start) {
    if (start == DTMAxisIterator.END) {
        _nodes = null;
    }
    else if (_nodes != null) {
        _position = 0;
    }
    return (DTMAxisIterator) this;
}
 
Example 17
Source File: BasisLibrary.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/node-set compare.
 */
public static boolean compare(DTMAxisIterator left, DTMAxisIterator right,
                              int op, DOM dom) {
    int lnode;
    left.reset();

    while ((lnode = left.next()) != DTMAxisIterator.END) {
        final String lvalue = dom.getStringValueX(lnode);

        int rnode;
        right.reset();
        while ((rnode = right.next()) != DTMAxisIterator.END) {
            // String value must be the same if both nodes are the same
            if (lnode == rnode) {
                if (op == Operators.EQ) {
                    return true;
                } else if (op == Operators.NE) {
                    continue;
                }
            }
            if (compareStrings(lvalue, dom.getStringValueX(rnode), op,
                               dom)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 18
Source File: KeyIndex.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Evaluate the reference to the <code>key</code> or <code>id</code>
 * function with the context specified by {@link #setStartNode(int)}
 * and set up this iterator to iterate over the DTM nodes that are
 * to be returned.
 */
protected void init() {
    super.init();
    _position = 0;

    // All nodes retrieved are in the same document
    int rootHandle = _dom.getAxisIterator(Axis.ROOT)
                              .setStartNode(_startNode).next();

    // Is the argument not a node set?
    if (_keyValueIterator == null) {
        // Look up nodes returned for the single string argument
        _nodes = lookupNodes(rootHandle, _keyValue);

        if (_nodes == null) {
            _nodes = EMPTY_NODES;
        }
    } else {
        DTMAxisIterator keyValues = _keyValueIterator.reset();
        int retrievedKeyValueIdx = 0;
        boolean foundNodes = false;

        _nodes = null;

        // For each node in the node set argument, get the string value
        // and look up the nodes returned by key or id for that string
        // value.  If at most one string value has nodes associated,
        // the nodes will be stored in _nodes; otherwise, the nodes
        // will be placed in a heap.
        for (int keyValueNode = keyValues.next();
             keyValueNode != DTMAxisIterator.END;
             keyValueNode = keyValues.next()) {

            String keyValue = BasisLibrary.stringF(keyValueNode, _dom);

            IntegerArray nodes = lookupNodes(rootHandle, keyValue);

            if (nodes != null) {
                if (!foundNodes) {
                    _nodes = nodes;
                    foundNodes = true;
                } else {
                    if (_nodes != null) {
                        addHeapNode(new KeyIndexHeapNode(_nodes));
                        _nodes = null;
                    }
                    addHeapNode(new KeyIndexHeapNode(nodes));
                }
            }
        }

        if (!foundNodes) {
            _nodes = EMPTY_NODES;
        }
    }
}
 
Example 19
Source File: SingletonIterator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public int next() {
    final int result = _node;
    _node = DTMAxisIterator.END;
    return returnNode(result);
}
 
Example 20
Source File: SingletonIterator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public int next() {
    final int result = _node;
    _node = DTMAxisIterator.END;
    return returnNode(result);
}