Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTMManager#IDENT_DTM_NODE_BITS

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMManager#IDENT_DTM_NODE_BITS . 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: MultiDOM.java    From hottub with GNU General Public License v2.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 2
Source File: SAX2DTM.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
  * Migrate a DTM built with an old DTMManager to a new DTMManager.
  * After the migration, the new DTMManager will treat the DTM as
  * one that is built by itself.
  * This is used to support DTM sharing between multiple transformations.
  * @param manager the DTMManager
  */
public void migrateTo(DTMManager manager) {
  super.migrateTo(manager);

  // We have to reset the information in m_dtmIdent and
  // register the DTM with the new manager.
  int numDTMs = m_dtmIdent.size();
  int dtmId = m_mgrDefault.getFirstFreeDTMID();
  int nodeIndex = 0;
  for (int i = 0; i < numDTMs; i++)
  {
    m_dtmIdent.setElementAt(dtmId << DTMManager.IDENT_DTM_NODE_BITS, i);
    m_mgrDefault.addDTM(this, dtmId, nodeIndex);
    dtmId++;
    nodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
  }
}
 
Example 3
Source File: MultiDOM.java    From JDKSourceCode1.8 with MIT License 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 4
Source File: MultiDOM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void removeDOMAdapter(DOMAdapter adapter) {
    _documents.remove(adapter.getDocumentURI(0));
    DOM dom = adapter.getDOMImpl();

    if (dom instanceof DTMDefaultBase) {
        SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
        int idsSize = ids.size();
        for (int i = 0; i < idsSize; i++) {
            _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
        }
    } else {
        int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
        if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
            _adapters[id] = null;
        } else {
            boolean found = false;
            for (int i = 0; i < _adapters.length; i++) {
                if (isMatchingAdapterEntry(_adapters[id], adapter)) {
                    _adapters[i] = null;
                    found = true;
                    break;
                }
            }
        }
    }
}
 
Example 5
Source File: MultiDOM.java    From openjdk-jdk9 with GNU General Public License v2.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 6
Source File: SAX2DTM.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Migrate a DTM built with an old DTMManager to a new DTMManager.
  * After the migration, the new DTMManager will treat the DTM as
  * one that is built by itself.
  * This is used to support DTM sharing between multiple transformations.
  * @param manager the DTMManager
  */
public void migrateTo(DTMManager manager) {
  super.migrateTo(manager);

  // We have to reset the information in m_dtmIdent and
  // register the DTM with the new manager.
  int numDTMs = m_dtmIdent.size();
  int dtmId = m_mgrDefault.getFirstFreeDTMID();
  int nodeIndex = 0;
  for (int i = 0; i < numDTMs; i++)
  {
    m_dtmIdent.setElementAt(dtmId << DTMManager.IDENT_DTM_NODE_BITS, i);
    m_mgrDefault.addDTM(this, dtmId, nodeIndex);
    dtmId++;
    nodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
  }
}
 
Example 7
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 8
Source File: MultiDOM.java    From jdk1.8-source-analysis 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 9
Source File: MultiDOM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public int getDTMId(int nodeHandle)
{
    if (nodeHandle == DTM.NULL)
        return 0;

    int id = nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS;
    while (id >= 2 && _adapters[id] == _adapters[id-1]) {
        id--;
    }
    return id;
}
 
Example 10
Source File: SAX2DTM2.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a SAX2DTM2 object using the given block size.
 */
public SAX2DTM2(DTMManager mgr, Source source, int dtmIdentity,
               DTMWSFilter whiteSpaceFilter,
               XMLStringFactory xstringfactory,
               boolean doIndexing,
               int blocksize,
               boolean usePrevsib,
               boolean buildIdIndex,
               boolean newNameTable)
{

  super(mgr, source, dtmIdentity, whiteSpaceFilter,
        xstringfactory, doIndexing, blocksize, usePrevsib, newNameTable);

  // Initialize the values of m_SHIFT and m_MASK.
  int shift;
  for(shift=0; (blocksize>>>=1) != 0; ++shift);

  m_blocksize = 1<<shift;
  m_SHIFT = shift;
  m_MASK = m_blocksize - 1;

  m_buildIdIndex = buildIdIndex;

  // Some documents do not have attribute nodes. That is why
  // we set the initial size of this ArrayList to be small.
  m_values = new ArrayList<>(32);

  m_maxNodeIndex = 1 << DTMManager.IDENT_DTM_NODE_BITS;

  // Set the map0 values in the constructor.
  m_exptype_map0 = m_exptype.getMap0();
  m_nextsib_map0 = m_nextsib.getMap0();
  m_firstch_map0 = m_firstch.getMap0();
  m_parent_map0  = m_parent.getMap0();
}
 
Example 11
Source File: MultiDOM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public int getDTMId(int nodeHandle)
{
    if (nodeHandle == DTM.NULL)
        return 0;

    int id = nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS;
    while (id >= 2 && _adapters[id] == _adapters[id-1]) {
        id--;
    }
    return id;
}
 
Example 12
Source File: MultiDOM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public int getDTMId(int nodeHandle)
{
    if (nodeHandle == DTM.NULL)
        return 0;

    int id = nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS;
    while (id >= 2 && _adapters[id] == _adapters[id-1]) {
        id--;
    }
    return id;
}
 
Example 13
Source File: MultiDOM.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}
 
Example 14
Source File: SAX2DTM.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Construct the node map from the node.
 *
 * @param type raw type ID, one of DTM.XXX_NODE.
 * @param expandedTypeID The expended type ID.
 * @param parentIndex The current parent index.
 * @param previousSibling The previous sibling index.
 * @param dataOrPrefix index into m_data table, or string handle.
 * @param canHaveFirstChild true if the node can have a first child, false
 *                          if it is atomic.
 *
 * @return The index identity of the node that was added.
 */
protected int addNode(int type, int expandedTypeID,
                      int parentIndex, int previousSibling,
                      int dataOrPrefix, boolean canHaveFirstChild)
{
  // Common to all nodes:
  int nodeIndex = m_size++;

  // Have we overflowed a DTM Identity's addressing range?
  if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
  {
    addNewDTMID(nodeIndex);
  }

  m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL);
  m_nextsib.addElement(NOTPROCESSED);
  m_parent.addElement(parentIndex);
  m_exptype.addElement(expandedTypeID);
  m_dataOrQName.addElement(dataOrPrefix);

  if (m_prevsib != null) {
    m_prevsib.addElement(previousSibling);
  }

  if (DTM.NULL != previousSibling) {
    m_nextsib.setElementAt(nodeIndex,previousSibling);
  }

  if (m_locator != null && m_useSourceLocationProperty) {
    setSourceLocation();
  }

  // Note that nextSibling is not processed until charactersFlush()
  // is called, to handle successive characters() events.

  // Special handling by type: Declare namespaces, attach first child
  switch(type)
  {
  case DTM.NAMESPACE_NODE:
    declareNamespaceInContext(parentIndex,nodeIndex);
    break;
  case DTM.ATTRIBUTE_NODE:
    break;
  default:
    if (DTM.NULL == previousSibling && DTM.NULL != parentIndex) {
      m_firstch.setElementAt(nodeIndex,parentIndex);
    }
    break;
  }

  return nodeIndex;
}
 
Example 15
Source File: SAX2DTM.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Construct the node map from the node.
 *
 * @param type raw type ID, one of DTM.XXX_NODE.
 * @param expandedTypeID The expended type ID.
 * @param parentIndex The current parent index.
 * @param previousSibling The previous sibling index.
 * @param dataOrPrefix index into m_data table, or string handle.
 * @param canHaveFirstChild true if the node can have a first child, false
 *                          if it is atomic.
 *
 * @return The index identity of the node that was added.
 */
protected int addNode(int type, int expandedTypeID,
                      int parentIndex, int previousSibling,
                      int dataOrPrefix, boolean canHaveFirstChild)
{
  // Common to all nodes:
  int nodeIndex = m_size++;

  // Have we overflowed a DTM Identity's addressing range?
  if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
  {
    addNewDTMID(nodeIndex);
  }

  m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL);
  m_nextsib.addElement(NOTPROCESSED);
  m_parent.addElement(parentIndex);
  m_exptype.addElement(expandedTypeID);
  m_dataOrQName.addElement(dataOrPrefix);

  if (m_prevsib != null) {
    m_prevsib.addElement(previousSibling);
  }

  if (DTM.NULL != previousSibling) {
    m_nextsib.setElementAt(nodeIndex,previousSibling);
  }

  if (m_locator != null && m_useSourceLocationProperty) {
    setSourceLocation();
  }

  // Note that nextSibling is not processed until charactersFlush()
  // is called, to handle successive characters() events.

  // Special handling by type: Declare namespaces, attach first child
  switch(type)
  {
  case DTM.NAMESPACE_NODE:
    declareNamespaceInContext(parentIndex,nodeIndex);
    break;
  case DTM.ATTRIBUTE_NODE:
    break;
  default:
    if (DTM.NULL == previousSibling && DTM.NULL != parentIndex) {
      m_firstch.setElementAt(nodeIndex,parentIndex);
    }
    break;
  }

  return nodeIndex;
}
 
Example 16
Source File: MultiDOM.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}
 
Example 17
Source File: MultiDOM.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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);
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}
 
Example 18
Source File: MultiDOM.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
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);
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}
 
Example 19
Source File: MultiDOM.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
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);
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}
 
Example 20
Source File: MultiDOM.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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 hashtable
    if (indexByURI) {
        String uri = adapter.getDocumentURI(0);
        _documents.put(uri, new Integer(domNo));
    }

    // If the dom is an AdaptiveResultTreeImpl, we need to create a
    // DOMAdapter around its nested dom object (if it is non-null) and
    // 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;
}