return addDOMAdapter(adapter, true);
}
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(),