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

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

1. DTMDefaultBase#declareNamespaceInContext()

Project: openjdk
Source File: DTMDefaultBase.java
View license
/** Build table of namespace declaration
   * locations during DTM construction. Table is a Vector of
   * SuballocatedIntVectors containing the namespace node HANDLES declared at
   * that ID, plus an SuballocatedIntVector of the element node INDEXES at which
   * these declarations appeared.
   *
   * NOTE: Since this occurs during model build, nodes will be encountered
   * in doucment order and thus the table will be ordered by element,
   * permitting binary-search as a possible retrieval optimization.
   *
   * %REVIEW% Directly managed arrays rather than vectors?
   * %REVIEW% Handles or IDs? Given usage, I think handles.
   * */
protected void declareNamespaceInContext(int elementNodeIndex, int namespaceNodeIndex) {
    SuballocatedIntVector nsList = null;
    if (m_namespaceDeclSets == null) {
        // First
        m_namespaceDeclSetElements = new SuballocatedIntVector(32);
        m_namespaceDeclSetElements.addElement(elementNodeIndex);
        m_namespaceDeclSets = new Vector();
        nsList = new SuballocatedIntVector(32);
        m_namespaceDeclSets.addElement(nsList);
    } else {
        // Most recent. May be -1 (none) if DTM was pruned.
        // %OPT% Is there a lastElement() method? Should there be?
        int last = m_namespaceDeclSetElements.size() - 1;
        if (last >= 0 && elementNodeIndex == m_namespaceDeclSetElements.elementAt(last)) {
            nsList = (SuballocatedIntVector) m_namespaceDeclSets.elementAt(last);
        }
    }
    if (nsList == null) {
        m_namespaceDeclSetElements.addElement(elementNodeIndex);
        SuballocatedIntVector inherited = findNamespaceContext(_parent(elementNodeIndex));
        if (inherited != null) {
            // %OPT% Count-down might be faster, but debuggability may
            // be better this way, and if we ever decide we want to
            // keep this ordered by expanded-type...
            int isize = inherited.size();
            // Base the size of a new namespace list on the
            // size of the inherited list - but within reason!
            nsList = new SuballocatedIntVector(Math.max(Math.min(isize + 16, 2048), 32));
            for (int i = 0; i < isize; ++i) {
                nsList.addElement(inherited.elementAt(i));
            }
        } else {
            nsList = new SuballocatedIntVector(32);
        }
        m_namespaceDeclSets.addElement(nsList);
    }
    // Handle overwriting inherited.
    // %OPT% Keep sorted? (By expanded-name rather than by doc order...)
    // Downside: Would require insertElementAt if not found,
    // which has recopying costs. But these are generally short lists...
    int newEType = _exptype(namespaceNodeIndex);
    for (int i = nsList.size() - 1; i >= 0; --i) {
        if (newEType == getExpandedTypeID(nsList.elementAt(i))) {
            nsList.setElementAt(makeNodeHandle(namespaceNodeIndex), i);
            return;
        }
    }
    nsList.addElement(makeNodeHandle(namespaceNodeIndex));
}

2. MultiDOM#addDOMAdapter()

Project: openjdk
Source File: MultiDOM.java
View license
private int addDOMAdapter(DOMAdapter adapter, boolean indexByURI) {
    // Add the DOM adapter to the array of DOMs
    DOM dom = adapter.getDOMImpl();
    int domNo = 1;
    int dtmSize = 1;
    SuballocatedIntVector dtmIds = null;
    if (dom instanceof DTMDefaultBase) {
        DTMDefaultBase dtmdb = (DTMDefaultBase) dom;
        dtmIds = dtmdb.getDTMIDs();
        dtmSize = dtmIds.size();
        domNo = dtmIds.elementAt(dtmSize - 1) >>> DTMManager.IDENT_DTM_NODE_BITS;
    } else if (dom instanceof SimpleResultTreeImpl) {
        SimpleResultTreeImpl simpleRTF = (SimpleResultTreeImpl) dom;
        domNo = simpleRTF.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
    }
    if (domNo >= _size) {
        int oldSize = _size;
        do {
            _size *= 2;
        } while (_size <= domNo);
        final DOMAdapter[] newArray = new DOMAdapter[_size];
        System.arraycopy(_adapters, 0, newArray, 0, oldSize);
        _adapters = newArray;
    }
    _free = domNo + 1;
    if (dtmSize == 1) {
        _adapters[domNo] = adapter;
    } else if (dtmIds != null) {
        int domPos = 0;
        for (int i = dtmSize - 1; i >= 0; i--) {
            domPos = dtmIds.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS;
            _adapters[domPos] = adapter;
        }
        domNo = domPos;
    }
    // Store reference to document (URI) in the Map
    if (indexByURI) {
        String uri = adapter.getDocumentURI(0);
        _documents.put(uri, domNo);
    }
    // add the DOMAdapter to the list.
    if (dom instanceof AdaptiveResultTreeImpl) {
        AdaptiveResultTreeImpl adaptiveRTF = (AdaptiveResultTreeImpl) dom;
        DOM nestedDom = adaptiveRTF.getNestedDOM();
        if (nestedDom != null) {
            DOMAdapter newAdapter = new DOMAdapter(nestedDom, adapter.getNamesArray(), adapter.getUrisArray(), adapter.getTypesArray(), adapter.getNamespaceArray());
            addDOMAdapter(newAdapter);
        }
    }
    return domNo;
}

3. SAX2DTM2#copyNS()

Project: openjdk
Source File: SAX2DTM2.java
View license
/**
     * Copy  namespace nodes.
     *
     * @param nodeID The Element node identity
     * @param handler The SerializationHandler
     * @param inScope  true if all namespaces in scope should be copied,
     *  false if only the namespace declarations should be copied.
     */
protected final void copyNS(final int nodeID, SerializationHandler handler, boolean inScope) throws SAXException {
    // doing anything.
    if (m_namespaceDeclSetElements != null && m_namespaceDeclSetElements.size() == 1 && m_namespaceDeclSets != null && ((SuballocatedIntVector) m_namespaceDeclSets.elementAt(0)).size() == 1)
        return;
    SuballocatedIntVector nsContext = null;
    int nextNSNode;
    // Find the first namespace node
    if (inScope) {
        nsContext = findNamespaceContext(nodeID);
        if (nsContext == null || nsContext.size() < 1)
            return;
        else
            nextNSNode = makeNodeIdentity(nsContext.elementAt(0));
    } else
        nextNSNode = getNextNamespaceNode2(nodeID);
    int nsIndex = 1;
    while (nextNSNode != DTM.NULL) {
        // Retrieve the name of the namespace node
        int eType = _exptype2(nextNSNode);
        String nodeName = m_extendedTypes[eType].getLocalName();
        // Retrieve the node value of the namespace node
        int dataIndex = m_dataOrQName.elementAt(nextNSNode);
        if (dataIndex < 0) {
            dataIndex = -dataIndex;
            dataIndex = m_data.elementAt(dataIndex + 1);
        }
        String nodeValue = (String) m_values.elementAt(dataIndex);
        handler.namespaceAfterStartElement(nodeName, nodeValue);
        if (inScope) {
            if (nsIndex < nsContext.size()) {
                nextNSNode = makeNodeIdentity(nsContext.elementAt(nsIndex));
                nsIndex++;
            } else
                return;
        } else
            nextNSNode = getNextNamespaceNode2(nextNSNode);
    }
}