com.sun.org.apache.xml.internal.utils.NodeVector

Here are the examples of the java api class com.sun.org.apache.xml.internal.utils.NodeVector taken from open source projects.

1. NodeSequence#getVector()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * If this iterator needs to cache nodes that are fetched, they
   * are stored in the Vector in the generic object.
   */
protected NodeVector getVector() {
    NodeVector nv = (m_cache != null) ? m_cache.getVector() : null;
    return nv;
}

2. NodeSequence#hasCache()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * If the iterator needs to cache nodes as they are fetched,
   * then this method returns true.
   */
public boolean hasCache() {
    final NodeVector nv = getVector();
    return (nv != null);
}

3. NodeSequence#markCacheComplete()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * If this NodeSequence has a cache, mark that it is complete.
   * This method should be called after the iterator is exhausted.
   */
private void markCacheComplete() {
    NodeVector nv = getVector();
    if (nv != null) {
        m_cache.setCacheComplete(true);
    }
}

4. NodeSequence#nextNode()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * @see DTMIterator#nextNode()
   */
public int nextNode() {
    // If the cache is on, and the node has already been found, then
    // just return from the list.
    NodeVector vec = getVector();
    if (null != vec) {
        // There is a cache
        if (m_next < vec.size()) {
            // The node is in the cache, so just return it.
            int next = vec.elementAt(m_next);
            m_next++;
            return next;
        } else if (cacheComplete() || (-1 != m_last) || (null == m_iter)) {
            m_next++;
            return DTM.NULL;
        }
    }
    if (null == m_iter)
        return DTM.NULL;
    int next = m_iter.nextNode();
    if (DTM.NULL != next) {
        if (hasCache()) {
            if (m_iter.isDocOrdered()) {
                getVector().addElement(next);
                m_next++;
            } else {
                int insertIndex = addNodeInDocOrder(next);
                if (insertIndex >= 0)
                    m_next++;
            }
        } else
            m_next++;
    } else {
        // We have exhausted the iterator, and if there is a cache
        // it must have all nodes in it by now, so let the cache
        // know that it is complete.
        markCacheComplete();
        m_last = m_next;
        m_next++;
    }
    return next;
}

5. NodeSequence#setItem()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * @see DTMIterator#setItem(int, int)
   */
public void setItem(int node, int index) {
    NodeVector vec = getVector();
    if (null != vec) {
        int oldNode = vec.elementAt(index);
        if (oldNode != node && m_cache.useCount() > 1) {
            /* If we are going to set the node at the given index
             * to a different value, and the cache is shared
             * (has a use count greater than 1)
             * then make a copy of the cache and use it
             * so we don't overwrite the value for other
             * users of the cache.
             */
            IteratorCache newCache = new IteratorCache();
            final NodeVector nv;
            try {
                nv = (NodeVector) vec.clone();
            } catch (CloneNotSupportedException e) {
                e.printStackTrace();
                RuntimeException rte = new RuntimeException(e.getMessage());
                throw rte;
            }
            newCache.setVector(nv);
            newCache.setCacheComplete(true);
            m_cache = newCache;
            vec = nv;
            // Keep our superclass informed of the current NodeVector
            super.setObject(nv);
        /* When we get to here the new cache has
             * a use count of 1 and when setting a
             * bunch of values on the same NodeSequence,
             * such as when sorting, we will keep setting
             * values in that same copy which has a use count of 1.
             */
        }
        vec.setElementAt(node, index);
        m_last = vec.size();
    } else
        m_iter.setItem(node, index);
}

6. NodeSequence#addNodeInDocOrder()

Project: openjdk
Source File: NodeSequence.java
View license
/**
   * Add the node into a vector of nodes where it should occur in
   * document order.
   * @param node The node to be added.
   * @return insertIndex.
   * @throws RuntimeException thrown if this NodeSetDTM is not of
   * a mutable type.
   */
protected int addNodeInDocOrder(int node) {
    assertion(hasCache(), "addNodeInDocOrder must be done on a mutable sequence!");
    int insertIndex = -1;
    NodeVector vec = getVector();
    // This needs to do a binary search, but a binary search
    // is somewhat tough because the sequence test involves
    // two nodes.
    int size = vec.size(), i;
    for (i = size - 1; i >= 0; i--) {
        int child = vec.elementAt(i);
        if (child == node) {
            // Duplicate, suppress insert
            i = -2;
            break;
        }
        DTM dtm = m_dtmMgr.getDTM(node);
        if (!dtm.isNodeAfter(node, child)) {
            break;
        }
    }
    if (i != -2) {
        insertIndex = i + 1;
        vec.insertElementAt(node, insertIndex);
    }
    // checkDups();
    return insertIndex;
}