Java Code Examples for com.sun.org.apache.xml.internal.utils.SuballocatedIntVector#elementAt()
The following examples show how to use
com.sun.org.apache.xml.internal.utils.SuballocatedIntVector#elementAt() .
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 jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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 2
Source File: MultiDOM.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 3
Source File: MultiDOM.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 4
Source File: MultiDOM.java From JDKSourceCode1.8 with MIT License | 6 votes |
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: DTMDefaultBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 6
Source File: DTMDefaultBase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 7
Source File: DTMDefaultBase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 8
Source File: DTMDefaultBase.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 9
Source File: DTMDefaultBase.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 10
Source File: DTMDefaultBase.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 11
Source File: DTMDefaultBase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 12
Source File: DTMDefaultBase.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 13
Source File: DTMDefaultBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 14
Source File: DTMDefaultBase.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 15
Source File: DTMDefaultBase.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Subroutine: Locate the specified node within * m_namespaceDeclSetElements, or the last element which * preceeds it in document order * * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type? * * @return If positive or zero, the index of the found item. * If negative, index of the point at which it would have appeared, * encoded as -1-index and hence reconvertable by subtracting * it from -1. (Encoding because I don't want to recompare the strings * but don't want to burn bytes on a datatype to hold a flagged value.) */ protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor) { // Binary search int i = 0; if(vector != null) { int first = 0; int last = vector.size() - 1; while (first <= last) { i = (first + last) / 2; int test = lookfor-vector.elementAt(i); if(test == 0) { return i; // Name found } else if (test < 0) { last = i - 1; // looked too late } else { first = i + 1; // looked ot early } } if (first > i) { i = first; // Clean up at loop end } } return -1 - i; // not-found has to be encoded. }
Example 16
Source File: DTMDefaultBase.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 17
Source File: DTMDefaultBase.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Given a namespace handle, advance to the next namespace. * * @param baseHandle handle to original node from where the first namespace * was relative to (needed to return nodes in document order). * @param nodeHandle A namespace handle for which we will find the next node. * @param inScope true if all namespaces that are in scope should be processed, * otherwise just process the nodes in the given element handle. * @return handle of next namespace, or DTM.NULL to indicate none exists. */ public int getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope) { if(inScope) { //Since we've been given the base, try direct lookup //(could look from nodeHandle but this is at least one //comparison/get-parent faster) //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask); SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle)); if(nsContext==null) return NULL; int i=1 + nsContext.indexOf(nodeHandle); if(i<=0 || i==nsContext.size()) return NULL; return nsContext.elementAt(i); } else { // Assume that attributes and namespace nodes immediately follow the element. int identity = makeNodeIdentity(nodeHandle); while (DTM.NULL != (identity = getNextNodeIdentity(identity))) { int type = _type(identity); if (type == DTM.NAMESPACE_NODE) { return makeNodeHandle(identity); } else if (type != DTM.ATTRIBUTE_NODE) { break; } } } return DTM.NULL; }
Example 18
Source File: MultiDOM.java From hottub with GNU General Public License v2.0 | 4 votes |
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 TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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 jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
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; }