Source Home >> Java Source 1.6.0 >> com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase V 0.09
  • 0001/*
  • 0002 * Copyright 1999-2004 The Apache Software Foundation.
  • 0003 *
  • 0004 * Licensed under the Apache License, Version 2.0 (the "License");
  • 0005 * you may not use this file except in compliance with the License.
  • 0006 * You may obtain a copy of the License at
  • 0007 *
  • 0008 * http://www.apache.org/licenses/LICENSE-2.0
  • 0009 *
  • 0010 * Unless required by applicable law or agreed to in writing, software
  • 0011 * distributed under the License is distributed on an "AS IS" BASIS,
  • 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • 0013 * See the License for the specific language governing permissions and
  • 0014 * limitations under the License.
  • 0015 */
  • 0016/*
  • 0017 * $Id: DTMDefaultBase.java,v 1.3 2005/09/28 13:48:52 pvedula Exp $
  • 0018 */
  • 0019package com.sun.org.apache.xml.internal.dtm.ref;
  • 0020
  • 0021import com.sun.org.apache.xml.internal.dtm.*;
  • 0022import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
  • 0023import com.sun.org.apache.xml.internal.utils.BoolStack;
  • 0024
  • 0025import java.util.Vector;
  • 0026
  • 0027import javax.xml.transform.Source;
  • 0028
  • 0029import com.sun.org.apache.xml.internal.utils.XMLString;
  • 0030import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
  • 0031
  • 0032import com.sun.org.apache.xml.internal.res.XMLMessages;
  • 0033import com.sun.org.apache.xml.internal.res.XMLErrorResources;
  • 0034
  • 0035import java.io.*; // for dumpDTM
  • 0036
  • 0037/**
  • 0038 * The <code>DTMDefaultBase</code> class serves as a helper base for DTMs.
  • 0039 * It sets up structures for navigation and type, while leaving data
  • 0040 * management and construction to the derived classes.
  • 0041 */
  • 0042public abstract class DTMDefaultBase implements DTM
  • 0043{
  • 0044 static final boolean JJK_DEBUG=false;
  • 0045
  • 0046 // This constant is likely to be removed in the future. Use the
  • 0047 // getDocument() method instead of ROOTNODE to get at the root
  • 0048 // node of a DTM.
  • 0049 /** The identity of the root node. */
  • 0050 public static final int ROOTNODE = 0;
  • 0051
  • 0052 /**
  • 0053 * The number of nodes, which is also used to determine the next
  • 0054 * node index.
  • 0055 */
  • 0056 protected int m_size = 0;
  • 0057
  • 0058 /** The expanded names, one array element for each node. */
  • 0059 protected SuballocatedIntVector m_exptype;
  • 0060
  • 0061 /** First child values, one array element for each node. */
  • 0062 protected SuballocatedIntVector m_firstch;
  • 0063
  • 0064 /** Next sibling values, one array element for each node. */
  • 0065 protected SuballocatedIntVector m_nextsib;
  • 0066
  • 0067 /** Previous sibling values, one array element for each node. */
  • 0068 protected SuballocatedIntVector m_prevsib;
  • 0069
  • 0070 /** Previous sibling values, one array element for each node. */
  • 0071 protected SuballocatedIntVector m_parent;
  • 0072
  • 0073 /** Vector of SuballocatedIntVectors of NS decl sets */
  • 0074 protected Vector m_namespaceDeclSets = null;
  • 0075
  • 0076 /** SuballocatedIntVector of elements at which corresponding
  • 0077 * namespaceDeclSets were defined */
  • 0078 protected SuballocatedIntVector m_namespaceDeclSetElements = null;
  • 0079
  • 0080 /**
  • 0081 * These hold indexes to elements based on namespace and local name.
  • 0082 * The base lookup is the the namespace. The second lookup is the local
  • 0083 * name, and the last array contains the the first free element
  • 0084 * at the start, and the list of element handles following.
  • 0085 */
  • 0086 protected int[][][] m_elemIndexes;
  • 0087
  • 0088 /** The default block size of the node arrays */
  • 0089 public static final int DEFAULT_BLOCKSIZE = 512; // favor small docs.
  • 0090
  • 0091 /** The number of blocks for the node arrays */
  • 0092 public static final int DEFAULT_NUMBLOCKS = 32;
  • 0093
  • 0094 /** The number of blocks used for small documents & RTFs */
  • 0095 public static final int DEFAULT_NUMBLOCKS_SMALL = 4;
  • 0096
  • 0097 /** The block size of the node arrays */
  • 0098 //protected final int m_blocksize;
  • 0099
  • 0100 /**
  • 0101 * The value to use when the information has not been built yet.
  • 0102 */
  • 0103 protected static final int NOTPROCESSED = DTM.NULL - 1;
  • 0104
  • 0105 /**
  • 0106 * The DTM manager who "owns" this DTM.
  • 0107 */
  • 0108
  • 0109 public DTMManager m_mgr;
  • 0110
  • 0111 /**
  • 0112 * m_mgr cast to DTMManagerDefault, or null if it isn't an instance
  • 0113 * (Efficiency hook)
  • 0114 */
  • 0115 protected DTMManagerDefault m_mgrDefault=null;
  • 0116
  • 0117
  • 0118 /** The document identity number(s). If we have overflowed the addressing
  • 0119 * range of the first that was assigned to us, we may add others. */
  • 0120 protected SuballocatedIntVector m_dtmIdent;
  • 0121
  • 0122 /** The mask for the identity.
  • 0123 %REVIEW% Should this really be set to the _DEFAULT? What if
  • 0124 a particular DTM wanted to use another value? */
  • 0125 //protected final static int m_mask = DTMManager.IDENT_NODE_DEFAULT;
  • 0126
  • 0127 /** The base URI for this document. */
  • 0128 protected String m_documentBaseURI;
  • 0129
  • 0130 /**
  • 0131 * The whitespace filter that enables elements to strip whitespace or not.
  • 0132 */
  • 0133 protected DTMWSFilter m_wsfilter;
  • 0134
  • 0135 /** Flag indicating whether to strip whitespace nodes */
  • 0136 protected boolean m_shouldStripWS = false;
  • 0137
  • 0138 /** Stack of flags indicating whether to strip whitespace nodes */
  • 0139 protected BoolStack m_shouldStripWhitespaceStack;
  • 0140
  • 0141 /** The XMLString factory for creating XMLStrings. */
  • 0142 protected XMLStringFactory m_xstrf;
  • 0143
  • 0144 /**
  • 0145 * The table for exandedNameID lookups. This may or may not be the same
  • 0146 * table as is contained in the DTMManagerDefault.
  • 0147 */
  • 0148 protected ExpandedNameTable m_expandedNameTable;
  • 0149
  • 0150 /** true if indexing is turned on. */
  • 0151 protected boolean m_indexing;
  • 0152
  • 0153 /**
  • 0154 * Construct a DTMDefaultBase object using the default block size.
  • 0155 *
  • 0156 * @param mgr The DTMManager who owns this DTM.
  • 0157 * @param source The object that is used to specify the construction source.
  • 0158 * @param dtmIdentity The DTM identity ID for this DTM.
  • 0159 * @param whiteSpaceFilter The white space filter for this DTM, which may
  • 0160 * be null.
  • 0161 * @param xstringfactory The factory to use for creating XMLStrings.
  • 0162 * @param doIndexing true if the caller considers it worth it to use
  • 0163 * indexing schemes.
  • 0164 */
  • 0165 public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
  • 0166 DTMWSFilter whiteSpaceFilter,
  • 0167 XMLStringFactory xstringfactory, boolean doIndexing)
  • 0168 {
  • 0169 this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
  • 0170 doIndexing, DEFAULT_BLOCKSIZE, true, false);
  • 0171 }
  • 0172
  • 0173 /**
  • 0174 * Construct a DTMDefaultBase object from a DOM node.
  • 0175 *
  • 0176 * @param mgr The DTMManager who owns this DTM.
  • 0177 * @param source The object that is used to specify the construction source.
  • 0178 * @param dtmIdentity The DTM identity ID for this DTM.
  • 0179 * @param whiteSpaceFilter The white space filter for this DTM, which may
  • 0180 * be null.
  • 0181 * @param xstringfactory The factory to use for creating XMLStrings.
  • 0182 * @param doIndexing true if the caller considers it worth it to use
  • 0183 * indexing schemes.
  • 0184 * @param blocksize The block size of the DTM.
  • 0185 * @param usePrevsib true if we want to build the previous sibling node array.
  • 0186 * @param newNameTable true if we want to use a new ExpandedNameTable for this DTM.
  • 0187 */
  • 0188 public DTMDefaultBase(DTMManager mgr, Source source, int dtmIdentity,
  • 0189 DTMWSFilter whiteSpaceFilter,
  • 0190 XMLStringFactory xstringfactory, boolean doIndexing,
  • 0191 int blocksize, boolean usePrevsib,
  • 0192 boolean newNameTable)
  • 0193 {
  • 0194 // Use smaller sizes for the internal node arrays if the block size
  • 0195 // is small.
  • 0196 int numblocks;
  • 0197 if (blocksize <= 64)
  • 0198 {
  • 0199 numblocks = DEFAULT_NUMBLOCKS_SMALL;
  • 0200 m_dtmIdent= new SuballocatedIntVector(4, 1);
  • 0201 }
  • 0202 else
  • 0203 {
  • 0204 numblocks = DEFAULT_NUMBLOCKS;
  • 0205 m_dtmIdent= new SuballocatedIntVector(32);
  • 0206 }
  • 0207
  • 0208 m_exptype = new SuballocatedIntVector(blocksize, numblocks);
  • 0209 m_firstch = new SuballocatedIntVector(blocksize, numblocks);
  • 0210 m_nextsib = new SuballocatedIntVector(blocksize, numblocks);
  • 0211 m_parent = new SuballocatedIntVector(blocksize, numblocks);
  • 0212
  • 0213 // Only create the m_prevsib array if the usePrevsib flag is true.
  • 0214 // Some DTM implementations (e.g. SAXImpl) do not need this array.
  • 0215 // We can save the time to build it in those cases.
  • 0216 if (usePrevsib)
  • 0217 m_prevsib = new SuballocatedIntVector(blocksize, numblocks);
  • 0218
  • 0219 m_mgr = mgr;
  • 0220 if(mgr instanceof DTMManagerDefault)
  • 0221 m_mgrDefault=(DTMManagerDefault)mgr;
  • 0222
  • 0223 m_documentBaseURI = (null != source) ? source.getSystemId() : null;
  • 0224 m_dtmIdent.setElementAt(dtmIdentity,0);
  • 0225 m_wsfilter = whiteSpaceFilter;
  • 0226 m_xstrf = xstringfactory;
  • 0227 m_indexing = doIndexing;
  • 0228
  • 0229 if (doIndexing)
  • 0230 {
  • 0231 m_expandedNameTable = new ExpandedNameTable();
  • 0232 }
  • 0233 else
  • 0234 {
  • 0235 // Note that this fails if we aren't talking to an instance of
  • 0236 // DTMManagerDefault
  • 0237 m_expandedNameTable = m_mgrDefault.getExpandedNameTable(this);
  • 0238 }
  • 0239
  • 0240 if (null != whiteSpaceFilter)
  • 0241 {
  • 0242 m_shouldStripWhitespaceStack = new BoolStack();
  • 0243
  • 0244 pushShouldStripWhitespace(false);
  • 0245 }
  • 0246 }
  • 0247
  • 0248 /**
  • 0249 * Ensure that the size of the element indexes can hold the information.
  • 0250 *
  • 0251 * @param namespaceID Namespace ID index.
  • 0252 * @param LocalNameID Local name ID.
  • 0253 */
  • 0254 protected void ensureSizeOfIndex(int namespaceID, int LocalNameID)
  • 0255 {
  • 0256
  • 0257 if (null == m_elemIndexes)
  • 0258 {
  • 0259 m_elemIndexes = new int[namespaceID + 20][][];
  • 0260 }
  • 0261 else if (m_elemIndexes.length <= namespaceID)
  • 0262 {
  • 0263 int[][][] indexes = m_elemIndexes;
  • 0264
  • 0265 m_elemIndexes = new int[namespaceID + 20][][];
  • 0266
  • 0267 System.arraycopy(indexes, 0, m_elemIndexes, 0, indexes.length);
  • 0268 }
  • 0269
  • 0270 int[][] localNameIndex = m_elemIndexes[namespaceID];
  • 0271
  • 0272 if (null == localNameIndex)
  • 0273 {
  • 0274 localNameIndex = new int[LocalNameID + 100][];
  • 0275 m_elemIndexes[namespaceID] = localNameIndex;
  • 0276 }
  • 0277 else if (localNameIndex.length <= LocalNameID)
  • 0278 {
  • 0279 int[][] indexes = localNameIndex;
  • 0280
  • 0281 localNameIndex = new int[LocalNameID + 100][];
  • 0282
  • 0283 System.arraycopy(indexes, 0, localNameIndex, 0, indexes.length);
  • 0284
  • 0285 m_elemIndexes[namespaceID] = localNameIndex;
  • 0286 }
  • 0287
  • 0288 int[] elemHandles = localNameIndex[LocalNameID];
  • 0289
  • 0290 if (null == elemHandles)
  • 0291 {
  • 0292 elemHandles = new int[128];
  • 0293 localNameIndex[LocalNameID] = elemHandles;
  • 0294 elemHandles[0] = 1;
  • 0295 }
  • 0296 else if (elemHandles.length <= elemHandles[0] + 1)
  • 0297 {
  • 0298 int[] indexes = elemHandles;
  • 0299
  • 0300 elemHandles = new int[elemHandles[0] + 1024];
  • 0301
  • 0302 System.arraycopy(indexes, 0, elemHandles, 0, indexes.length);
  • 0303
  • 0304 localNameIndex[LocalNameID] = elemHandles;
  • 0305 }
  • 0306 }
  • 0307
  • 0308 /**
  • 0309 * Add a node to the element indexes. The node will not be added unless
  • 0310 * it's an element.
  • 0311 *
  • 0312 * @param expandedTypeID The expanded type ID of the node.
  • 0313 * @param identity The node identity index.
  • 0314 */
  • 0315 protected void indexNode(int expandedTypeID, int identity)
  • 0316 {
  • 0317
  • 0318 ExpandedNameTable ent = m_expandedNameTable;
  • 0319 short type = ent.getType(expandedTypeID);
  • 0320
  • 0321 if (DTM.ELEMENT_NODE == type)
  • 0322 {
  • 0323 int namespaceID = ent.getNamespaceID(expandedTypeID);
  • 0324 int localNameID = ent.getLocalNameID(expandedTypeID);
  • 0325
  • 0326 ensureSizeOfIndex(namespaceID, localNameID);
  • 0327
  • 0328 int[] index = m_elemIndexes[namespaceID][localNameID];
  • 0329
  • 0330 index[index[0]] = identity;
  • 0331
  • 0332 index[0]++;
  • 0333 }
  • 0334 }
  • 0335
  • 0336 /**
  • 0337 * Find the first index that occurs in the list that is greater than or
  • 0338 * equal to the given value.
  • 0339 *
  • 0340 * @param list A list of integers.
  • 0341 * @param start The start index to begin the search.
  • 0342 * @param len The number of items to search.
  • 0343 * @param value Find the slot that has a value that is greater than or
  • 0344 * identical to this argument.
  • 0345 *
  • 0346 * @return The index in the list of the slot that is higher or identical
  • 0347 * to the identity argument, or -1 if no node is higher or equal.
  • 0348 */
  • 0349 protected int findGTE(int[] list, int start, int len, int value)
  • 0350 {
  • 0351
  • 0352 int low = start;
  • 0353 int high = start + (len - 1);
  • 0354 int end = high;
  • 0355
  • 0356 while (low <= high)
  • 0357 {
  • 0358 int mid = (low + high) / 2;
  • 0359 int c = list[mid];
  • 0360
  • 0361 if (c > value)
  • 0362 high = mid - 1;
  • 0363 else if (c < value)
  • 0364 low = mid + 1;
  • 0365 else
  • 0366 return mid;
  • 0367 }
  • 0368
  • 0369 return (low <= end && list[low] > value) ? low : -1;
  • 0370 }
  • 0371
  • 0372 /**
  • 0373 * Find the first matching element from the index at or after the
  • 0374 * given node.
  • 0375 *
  • 0376 * @param nsIndex The namespace index lookup.
  • 0377 * @param lnIndex The local name index lookup.
  • 0378 * @param firstPotential The first potential match that is worth looking at.
  • 0379 *
  • 0380 * @return The first node that is greater than or equal to the
  • 0381 * firstPotential argument, or DTM.NOTPROCESSED if not found.
  • 0382 */
  • 0383 int findElementFromIndex(int nsIndex, int lnIndex, int firstPotential)
  • 0384 {
  • 0385
  • 0386 int[][][] indexes = m_elemIndexes;
  • 0387
  • 0388 if (null != indexes && nsIndex < indexes.length)
  • 0389 {
  • 0390 int[][] lnIndexs = indexes[nsIndex];
  • 0391
  • 0392 if (null != lnIndexs && lnIndex < lnIndexs.length)
  • 0393 {
  • 0394 int[] elems = lnIndexs[lnIndex];
  • 0395
  • 0396 if (null != elems)
  • 0397 {
  • 0398 int pos = findGTE(elems, 1, elems[0], firstPotential);
  • 0399
  • 0400 if (pos > -1)
  • 0401 {
  • 0402 return elems[pos];
  • 0403 }
  • 0404 }
  • 0405 }
  • 0406 }
  • 0407
  • 0408 return NOTPROCESSED;
  • 0409 }
  • 0410
  • 0411 /**
  • 0412 * Get the next node identity value in the list, and call the iterator
  • 0413 * if it hasn't been added yet.
  • 0414 *
  • 0415 * @param identity The node identity (index).
  • 0416 * @return identity+1, or DTM.NULL.
  • 0417 */
  • 0418 protected abstract int getNextNodeIdentity(int identity);
  • 0419
  • 0420 /**
  • 0421 * This method should try and build one or more nodes in the table.
  • 0422 *
  • 0423 * @return The true if a next node is found or false if
  • 0424 * there are no more nodes.
  • 0425 */
  • 0426 protected abstract boolean nextNode();
  • 0427
  • 0428 /**
  • 0429 * Get the number of nodes that have been added.
  • 0430 *
  • 0431 * @return the number of nodes that have been mapped.
  • 0432 */
  • 0433 protected abstract int getNumberOfNodes();
  • 0434
  • 0435 /** Stateless axis traversers, lazely built. */
  • 0436 protected DTMAxisTraverser[] m_traversers;
  • 0437
  • 0438// /**
  • 0439// * Ensure that the size of the information arrays can hold another entry
  • 0440// * at the given index.
  • 0441// *
  • 0442// * @param index On exit from this function, the information arrays sizes must be
  • 0443// * at least index+1.
  • 0444// */
  • 0445// protected void ensureSize(int index)
  • 0446// {
  • 0447// // We've cut over to Suballocated*Vector, which are self-sizing.
  • 0448// }
  • 0449
  • 0450 /**
  • 0451 * Get the simple type ID for the given node identity.
  • 0452 *
  • 0453 * @param identity The node identity.
  • 0454 *
  • 0455 * @return The simple type ID, or DTM.NULL.
  • 0456 */
  • 0457 protected short _type(int identity)
  • 0458 {
  • 0459
  • 0460 int info = _exptype(identity);
  • 0461
  • 0462 if (NULL != info)
  • 0463 return m_expandedNameTable.getType(info);
  • 0464 else
  • 0465 return NULL;
  • 0466 }
  • 0467
  • 0468 /**
  • 0469 * Get the expanded type ID for the given node identity.
  • 0470 *
  • 0471 * @param identity The node identity.
  • 0472 *
  • 0473 * @return The expanded type ID, or DTM.NULL.
  • 0474 */
  • 0475 protected int _exptype(int identity)
  • 0476 {
  • 0477 if (identity == DTM.NULL)
  • 0478 return NULL;
  • 0479 // Reorganized test and loop into single flow
  • 0480 // Tiny performance improvement, saves a few bytes of code, clearer.
  • 0481 // %OPT% Other internal getters could be treated simliarly
  • 0482 while (identity>=m_size)
  • 0483 {
  • 0484 if (!nextNode() && identity >= m_size)
  • 0485 return NULL;
  • 0486 }
  • 0487 return m_exptype.elementAt(identity);
  • 0488
  • 0489 }
  • 0490
  • 0491 /**
  • 0492 * Get the level in the tree for the given node identity.
  • 0493 *
  • 0494 * @param identity The node identity.
  • 0495 *
  • 0496 * @return The tree level, or DTM.NULL.
  • 0497 */
  • 0498 protected int _level(int identity)
  • 0499 {
  • 0500 while (identity>=m_size)
  • 0501 {
  • 0502 boolean isMore = nextNode();
  • 0503 if (!isMore && identity >= m_size)
  • 0504 return NULL;
  • 0505 }
  • 0506
  • 0507 int i=0;
  • 0508 while(NULL != (identity=_parent(identity)))
  • 0509 ++i;
  • 0510 return i;
  • 0511 }
  • 0512
  • 0513 /**
  • 0514 * Get the first child for the given node identity.
  • 0515 *
  • 0516 * @param identity The node identity.
  • 0517 *
  • 0518 * @return The first child identity, or DTM.NULL.
  • 0519 */
  • 0520 protected int _firstch(int identity)
  • 0521 {
  • 0522
  • 0523 // Boiler-plate code for each of the _xxx functions, except for the array.
  • 0524 int info = (identity >= m_size) ? NOTPROCESSED : m_firstch.elementAt(identity);
  • 0525
  • 0526 // Check to see if the information requested has been processed, and,
  • 0527 // if not, advance the iterator until we the information has been
  • 0528 // processed.
  • 0529 while (info == NOTPROCESSED)
  • 0530 {
  • 0531 boolean isMore = nextNode();
  • 0532
  • 0533 if (identity >= m_size &&!isMore)
  • 0534 return NULL;
  • 0535 else
  • 0536 {
  • 0537 info = m_firstch.elementAt(identity);
  • 0538 if(info == NOTPROCESSED && !isMore)
  • 0539 return NULL;
  • 0540 }
  • 0541 }
  • 0542
  • 0543 return info;
  • 0544 }
  • 0545
  • 0546 /**
  • 0547 * Get the next sibling for the given node identity.
  • 0548 *
  • 0549 * @param identity The node identity.
  • 0550 *
  • 0551 * @return The next sibling identity, or DTM.NULL.
  • 0552 */
  • 0553 protected int _nextsib(int identity)
  • 0554 {
  • 0555 // Boiler-plate code for each of the _xxx functions, except for the array.
  • 0556 int info = (identity >= m_size) ? NOTPROCESSED : m_nextsib.elementAt(identity);
  • 0557
  • 0558 // Check to see if the information requested has been processed, and,
  • 0559 // if not, advance the iterator until we the information has been
  • 0560 // processed.
  • 0561 while (info == NOTPROCESSED)
  • 0562 {
  • 0563 boolean isMore = nextNode();
  • 0564
  • 0565 if (identity >= m_size &&!isMore)
  • 0566 return NULL;
  • 0567 else
  • 0568 {
  • 0569 info = m_nextsib.elementAt(identity);
  • 0570 if(info == NOTPROCESSED && !isMore)
  • 0571 return NULL;
  • 0572 }
  • 0573 }
  • 0574
  • 0575 return info;
  • 0576 }
  • 0577
  • 0578 /**
  • 0579 * Get the previous sibling for the given node identity.
  • 0580 *
  • 0581 * @param identity The node identity.
  • 0582 *
  • 0583 * @return The previous sibling identity, or DTM.NULL.
  • 0584 */
  • 0585 protected int _prevsib(int identity)
  • 0586 {
  • 0587
  • 0588 if (identity < m_size)
  • 0589 return m_prevsib.elementAt(identity);
  • 0590
  • 0591 // Check to see if the information requested has been processed, and,
  • 0592 // if not, advance the iterator until we the information has been
  • 0593 // processed.
  • 0594 while (true)
  • 0595 {
  • 0596 boolean isMore = nextNode();
  • 0597
  • 0598 if (identity >= m_size && !isMore)
  • 0599 return NULL;
  • 0600 else if (identity < m_size)
  • 0601 return m_prevsib.elementAt(identity);
  • 0602 }
  • 0603 }
  • 0604
  • 0605 /**
  • 0606 * Get the parent for the given node identity.
  • 0607 *
  • 0608 * @param identity The node identity.
  • 0609 *
  • 0610 * @return The parent identity, or DTM.NULL.
  • 0611 */
  • 0612 protected int _parent(int identity)
  • 0613 {
  • 0614
  • 0615 if (identity < m_size)
  • 0616 return m_parent.elementAt(identity);
  • 0617
  • 0618 // Check to see if the information requested has been processed, and,
  • 0619 // if not, advance the iterator until we the information has been
  • 0620 // processed.
  • 0621 while (true)
  • 0622 {
  • 0623 boolean isMore = nextNode();
  • 0624
  • 0625 if (identity >= m_size && !isMore)
  • 0626 return NULL;
  • 0627 else if (identity < m_size)
  • 0628 return m_parent.elementAt(identity);
  • 0629 }
  • 0630 }
  • 0631
  • 0632 /**
  • 0633 * Diagnostics function to dump the DTM.
  • 0634 */
  • 0635 public void dumpDTM(OutputStream os)
  • 0636 {
  • 0637 try
  • 0638 {
  • 0639 if(os==null)
  • 0640 {
  • 0641 File f = new File("DTMDump"+((Object)this).hashCode()+".txt");
  • 0642 System.err.println("Dumping... "+f.getAbsolutePath());
  • 0643 os=new FileOutputStream(f);
  • 0644 }
  • 0645 PrintStream ps = new PrintStream(os);
  • 0646
  • 0647 while (nextNode()){}
  • 0648
  • 0649 int nRecords = m_size;
  • 0650
  • 0651 ps.println("Total nodes: " + nRecords);
  • 0652
  • 0653 for (int index = 0; index < nRecords; ++index)
  • 0654 {
  • 0655 int i=makeNodeHandle(index);
  • 0656 ps.println("=========== index=" + index + " handle=" + i + " ===========");
  • 0657 ps.println("NodeName: " + getNodeName(i));
  • 0658 ps.println("NodeNameX: " + getNodeNameX(i));
  • 0659 ps.println("LocalName: " + getLocalName(i));
  • 0660 ps.println("NamespaceURI: " + getNamespaceURI(i));
  • 0661 ps.println("Prefix: " + getPrefix(i));
  • 0662
  • 0663 int exTypeID = _exptype(index);
  • 0664
  • 0665 ps.println("Expanded Type ID: "
  • 0666 + Integer.toHexString(exTypeID));
  • 0667
  • 0668 int type = _type(index);
  • 0669 String typestring;
  • 0670
  • 0671 switch (type)
  • 0672 {
  • 0673 case DTM.ATTRIBUTE_NODE :
  • 0674 typestring = "ATTRIBUTE_NODE";
  • 0675 break;
  • 0676 case DTM.CDATA_SECTION_NODE :
  • 0677 typestring = "CDATA_SECTION_NODE";
  • 0678 break;
  • 0679 case DTM.COMMENT_NODE :
  • 0680 typestring = "COMMENT_NODE";
  • 0681 break;
  • 0682 case DTM.DOCUMENT_FRAGMENT_NODE :
  • 0683 typestring = "DOCUMENT_FRAGMENT_NODE";
  • 0684 break;
  • 0685 case DTM.DOCUMENT_NODE :
  • 0686 typestring = "DOCUMENT_NODE";
  • 0687 break;
  • 0688 case DTM.DOCUMENT_TYPE_NODE :
  • 0689 typestring = "DOCUMENT_NODE";
  • 0690 break;
  • 0691 case DTM.ELEMENT_NODE :
  • 0692 typestring = "ELEMENT_NODE";
  • 0693 break;
  • 0694 case DTM.ENTITY_NODE :
  • 0695 typestring = "ENTITY_NODE";
  • 0696 break;
  • 0697 case DTM.ENTITY_REFERENCE_NODE :
  • 0698 typestring = "ENTITY_REFERENCE_NODE";
  • 0699 break;
  • 0700 case DTM.NAMESPACE_NODE :
  • 0701 typestring = "NAMESPACE_NODE";
  • 0702 break;
  • 0703 case DTM.NOTATION_NODE :
  • 0704 typestring = "NOTATION_NODE";
  • 0705 break;
  • 0706 case DTM.NULL :
  • 0707 typestring = "NULL";
  • 0708 break;
  • 0709 case DTM.PROCESSING_INSTRUCTION_NODE :
  • 0710 typestring = "PROCESSING_INSTRUCTION_NODE";
  • 0711 break;
  • 0712 case DTM.TEXT_NODE :
  • 0713 typestring = "TEXT_NODE";
  • 0714 break;
  • 0715 default :
  • 0716 typestring = "Unknown!";
  • 0717 break;
  • 0718 }
  • 0719
  • 0720 ps.println("Type: " + typestring);
  • 0721
  • 0722 int firstChild = _firstch(index);
  • 0723
  • 0724 if (DTM.NULL == firstChild)
  • 0725 ps.println("First child: DTM.NULL");
  • 0726 else if (NOTPROCESSED == firstChild)
  • 0727 ps.println("First child: NOTPROCESSED");
  • 0728 else
  • 0729 ps.println("First child: " + firstChild);
  • 0730
  • 0731 if (m_prevsib != null)
  • 0732 {
  • 0733 int prevSibling = _prevsib(index);
  • 0734
  • 0735 if (DTM.NULL == prevSibling)
  • 0736 ps.println("Prev sibling: DTM.NULL");
  • 0737 else if (NOTPROCESSED == prevSibling)
  • 0738 ps.println("Prev sibling: NOTPROCESSED");
  • 0739 else
  • 0740 ps.println("Prev sibling: " + prevSibling);
  • 0741 }
  • 0742
  • 0743 int nextSibling = _nextsib(index);
  • 0744
  • 0745 if (DTM.NULL == nextSibling)
  • 0746 ps.println("Next sibling: DTM.NULL");
  • 0747 else if (NOTPROCESSED == nextSibling)
  • 0748 ps.println("Next sibling: NOTPROCESSED");
  • 0749 else
  • 0750 ps.println("Next sibling: " + nextSibling);
  • 0751
  • 0752 int parent = _parent(index);
  • 0753
  • 0754 if (DTM.NULL == parent)
  • 0755 ps.println("Parent: DTM.NULL");
  • 0756 else if (NOTPROCESSED == parent)
  • 0757 ps.println("Parent: NOTPROCESSED");
  • 0758 else
  • 0759 ps.println("Parent: " + parent);
  • 0760
  • 0761 int level = _level(index);
  • 0762
  • 0763 ps.println("Level: " + level);
  • 0764 ps.println("Node Value: " + getNodeValue(i));
  • 0765 ps.println("String Value: " + getStringValue(i));
  • 0766 }
  • 0767 }
  • 0768 catch(IOException ioe)
  • 0769 {
  • 0770 ioe.printStackTrace(System.err);
  • 0771 throw new RuntimeException(ioe.getMessage());
  • 0772 }
  • 0773 }
  • 0774
  • 0775 /**
  • 0776 * Diagnostics function to dump a single node.
  • 0777 *
  • 0778 * %REVIEW% KNOWN GLITCH: If you pass it a node index rather than a
  • 0779 * node handle, it works just fine... but the displayed identity
  • 0780 * number before the colon is different, which complicates comparing
  • 0781 * it with nodes printed the other way. We could always OR the DTM ID
  • 0782 * into the value, to suppress that distinction...
  • 0783 *
  • 0784 * %REVIEW% This might want to be moved up to DTMDefaultBase, or possibly
  • 0785 * DTM itself, since it's a useful diagnostic and uses only DTM's public
  • 0786 * APIs.
  • 0787 */
  • 0788 public String dumpNode(int nodeHandle)
  • 0789 {
  • 0790 if(nodeHandle==DTM.NULL)
  • 0791 return "[null]";
  • 0792
  • 0793 String typestring;
  • 0794 switch (getNodeType(nodeHandle))
  • 0795 {
  • 0796 case DTM.ATTRIBUTE_NODE :
  • 0797 typestring = "ATTR";
  • 0798 break;
  • 0799 case DTM.CDATA_SECTION_NODE :
  • 0800 typestring = "CDATA";
  • 0801 break;
  • 0802 case DTM.COMMENT_NODE :
  • 0803 typestring = "COMMENT";
  • 0804 break;
  • 0805 case DTM.DOCUMENT_FRAGMENT_NODE :
  • 0806 typestring = "DOC_FRAG";
  • 0807 break;
  • 0808 case DTM.DOCUMENT_NODE :
  • 0809 typestring = "DOC";
  • 0810 break;
  • 0811 case DTM.DOCUMENT_TYPE_NODE :
  • 0812 typestring = "DOC_TYPE";
  • 0813 break;
  • 0814 case DTM.ELEMENT_NODE :
  • 0815 typestring = "ELEMENT";
  • 0816 break;
  • 0817 case DTM.ENTITY_NODE :
  • 0818 typestring = "ENTITY";
  • 0819 break;
  • 0820 case DTM.ENTITY_REFERENCE_NODE :
  • 0821 typestring = "ENT_REF";
  • 0822 break;
  • 0823 case DTM.NAMESPACE_NODE :
  • 0824 typestring = "NAMESPACE";
  • 0825 break;
  • 0826 case DTM.NOTATION_NODE :
  • 0827 typestring = "NOTATION";
  • 0828 break;
  • 0829 case DTM.NULL :
  • 0830 typestring = "null";
  • 0831 break;
  • 0832 case DTM.PROCESSING_INSTRUCTION_NODE :
  • 0833 typestring = "PI";
  • 0834 break;
  • 0835 case DTM.TEXT_NODE :
  • 0836 typestring = "TEXT";
  • 0837 break;
  • 0838 default :
  • 0839 typestring = "Unknown!";
  • 0840 break;
  • 0841 }
  • 0842
  • 0843 StringBuffer sb=new StringBuffer();
  • 0844 sb.append("["+nodeHandle+": "+typestring+
  • 0845 "(0x"+Integer.toHexString(getExpandedTypeID(nodeHandle))+") "+
  • 0846 getNodeNameX(nodeHandle)+" {"+getNamespaceURI(nodeHandle)+"}"+
  • 0847 "=\""+ getNodeValue(nodeHandle)+"\"]");
  • 0848 return sb.toString();
  • 0849 }
  • 0850
  • 0851 // ========= DTM Implementation Control Functions. ==============
  • 0852
  • 0853 /**
  • 0854 * Set an implementation dependent feature.
  • 0855 * <p>
  • 0856 * %REVIEW% Do we really expect to set features on DTMs?
  • 0857 *
  • 0858 * @param featureId A feature URL.
  • 0859 * @param state true if this feature should be on, false otherwise.
  • 0860 */
  • 0861 public void setFeature(String featureId, boolean state){}
  • 0862
  • 0863 // ========= Document Navigation Functions =========
  • 0864
  • 0865 /**
  • 0866 * Given a node handle, test if it has child nodes.
  • 0867 * <p> %REVIEW% This is obviously useful at the DOM layer, where it
  • 0868 * would permit testing this without having to create a proxy
  • 0869 * node. It's less useful in the DTM API, where
  • 0870 * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
  • 0871 * almost as self-evident. But it's a convenience, and eases porting
  • 0872 * of DOM code to DTM. </p>
  • 0873 *
  • 0874 * @param nodeHandle int Handle of the node.
  • 0875 * @return int true if the given node has child nodes.
  • 0876 */
  • 0877 public boolean hasChildNodes(int nodeHandle)
  • 0878 {
  • 0879
  • 0880 int identity = makeNodeIdentity(nodeHandle);
  • 0881 int firstChild = _firstch(identity);
  • 0882
  • 0883 return firstChild != DTM.NULL;
  • 0884 }
  • 0885
  • 0886 /** Given a node identity, return a node handle. If extended addressing
  • 0887 * has been used (multiple DTM IDs), we need to map the high bits of the
  • 0888 * identity into the proper DTM ID.
  • 0889 *
  • 0890 * This has been made FINAL to facilitate inlining, since we do not expect
  • 0891 * any subclass of DTMDefaultBase to ever change the algorithm. (I don't
  • 0892 * really like doing so, and would love to have an excuse not to...)
  • 0893 *
  • 0894 * %REVIEW% Is it worth trying to specialcase small documents?
  • 0895 * %REVIEW% Should this be exposed at the package/public layers?
  • 0896 *
  • 0897 * @param nodeIdentity Internal offset to this node's records.
  • 0898 * @return NodeHandle (external representation of node)
  • 0899 * */
  • 0900 final public int makeNodeHandle(int nodeIdentity)
  • 0901 {
  • 0902 if(NULL==nodeIdentity) return NULL;
  • 0903
  • 0904 if(JJK_DEBUG && nodeIdentity>DTMManager.IDENT_NODE_DEFAULT)
  • 0905 System.err.println("GONK! (only useful in limited situations)");
  • 0906
  • 0907 return m_dtmIdent.elementAt(nodeIdentity >>> DTMManager.IDENT_DTM_NODE_BITS)
  • 0908 + (nodeIdentity & DTMManager.IDENT_NODE_DEFAULT) ;
  • 0909 }
  • 0910
  • 0911 /** Given a node handle, return a node identity. If extended addressing
  • 0912 * has been used (multiple DTM IDs), we need to map the high bits of the
  • 0913 * identity into the proper DTM ID and thence find the proper offset
  • 0914 * to add to the low bits of the identity
  • 0915 *
  • 0916 * This has been made FINAL to facilitate inlining, since we do not expect
  • 0917 * any subclass of DTMDefaultBase to ever change the algorithm. (I don't
  • 0918 * really like doing so, and would love to have an excuse not to...)
  • 0919 *
  • 0920 * %OPT% Performance is critical for this operation.
  • 0921 *
  • 0922 * %REVIEW% Should this be exposed at the package/public layers?
  • 0923 *
  • 0924 * @param nodeHandle (external representation of node)
  • 0925 * @return nodeIdentity Internal offset to this node's records.
  • 0926 * */
  • 0927 final public int makeNodeIdentity(int nodeHandle)
  • 0928 {
  • 0929 if(NULL==nodeHandle) return NULL;
  • 0930
  • 0931 if(m_mgrDefault!=null)
  • 0932 {
  • 0933 // Optimization: use the DTMManagerDefault's fast DTMID-to-offsets
  • 0934 // table. I'm not wild about this solution but this operation
  • 0935 // needs need extreme speed.
  • 0936
  • 0937 int whichDTMindex=nodeHandle>>>DTMManager.IDENT_DTM_NODE_BITS;
  • 0938
  • 0939 // %REVIEW% Wish I didn't have to perform the pre-test, but
  • 0940 // someone is apparently asking DTMs whether they contain nodes
  • 0941 // which really don't belong to them. That's probably a bug
  • 0942 // which should be fixed, but until it is:
  • 0943 if(m_mgrDefault.m_dtms[whichDTMindex]!=this)
  • 0944 return NULL;
  • 0945 else
  • 0946 return
  • 0947 m_mgrDefault.m_dtm_offsets[whichDTMindex]
  • 0948 | (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
  • 0949 }
  • 0950
  • 0951 int whichDTMid=m_dtmIdent.indexOf(nodeHandle & DTMManager.IDENT_DTM_DEFAULT);
  • 0952 return (whichDTMid==NULL)
  • 0953 ? NULL
  • 0954 : (whichDTMid << DTMManager.IDENT_DTM_NODE_BITS)
  • 0955 + (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
  • 0956 }
  • 0957
  • 0958
  • 0959 /**
  • 0960 * Given a node handle, get the handle of the node's first child.
  • 0961 * If not yet resolved, waits for more nodes to be added to the document and
  • 0962 * tries again.
  • 0963 *
  • 0964 * @param nodeHandle int Handle of the node.
  • 0965 * @return int DTM node-number of first child, or DTM.NULL to indicate none exists.
  • 0966 */
  • 0967 public int getFirstChild(int nodeHandle)
  • 0968 {
  • 0969
  • 0970 int identity = makeNodeIdentity(nodeHandle);
  • 0971 int firstChild = _firstch(identity);
  • 0972
  • 0973 return makeNodeHandle(firstChild);
  • 0974 }
  • 0975
  • 0976 /**
  • 0977 * Given a node handle, get the handle of the node's first child.
  • 0978 * If not yet resolved, waits for more nodes to be added to the document and
  • 0979 * tries again.
  • 0980 *
  • 0981 * @param nodeHandle int Handle of the node.
  • 0982 * @return int DTM node-number of first child, or DTM.NULL to indicate none exists.
  • 0983 */
  • 0984 public int getTypedFirstChild(int nodeHandle, int nodeType)
  • 0985 {
  • 0986
  • 0987 int firstChild, eType;
  • 0988 if (nodeType < DTM.NTYPES) {
  • 0989 for (firstChild = _firstch(makeNodeIdentity(nodeHandle));
  • 0990 firstChild != DTM.NULL;
  • 0991 firstChild = _nextsib(firstChild)) {
  • 0992 eType = _exptype(firstChild);
  • 0993 if (eType == nodeType
  • 0994 || (eType >= DTM.NTYPES
  • 0995 && m_expandedNameTable.getType(eType) == nodeType)) {
  • 0996 return makeNodeHandle(firstChild);
  • 0997 }
  • 0998 }
  • 0999 } else {
  • 1000 for (firstChild = _firstch(makeNodeIdentity(nodeHandle));
  • 1001 firstChild != DTM.NULL;
  • 1002 firstChild = _nextsib(firstChild)) {
  • 1003 if (_exptype(firstChild) == nodeType) {
  • 1004 return makeNodeHandle(firstChild);
  • 1005 }
  • 1006 }
  • 1007 }
  • 1008 return DTM.NULL;
  • 1009 }
  • 1010
  • 1011 /**
  • 1012 * Given a node handle, advance to its last child.
  • 1013 * If not yet resolved, waits for more nodes to be added to the document and
  • 1014 * tries again.
  • 1015 *
  • 1016 * @param nodeHandle int Handle of the node.
  • 1017 * @return int Node-number of last child,
  • 1018 * or DTM.NULL to indicate none exists.
  • 1019 */
  • 1020 public int getLastChild(int nodeHandle)
  • 1021 {
  • 1022
  • 1023 int identity = makeNodeIdentity(nodeHandle);
  • 1024 int child = _firstch(identity);
  • 1025 int lastChild = DTM.NULL;
  • 1026
  • 1027 while (child != DTM.NULL)
  • 1028 {
  • 1029 lastChild = child;
  • 1030 child = _nextsib(child);
  • 1031 }
  • 1032
  • 1033 return makeNodeHandle(lastChild);
  • 1034 }
  • 1035
  • 1036 /**
  • 1037 * Retrieves an attribute node by by qualified name and namespace URI.
  • 1038 *
  • 1039 * @param nodeHandle int Handle of the node upon which to look up this attribute..
  • 1040 * @param namespaceURI The namespace URI of the attribute to
  • 1041 * retrieve, or null.
  • 1042 * @param name The local name of the attribute to
  • 1043 * retrieve.
  • 1044 * @return The attribute node handle with the specified name (
  • 1045 * <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
  • 1046 * attribute.
  • 1047 */
  • 1048 public abstract int getAttributeNode(int nodeHandle, String namespaceURI,
  • 1049 String name);
  • 1050
  • 1051 /**
  • 1052 * Given a node handle, get the index of the node's first attribute.
  • 1053 *
  • 1054 * @param nodeHandle int Handle of the node.
  • 1055 * @return Handle of first attribute, or DTM.NULL to indicate none exists.
  • 1056 */
  • 1057 public int getFirstAttribute(int nodeHandle)
  • 1058 {
  • 1059 int nodeID = makeNodeIdentity(nodeHandle);
  • 1060
  • 1061 return makeNodeHandle(getFirstAttributeIdentity(nodeID));
  • 1062 }
  • 1063
  • 1064 /**
  • 1065 * Given a node identity, get the index of the node's first attribute.
  • 1066 *
  • 1067 * @param identity int identity of the node.
  • 1068 * @return Identity of first attribute, or DTM.NULL to indicate none exists.
  • 1069 */
  • 1070 protected int getFirstAttributeIdentity(int identity) {
  • 1071 int type = _type(identity);
  • 1072
  • 1073 if (DTM.ELEMENT_NODE == type)
  • 1074 {
  • 1075 // Assume that attributes and namespaces immediately follow the element.
  • 1076 while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
  • 1077 {
  • 1078
  • 1079 // Assume this can not be null.
  • 1080 type = _type(identity);
  • 1081
  • 1082 if (type == DTM.ATTRIBUTE_NODE)
  • 1083 {
  • 1084 return identity;
  • 1085 }
  • 1086 else if (DTM.NAMESPACE_NODE != type)
  • 1087 {
  • 1088 break;
  • 1089 }
  • 1090 }
  • 1091 }
  • 1092
  • 1093 return DTM.NULL;
  • 1094 }
  • 1095
  • 1096 /**
  • 1097 * Given a node handle and an expanded type ID, get the index of the node's
  • 1098 * attribute of that type, if any.
  • 1099 *
  • 1100 * @param nodeHandle int Handle of the node.
  • 1101 * @param attType int expanded type ID of the required attribute.
  • 1102 * @return Handle of attribute of the required type, or DTM.NULL to indicate
  • 1103 * none exists.
  • 1104 */
  • 1105 protected int getTypedAttribute(int nodeHandle, int attType) {
  • 1106 int type = getNodeType(nodeHandle);
  • 1107 if (DTM.ELEMENT_NODE == type) {
  • 1108 int identity = makeNodeIdentity(nodeHandle);
  • 1109
  • 1110 while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
  • 1111 {
  • 1112 type = _type(identity);
  • 1113
  • 1114 if (type == DTM.ATTRIBUTE_NODE)
  • 1115 {
  • 1116 if (_exptype(identity) == attType) return makeNodeHandle(identity);
  • 1117 }
  • 1118 else if (DTM.NAMESPACE_NODE != type)
  • 1119 {
  • 1120 break;
  • 1121 }
  • 1122 }
  • 1123 }
  • 1124
  • 1125 return DTM.NULL;
  • 1126 }
  • 1127
  • 1128 /**
  • 1129 * Given a node handle, advance to its next sibling.
  • 1130 * If not yet resolved, waits for more nodes to be added to the document and
  • 1131 * tries again.
  • 1132 * @param nodeHandle int Handle of the node.
  • 1133 * @return int Node-number of next sibling,
  • 1134 * or DTM.NULL to indicate none exists.
  • 1135 */
  • 1136 public int getNextSibling(int nodeHandle)
  • 1137 {
  • 1138 if (nodeHandle == DTM.NULL)
  • 1139 return DTM.NULL;
  • 1140 return makeNodeHandle(_nextsib(makeNodeIdentity(nodeHandle)));
  • 1141 }
  • 1142
  • 1143 /**
  • 1144 * Given a node handle, advance to its next sibling.
  • 1145 * If not yet resolved, waits for more nodes to be added to the document and
  • 1146 * tries again.
  • 1147 * @param nodeHandle int Handle of the node.
  • 1148 * @return int Node-number of next sibling,
  • 1149 * or DTM.NULL to indicate none exists.
  • 1150 */
  • 1151 public int getTypedNextSibling(int nodeHandle, int nodeType)
  • 1152 {
  • 1153 if (nodeHandle == DTM.NULL)
  • 1154 return DTM.NULL;
  • 1155 int node = makeNodeIdentity(nodeHandle);
  • 1156 int eType;
  • 1157 while ((node = _nextsib(node)) != DTM.NULL &&
  • 1158 ((eType = _exptype(node)) != nodeType &&
  • 1159 m_expandedNameTable.getType(eType)!= nodeType));
  • 1160 //_type(node) != nodeType));
  • 1161
  • 1162 return (node == DTM.NULL ? DTM.NULL : makeNodeHandle(node));
  • 1163 }
  • 1164
  • 1165 /**
  • 1166 * Given a node handle, find its preceeding sibling.
  • 1167 * WARNING: DTM is asymmetric; this operation is resolved by search, and is
  • 1168 * relatively expensive.
  • 1169 *
  • 1170 * @param nodeHandle the id of the node.
  • 1171 * @return int Node-number of the previous sib,
  • 1172 * or DTM.NULL to indicate none exists.
  • 1173 */
  • 1174 public int getPreviousSibling(int nodeHandle)
  • 1175 {
  • 1176 if (nodeHandle == DTM.NULL)
  • 1177 return DTM.NULL;
  • 1178
  • 1179 if (m_prevsib != null)
  • 1180 return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle)));
  • 1181 else
  • 1182 {
  • 1183 // If the previous sibling array is not built, we get at
  • 1184 // the previous sibling using the parent, firstch and
  • 1185 // nextsib arrays.
  • 1186 int nodeID = makeNodeIdentity(nodeHandle);
  • 1187 int parent = _parent(nodeID);
  • 1188 int node = _firstch(parent);
  • 1189 int result = DTM.NULL;
  • 1190 while (node != nodeID)
  • 1191 {
  • 1192 result = node;
  • 1193 node = _nextsib(node);
  • 1194 }
  • 1195 return makeNodeHandle(result);
  • 1196 }
  • 1197 }
  • 1198
  • 1199 /**
  • 1200 * Given a node handle, advance to the next attribute.
  • 1201 * If an attr, we advance to
  • 1202 * the next attr on the same node. If not an attribute, we return NULL.
  • 1203 *
  • 1204 * @param nodeHandle int Handle of the node.
  • 1205 * @return int DTM node-number of the resolved attr,
  • 1206 * or DTM.NULL to indicate none exists.
  • 1207 */
  • 1208 public int getNextAttribute(int nodeHandle) {
  • 1209 int nodeID = makeNodeIdentity(nodeHandle);
  • 1210
  • 1211 if (_type(nodeID) == DTM.ATTRIBUTE_NODE) {
  • 1212 return makeNodeHandle(getNextAttributeIdentity(nodeID));
  • 1213 }
  • 1214
  • 1215 return DTM.NULL;
  • 1216 }
  • 1217
  • 1218 /**
  • 1219 * Given a node identity for an attribute, advance to the next attribute.
  • 1220 *
  • 1221 * @param identity int identity of the attribute node. This
  • 1222 * <strong>must</strong> be an attribute node.
  • 1223 *
  • 1224 * @return int DTM node-identity of the resolved attr,
  • 1225 * or DTM.NULL to indicate none exists.
  • 1226 *
  • 1227 */
  • 1228 protected int getNextAttributeIdentity(int identity) {
  • 1229 // Assume that attributes and namespace nodes immediately follow the element
  • 1230 while (DTM.NULL != (identity = getNextNodeIdentity(identity))) {
  • 1231 int type = _type(identity);
  • 1232
  • 1233 if (type == DTM.ATTRIBUTE_NODE) {
  • 1234 return identity;
  • 1235 } else if (type != DTM.NAMESPACE_NODE) {
  • 1236 break;
  • 1237 }
  • 1238 }
  • 1239
  • 1240 return DTM.NULL;
  • 1241 }
  • 1242
  • 1243 /** Lazily created namespace lists. */
  • 1244 private Vector m_namespaceLists = null; // on demand
  • 1245
  • 1246
  • 1247 /** Build table of namespace declaration
  • 1248 * locations during DTM construction. Table is a Vector of
  • 1249 * SuballocatedIntVectors containing the namespace node HANDLES declared at
  • 1250 * that ID, plus an SuballocatedIntVector of the element node INDEXES at which
  • 1251 * these declarations appeared.
  • 1252 *
  • 1253 * NOTE: Since this occurs during model build, nodes will be encountered
  • 1254 * in doucment order and thus the table will be ordered by element,
  • 1255 * permitting binary-search as a possible retrieval optimization.
  • 1256 *
  • 1257 * %REVIEW% Directly managed arrays rather than vectors?
  • 1258 * %REVIEW% Handles or IDs? Given usage, I think handles.
  • 1259 * */
  • 1260 protected void declareNamespaceInContext(int elementNodeIndex,int namespaceNodeIndex)
  • 1261 {
  • 1262 SuballocatedIntVector nsList=null;
  • 1263 if(m_namespaceDeclSets==null)
  • 1264 {
  • 1265
  • 1266 // First
  • 1267 m_namespaceDeclSetElements=new SuballocatedIntVector(32);
  • 1268 m_namespaceDeclSetElements.addElement(elementNodeIndex);
  • 1269 m_namespaceDeclSets=new Vector();
  • 1270 nsList=new SuballocatedIntVector(32);
  • 1271 m_namespaceDeclSets.addElement(nsList);
  • 1272 }
  • 1273 else
  • 1274 {
  • 1275 // Most recent. May be -1 (none) if DTM was pruned.
  • 1276 // %OPT% Is there a lastElement() method? Should there be?
  • 1277 int last=m_namespaceDeclSetElements.size()-1;
  • 1278
  • 1279 if(last>=0 && elementNodeIndex==m_namespaceDeclSetElements.elementAt(last))
  • 1280 {
  • 1281 nsList=(SuballocatedIntVector)m_namespaceDeclSets.elementAt(last);
  • 1282 }
  • 1283 }
  • 1284 if(nsList==null)
  • 1285 {
  • 1286 m_namespaceDeclSetElements.addElement(elementNodeIndex);
  • 1287
  • 1288 SuballocatedIntVector inherited =
  • 1289 findNamespaceContext(_parent(elementNodeIndex));
  • 1290
  • 1291 if (inherited!=null) {
  • 1292 // %OPT% Count-down might be faster, but debuggability may
  • 1293 // be better this way, and if we ever decide we want to
  • 1294 // keep this ordered by expanded-type...
  • 1295 int isize=inherited.size();
  • 1296
  • 1297 // Base the size of a new namespace list on the
  • 1298 // size of the inherited list - but within reason!
  • 1299 nsList=new SuballocatedIntVector(Math.max(Math.min(isize+16,2048),
  • 1300 32));
  • 1301
  • 1302 for(int i=0;i<isize;++i)
  • 1303 {
  • 1304 nsList.addElement(inherited.elementAt(i));
  • 1305 }
  • 1306 } else {
  • 1307 nsList=new SuballocatedIntVector(32);
  • 1308 }
  • 1309
  • 1310 m_namespaceDeclSets.addElement(nsList);
  • 1311 }
  • 1312
  • 1313 // Handle overwriting inherited.
  • 1314 // %OPT% Keep sorted? (By expanded-name rather than by doc order...)
  • 1315 // Downside: Would require insertElementAt if not found,
  • 1316 // which has recopying costs. But these are generally short lists...
  • 1317 int newEType=_exptype(namespaceNodeIndex);
  • 1318
  • 1319 for(int i=nsList.size()-1;i>=0;--i)
  • 1320 {
  • 1321 if(newEType==getExpandedTypeID(nsList.elementAt(i)))
  • 1322 {
  • 1323 nsList.setElementAt(makeNodeHandle(namespaceNodeIndex),i);
  • 1324 return;
  • 1325 }
  • 1326 }
  • 1327 nsList.addElement(makeNodeHandle(namespaceNodeIndex));
  • 1328 }
  • 1329
  • 1330 /** Retrieve list of namespace declaration locations
  • 1331 * active at this node. List is an SuballocatedIntVector whose
  • 1332 * entries are the namespace node HANDLES declared at that ID.
  • 1333 *
  • 1334 * %REVIEW% Directly managed arrays rather than vectors?
  • 1335 * %REVIEW% Handles or IDs? Given usage, I think handles.
  • 1336 * */
  • 1337 protected SuballocatedIntVector findNamespaceContext(int elementNodeIndex)
  • 1338 {
  • 1339 if (null!=m_namespaceDeclSetElements)
  • 1340 {
  • 1341 // %OPT% Is binary-search really saving us a lot versus linear?
  • 1342 // (... It may be, in large docs with many NS decls.)
  • 1343 int wouldBeAt=findInSortedSuballocatedIntVector(m_namespaceDeclSetElements,
  • 1344 elementNodeIndex);
  • 1345 if(wouldBeAt>=0) // Found it
  • 1346 return (SuballocatedIntVector) m_namespaceDeclSets.elementAt(wouldBeAt);
  • 1347 if(wouldBeAt == -1) // -1-wouldbeat == 0
  • 1348 return null; // Not after anything; definitely not found
  • 1349
  • 1350 // Not found, but we know where it should have been.
  • 1351 // Search back until we find an ancestor or run out.
  • 1352 wouldBeAt=-1-wouldBeAt;
  • 1353
  • 1354 // Decrement wouldBeAt to find last possible ancestor
  • 1355 int candidate=m_namespaceDeclSetElements.elementAt(-- wouldBeAt);
  • 1356 int ancestor=_parent(elementNodeIndex);
  • 1357
  • 1358 // Special case: if the candidate is before the given node, and
  • 1359 // is in the earliest possible position in the document, it
  • 1360 // must have the namespace declarations we're interested in.
  • 1361 if (wouldBeAt == 0 && candidate < ancestor) {
  • 1362 int rootHandle = getDocumentRoot(makeNodeHandle(elementNodeIndex));
  • 1363 int rootID = makeNodeIdentity(rootHandle);
  • 1364 int uppermostNSCandidateID;
  • 1365
  • 1366 if (getNodeType(rootHandle) == DTM.DOCUMENT_NODE) {
  • 1367 int ch = _firstch(rootID);
  • 1368 uppermostNSCandidateID = (ch != DTM.NULL) ? ch : rootID;
  • 1369 } else {
  • 1370 uppermostNSCandidateID = rootID;
  • 1371 }
  • 1372
  • 1373 if (candidate == uppermostNSCandidateID) {
  • 1374 return (SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
  • 1375 }
  • 1376 }
  • 1377
  • 1378 while(wouldBeAt>=0 && ancestor>0)
  • 1379 {
  • 1380 if (candidate==ancestor) {
  • 1381 // Found ancestor in list
  • 1382 return (SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
  • 1383 } else if (candidate<ancestor) {
  • 1384 // Too deep in tree
  • 1385 do {
  • 1386 ancestor=_parent(ancestor);
  • 1387 } while (candidate < ancestor);
  • 1388 } else if(wouldBeAt > 0){
  • 1389 // Too late in list
  • 1390 candidate=m_namespaceDeclSetElements.elementAt(--wouldBeAt);
  • 1391 }
  • 1392 else
  • 1393 break;
  • 1394 }
  • 1395 }
  • 1396
  • 1397 return null; // No namespaces known at this node
  • 1398 }
  • 1399
  • 1400 /**
  • 1401 * Subroutine: Locate the specified node within
  • 1402 * m_namespaceDeclSetElements, or the last element which
  • 1403 * preceeds it in document order
  • 1404 *
  • 1405 * %REVIEW% Inlne this into findNamespaceContext? Create SortedSuballocatedIntVector type?
  • 1406 *
  • 1407 * @return If positive or zero, the index of the found item.
  • 1408 * If negative, index of the point at which it would have appeared,
  • 1409 * encoded as -1-index and hence reconvertable by subtracting
  • 1410 * it from -1. (Encoding because I don't want to recompare the strings
  • 1411 * but don't want to burn bytes on a datatype to hold a flagged value.)
  • 1412 */
  • 1413 protected int findInSortedSuballocatedIntVector(SuballocatedIntVector vector, int lookfor)
  • 1414 {
  • 1415 // Binary search
  • 1416 int i = 0;
  • 1417 if(vector != null) {
  • 1418 int first = 0;
  • 1419 int last = vector.size() - 1;
  • 1420
  • 1421 while (first <= last) {
  • 1422 i = (first + last) / 2;
  • 1423 int test = lookfor-vector.elementAt(i);
  • 1424 if(test == 0) {
  • 1425 return i; // Name found
  • 1426 }
  • 1427 else if (test < 0) {
  • 1428 last = i - 1; // looked too late
  • 1429 }
  • 1430 else {
  • 1431 first = i + 1; // looked ot early
  • 1432 }
  • 1433 }
  • 1434
  • 1435 if (first > i) {
  • 1436 i = first; // Clean up at loop end
  • 1437 }
  • 1438 }
  • 1439
  • 1440 return -1 - i; // not-found has to be encoded.
  • 1441 }
  • 1442
  • 1443
  • 1444 /**
  • 1445 * Given a node handle, get the index of the node's first child.
  • 1446 * If not yet resolved, waits for more nodes to be added to the document and
  • 1447 * tries again
  • 1448 *
  • 1449 * @param nodeHandle handle to node, which should probably be an element
  • 1450 * node, but need not be.
  • 1451 *
  • 1452 * @param inScope true if all namespaces in scope should be returned,
  • 1453 * false if only the namespace declarations should be
  • 1454 * returned.
  • 1455 * @return handle of first namespace, or DTM.NULL to indicate none exists.
  • 1456 */
  • 1457 public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
  • 1458 {
  • 1459 if(inScope)
  • 1460 {
  • 1461 int identity = makeNodeIdentity(nodeHandle);
  • 1462 if (_type(identity) == DTM.ELEMENT_NODE)
  • 1463 {
  • 1464 SuballocatedIntVector nsContext=findNamespaceContext(identity);
  • 1465 if(nsContext==null || nsContext.size()<1)
  • 1466 return NULL;
  • 1467
  • 1468 return nsContext.elementAt(0);
  • 1469 }
  • 1470 else
  • 1471 return NULL;
  • 1472 }
  • 1473 else
  • 1474 {
  • 1475 // Assume that attributes and namespaces immediately
  • 1476 // follow the element.
  • 1477 //
  • 1478 // %OPT% Would things be faster if all NS nodes were built
  • 1479 // before all Attr nodes? Some costs at build time for 2nd
  • 1480 // pass...
  • 1481 int identity = makeNodeIdentity(nodeHandle);
  • 1482 if (_type(identity) == DTM.ELEMENT_NODE)
  • 1483 {
  • 1484 while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
  • 1485 {
  • 1486 int type = _type(identity);
  • 1487 if (type == DTM.NAMESPACE_NODE)
  • 1488 return makeNodeHandle(identity);
  • 1489 else if (DTM.ATTRIBUTE_NODE != type)
  • 1490 break;
  • 1491 }
  • 1492 return NULL;
  • 1493 }
  • 1494 else
  • 1495 return NULL;
  • 1496 }
  • 1497 }
  • 1498
  • 1499 /**
  • 1500 * Given a namespace handle, advance to the next namespace.
  • 1501 *
  • 1502 * @param baseHandle handle to original node from where the first namespace
  • 1503 * was relative to (needed to return nodes in document order).
  • 1504 * @param nodeHandle A namespace handle for which we will find the next node.
  • 1505 * @param inScope true if all namespaces that are in scope should be processed,
  • 1506 * otherwise just process the nodes in the given element handle.
  • 1507 * @return handle of next namespace, or DTM.NULL to indicate none exists.
  • 1508 */
  • 1509 public int getNextNamespaceNode(int baseHandle, int nodeHandle,
  • 1510 boolean inScope)
  • 1511 {
  • 1512 if(inScope)
  • 1513 {
  • 1514 //Since we've been given the base, try direct lookup
  • 1515 //(could look from nodeHandle but this is at least one
  • 1516 //comparison/get-parent faster)
  • 1517 //SuballocatedIntVector nsContext=findNamespaceContext(nodeHandle & m_mask);
  • 1518
  • 1519 SuballocatedIntVector nsContext=findNamespaceContext(makeNodeIdentity(baseHandle));
  • 1520
  • 1521 if(nsContext==null)
  • 1522 return NULL;
  • 1523 int i=1 + nsContext.indexOf(nodeHandle);
  • 1524 if(i<=0 || i==nsContext.size())
  • 1525 return NULL;
  • 1526
  • 1527 return nsContext.elementAt(i);
  • 1528 }
  • 1529 else
  • 1530 {
  • 1531 // Assume that attributes and namespace nodes immediately follow the element.
  • 1532 int identity = makeNodeIdentity(nodeHandle);
  • 1533 while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
  • 1534 {
  • 1535 int type = _type(identity);
  • 1536 if (type == DTM.NAMESPACE_NODE)
  • 1537 {
  • 1538 return makeNodeHandle(identity);
  • 1539 }
  • 1540 else if (type != DTM.ATTRIBUTE_NODE)
  • 1541 {
  • 1542 break;
  • 1543 }
  • 1544 }
  • 1545 }
  • 1546 return DTM.NULL;
  • 1547 }
  • 1548
  • 1549 /**
  • 1550 * Given a node handle, find its parent node.
  • 1551 *
  • 1552 * @param nodeHandle the id of the node.
  • 1553 * @return int Node-number of parent,
  • 1554 * or DTM.NULL to indicate none exists.
  • 1555 */
  • 1556 public int getParent(int nodeHandle)
  • 1557 {
  • 1558
  • 1559 int identity = makeNodeIdentity(nodeHandle);
  • 1560
  • 1561 if (identity > 0)
  • 1562 return makeNodeHandle(_parent(identity));
  • 1563 else
  • 1564 return DTM.NULL;
  • 1565 }
  • 1566
  • 1567 /**
  • 1568 * Find the Document node handle for the document currently under construction.
  • 1569 * PLEASE NOTE that most people should use getOwnerDocument(nodeHandle) instead;
  • 1570 * this version of the operation is primarily intended for use during negotiation
  • 1571 * with the DTM Manager.
  • 1572 *
  • 1573 * @return int Node handle of document, which should always be valid.
  • 1574 */
  • 1575 public int getDocument()
  • 1576 {
  • 1577 return m_dtmIdent.elementAt(0); // makeNodeHandle(0)
  • 1578 }
  • 1579
  • 1580 /**
  • 1581 * Given a node handle, find the owning document node. This has the exact
  • 1582 * same semantics as the DOM Document method of the same name, in that if
  • 1583 * the nodeHandle is a document node, it will return NULL.
  • 1584 *
  • 1585 * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM
  • 1586 * binding layer. Included here as a convenience function and to
  • 1587 * aid porting of DOM code to DTM.</p>
  • 1588 *
  • 1589 * @param nodeHandle the id of the node.
  • 1590 * @return int Node handle of owning document, or -1 if the node was a Docment
  • 1591 */
  • 1592 public int getOwnerDocument(int nodeHandle)
  • 1593 {
  • 1594
  • 1595 if (DTM.DOCUMENT_NODE == getNodeType(nodeHandle))
  • 1596 return DTM.NULL;
  • 1597
  • 1598 return getDocumentRoot(nodeHandle);
  • 1599 }
  • 1600
  • 1601 /**
  • 1602 * Given a node handle, find the owning document node. Unlike the DOM,
  • 1603 * this considers the owningDocument of a Document to be itself.
  • 1604 *
  • 1605 * @param nodeHandle the id of the node.
  • 1606 * @return int Node handle of owning document, or the nodeHandle if it is
  • 1607 * a Document.
  • 1608 */
  • 1609 public int getDocumentRoot(int nodeHandle)
  • 1610 {
  • 1611 return getManager().getDTM(nodeHandle).getDocument();
  • 1612 }
  • 1613
  • 1614 /**
  • 1615 * Get the string-value of a node as a String object
  • 1616 * (see http://www.w3.org/TR/xpath#data-model
  • 1617 * for the definition of a node's string-value).
  • 1618 *
  • 1619 * @param nodeHandle The node ID.
  • 1620 *
  • 1621 * @return A string object that represents the string-value of the given node.
  • 1622 */
  • 1623 public abstract XMLString getStringValue(int nodeHandle);
  • 1624
  • 1625 /**
  • 1626 * Get number of character array chunks in
  • 1627 * the string-value of a node.
  • 1628 * (see http://www.w3.org/TR/xpath#data-model
  • 1629 * for the definition of a node's string-value).
  • 1630 * Note that a single text node may have multiple text chunks.
  • 1631 *
  • 1632 * @param nodeHandle The node ID.
  • 1633 *
  • 1634 * @return number of character array chunks in
  • 1635 * the string-value of a node.
  • 1636 */
  • 1637 public int getStringValueChunkCount(int nodeHandle)
  • 1638 {
  • 1639
  • 1640 // %TBD%
  • 1641 error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//("getStringValueChunkCount not yet supported!");
  • 1642
  • 1643 return 0;
  • 1644 }
  • 1645
  • 1646 /**
  • 1647 * Get a character array chunk in the string-value of a node.
  • 1648 * (see http://www.w3.org/TR/xpath#data-model
  • 1649 * for the definition of a node's string-value).
  • 1650 * Note that a single text node may have multiple text chunks.
  • 1651 *
  • 1652 * @param nodeHandle The node ID.
  • 1653 * @param chunkIndex Which chunk to get.
  • 1654 * @param startAndLen An array of 2 where the start position and length of
  • 1655 * the chunk will be returned.
  • 1656 *
  • 1657 * @return The character array reference where the chunk occurs.
  • 1658 */
  • 1659 public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
  • 1660 int[] startAndLen)
  • 1661 {
  • 1662
  • 1663 // %TBD%
  • 1664 error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"getStringValueChunk not yet supported!");
  • 1665
  • 1666 return null;
  • 1667 }
  • 1668
  • 1669 /**
  • 1670 * Given a node handle, return an ID that represents the node's expanded name.
  • 1671 *
  • 1672 * @param nodeHandle The handle to the node in question.
  • 1673 *
  • 1674 * @return the expanded-name id of the node.
  • 1675 */
  • 1676 public int getExpandedTypeID(int nodeHandle)
  • 1677 {
  • 1678 // %REVIEW% This _should_ only be null if someone asked the wrong DTM about the node...
  • 1679 // which one would hope would never happen...
  • 1680 int id=makeNodeIdentity(nodeHandle);
  • 1681 if(id==NULL)
  • 1682 return NULL;
  • 1683 return _exptype(id);
  • 1684 }
  • 1685
  • 1686 /**
  • 1687 * Given an expanded name, return an ID. If the expanded-name does not
  • 1688 * exist in the internal tables, the entry will be created, and the ID will
  • 1689 * be returned. Any additional nodes that are created that have this
  • 1690 * expanded name will use this ID.
  • 1691 *
  • 1692 * @param type The simple type, i.e. one of ELEMENT, ATTRIBUTE, etc.
  • 1693 *
  • 1694 * @param namespace The namespace URI, which may be null, may be an empty
  • 1695 * string (which will be the same as null), or may be a
  • 1696 * namespace URI.
  • 1697 * @param localName The local name string, which must be a valid
  • 1698 * <a href="http://www.w3.org/TR/REC-xml-names/">NCName</a>.
  • 1699 *
  • 1700 * @return the expanded-name id of the node.
  • 1701 */
  • 1702 public int getExpandedTypeID(String namespace, String localName, int type)
  • 1703 {
  • 1704
  • 1705 ExpandedNameTable ent = m_expandedNameTable;
  • 1706
  • 1707 return ent.getExpandedTypeID(namespace, localName, type);
  • 1708 }
  • 1709
  • 1710 /**
  • 1711 * Given an expanded-name ID, return the local name part.
  • 1712 *
  • 1713 * @param expandedNameID an ID that represents an expanded-name.
  • 1714 * @return String Local name of this node.
  • 1715 */
  • 1716 public String getLocalNameFromExpandedNameID(int expandedNameID)
  • 1717 {
  • 1718 return m_expandedNameTable.getLocalName(expandedNameID);
  • 1719 }
  • 1720
  • 1721 /**
  • 1722 * Given an expanded-name ID, return the namespace URI part.
  • 1723 *
  • 1724 * @param expandedNameID an ID that represents an expanded-name.
  • 1725 * @return String URI value of this node's namespace, or null if no
  • 1726 * namespace was resolved.
  • 1727 */
  • 1728 public String getNamespaceFromExpandedNameID(int expandedNameID)
  • 1729 {
  • 1730 return m_expandedNameTable.getNamespace(expandedNameID);
  • 1731 }
  • 1732
  • 1733 /**
  • 1734 * Returns the namespace type of a specific node
  • 1735 * @param nodeHandle the id of the node.
  • 1736 * @return the ID of the namespace.
  • 1737 */
  • 1738 public int getNamespaceType(final int nodeHandle)
  • 1739 {
  • 1740
  • 1741 int identity = makeNodeIdentity(nodeHandle);
  • 1742 int expandedNameID = _exptype(identity);
  • 1743
  • 1744 return m_expandedNameTable.getNamespaceID(expandedNameID);
  • 1745 }
  • 1746
  • 1747 /**
  • 1748 * Given a node handle, return its DOM-style node name. This will
  • 1749 * include names such as #text or #document.
  • 1750 *
  • 1751 * @param nodeHandle the id of the node.
  • 1752 * @return String Name of this node, which may be an empty string.
  • 1753 * %REVIEW% Document when empty string is possible...
  • 1754 * %REVIEW-COMMENT% It should never be empty, should it?
  • 1755 */
  • 1756 public abstract String getNodeName(int nodeHandle);
  • 1757
  • 1758 /**
  • 1759 * Given a node handle, return the XPath node name. This should be
  • 1760 * the name as described by the XPath data model, NOT the DOM-style
  • 1761 * name.
  • 1762 *
  • 1763 * @param nodeHandle the id of the node.
  • 1764 * @return String Name of this node, which may be an empty string.
  • 1765 */
  • 1766 public String getNodeNameX(int nodeHandle)
  • 1767 {
  • 1768
  • 1769 /** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */
  • 1770 error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!");
  • 1771
  • 1772 return null;
  • 1773 }
  • 1774
  • 1775 /**
  • 1776 * Given a node handle, return its XPath-style localname.
  • 1777 * (As defined in Namespaces, this is the portion of the name after any
  • 1778 * colon character).
  • 1779 *
  • 1780 * @param nodeHandle the id of the node.
  • 1781 * @return String Local name of this node.
  • 1782 */
  • 1783 public abstract String getLocalName(int nodeHandle);
  • 1784
  • 1785 /**
  • 1786 * Given a namespace handle, return the prefix that the namespace decl is
  • 1787 * mapping.
  • 1788 * Given a node handle, return the prefix used to map to the namespace.
  • 1789 *
  • 1790 * <p> %REVIEW% Are you sure you want "" for no prefix? </p>
  • 1791 * <p> %REVIEW-COMMENT% I think so... not totally sure. -sb </p>
  • 1792 *
  • 1793 * @param nodeHandle the id of the node.
  • 1794 * @return String prefix of this node's name, or "" if no explicit
  • 1795 * namespace prefix was given.
  • 1796 */
  • 1797 public abstract String getPrefix(int nodeHandle);
  • 1798
  • 1799 /**
  • 1800 * Given a node handle, return its DOM-style namespace URI
  • 1801 * (As defined in Namespaces, this is the declared URI which this node's
  • 1802 * prefix -- or default in lieu thereof -- was mapped to.)
  • 1803 *
  • 1804 * <p>%REVIEW% Null or ""? -sb</p>
  • 1805 *
  • 1806 * @param nodeHandle the id of the node.
  • 1807 * @return String URI value of this node's namespace, or null if no
  • 1808 * namespace was resolved.
  • 1809 */
  • 1810 public abstract String getNamespaceURI(int nodeHandle);
  • 1811
  • 1812 /**
  • 1813 * Given a node handle, return its node value. This is mostly
  • 1814 * as defined by the DOM, but may ignore some conveniences.
  • 1815 * <p>
  • 1816 *
  • 1817 * @param nodeHandle The node id.
  • 1818 * @return String Value of this node, or null if not
  • 1819 * meaningful for this node type.
  • 1820 */
  • 1821 public abstract String getNodeValue(int nodeHandle);
  • 1822
  • 1823 /**
  • 1824 * Given a node handle, return its DOM-style node type.
  • 1825 * <p>
  • 1826 * %REVIEW% Generally, returning short is false economy. Return int?
  • 1827 * %REVIEW% Make assumption that node has already arrived. Is OK?
  • 1828 *
  • 1829 * @param nodeHandle The node id.
  • 1830 * @return int Node type, as per the DOM's Node._NODE constants.
  • 1831 */
  • 1832 public short getNodeType(int nodeHandle)
  • 1833 {
  • 1834 if (nodeHandle == DTM.NULL)
  • 1835 return DTM.NULL;
  • 1836 return m_expandedNameTable.getType(_exptype(makeNodeIdentity(nodeHandle)));
  • 1837 }
  • 1838
  • 1839 /**
  • 1840 * Get the depth level of this node in the tree (equals 1 for
  • 1841 * a parentless node).
  • 1842 *
  • 1843 * @param nodeHandle The node id.
  • 1844 * @return the number of ancestors, plus one
  • 1845 * @xsl.usage internal
  • 1846 */
  • 1847 public short getLevel(int nodeHandle)
  • 1848 {
  • 1849 // Apparently, the axis walker stuff requires levels to count from 1.
  • 1850 int identity = makeNodeIdentity(nodeHandle);
  • 1851 return (short) (_level(identity) + 1);
  • 1852 }
  • 1853
  • 1854 /**
  • 1855 * Get the identity of this node in the tree
  • 1856 *
  • 1857 * @param nodeHandle The node handle.
  • 1858 * @return the node identity
  • 1859 * @xsl.usage internal
  • 1860 */
  • 1861 public int getNodeIdent(int nodeHandle)
  • 1862 {
  • 1863 /*if (nodeHandle != DTM.NULL)
  • 1864 return nodeHandle & m_mask;
  • 1865 else
  • 1866 return DTM.NULL;*/
  • 1867
  • 1868 return makeNodeIdentity(nodeHandle);
  • 1869 }
  • 1870
  • 1871 /**
  • 1872 * Get the handle of this node in the tree
  • 1873 *
  • 1874 * @param nodeId The node identity.
  • 1875 * @return the node handle
  • 1876 * @xsl.usage internal
  • 1877 */
  • 1878 public int getNodeHandle(int nodeId)
  • 1879 {
  • 1880 /*if (nodeId != DTM.NULL)
  • 1881 return nodeId | m_dtmIdent;
  • 1882 else
  • 1883 return DTM.NULL;*/
  • 1884
  • 1885 return makeNodeHandle(nodeId);
  • 1886 }
  • 1887
  • 1888 // ============== Document query functions ==============
  • 1889
  • 1890 /**
  • 1891 * Tests whether DTM DOM implementation implements a specific feature and
  • 1892 * that feature is supported by this node.
  • 1893 *
  • 1894 * @param feature The name of the feature to test.
  • 1895 * @param version This is the version number of the feature to test.
  • 1896 * If the version is not
  • 1897 * specified, supporting any version of the feature will cause the
  • 1898 * method to return <code>true</code>.
  • 1899 * @return Returns <code>true</code> if the specified feature is
  • 1900 * supported on this node, <code>false</code> otherwise.
  • 1901 */
  • 1902 public boolean isSupported(String feature, String version)
  • 1903 {
  • 1904
  • 1905 // %TBD%
  • 1906 return false;
  • 1907 }
  • 1908
  • 1909 /**
  • 1910 * Return the base URI of the document entity. If it is not known
  • 1911 * (because the document was parsed from a socket connection or from
  • 1912 * standard input, for example), the value of this property is unknown.
  • 1913 *
  • 1914 * @return the document base URI String object or null if unknown.
  • 1915 */
  • 1916 public String getDocumentBaseURI()
  • 1917 {
  • 1918 return m_documentBaseURI;
  • 1919 }
  • 1920
  • 1921 /**
  • 1922 * Set the base URI of the document entity.
  • 1923 *
  • 1924 * @param baseURI the document base URI String object or null if unknown.
  • 1925 */
  • 1926 public void setDocumentBaseURI(String baseURI)
  • 1927 {
  • 1928 m_documentBaseURI = baseURI;
  • 1929 }
  • 1930
  • 1931 /**
  • 1932 * Return the system identifier of the document entity. If
  • 1933 * it is not known, the value of this property is unknown.
  • 1934 *
  • 1935 * @param nodeHandle The node id, which can be any valid node handle.
  • 1936 * @return the system identifier String object or null if unknown.
  • 1937 */
  • 1938 public String getDocumentSystemIdentifier(int nodeHandle)
  • 1939 {
  • 1940
  • 1941 // %REVIEW% OK? -sb
  • 1942 return m_documentBaseURI;
  • 1943 }
  • 1944
  • 1945 /**
  • 1946 * Return the name of the character encoding scheme
  • 1947 * in which the document entity is expressed.
  • 1948 *
  • 1949 * @param nodeHandle The node id, which can be any valid node handle.
  • 1950 * @return the document encoding String object.
  • 1951 * @xsl.usage internal
  • 1952 */
  • 1953 public String getDocumentEncoding(int nodeHandle)
  • 1954 {
  • 1955
  • 1956 // %REVIEW% OK?? -sb
  • 1957 return "UTF-8";
  • 1958 }
  • 1959
  • 1960 /**
  • 1961 * Return an indication of the standalone status of the document,
  • 1962 * either "yes" or "no". This property is derived from the optional
  • 1963 * standalone document declaration in the XML declaration at the
  • 1964 * beginning of the document entity, and has no value if there is no
  • 1965 * standalone document declaration.
  • 1966 *
  • 1967 * @param nodeHandle The node id, which can be any valid node handle.
  • 1968 * @return the document standalone String object, either "yes", "no", or null.
  • 1969 */
  • 1970 public String getDocumentStandalone(int nodeHandle)
  • 1971 {
  • 1972 return null;
  • 1973 }
  • 1974
  • 1975 /**
  • 1976 * Return a string representing the XML version of the document. This
  • 1977 * property is derived from the XML declaration optionally present at the
  • 1978 * beginning of the document entity, and has no value if there is no XML
  • 1979 * declaration.
  • 1980 *
  • 1981 * @param documentHandle The document handle
  • 1982 *
  • 1983 * @return the document version String object.
  • 1984 */
  • 1985 public String getDocumentVersion(int documentHandle)
  • 1986 {
  • 1987 return null;
  • 1988 }
  • 1989
  • 1990 /**
  • 1991 * Return an indication of
  • 1992 * whether the processor has read the complete DTD. Its value is a
  • 1993 * boolean. If it is false, then certain properties (indicated in their
  • 1994 * descriptions below) may be unknown. If it is true, those properties
  • 1995 * are never unknown.
  • 1996 *
  • 1997 * @return <code>true</code> if all declarations were processed;
  • 1998 * <code>false</code> otherwise.
  • 1999 */
  • 2000 public boolean getDocumentAllDeclarationsProcessed()
  • 2001 {
  • 2002
  • 2003 // %REVIEW% OK?
  • 2004 return true;
  • 2005 }
  • 2006
  • 2007 /**
  • 2008 * A document type declaration information item has the following properties:
  • 2009 *
  • 2010 * 1. [system identifier] The system identifier of the external subset, if
  • 2011 * it exists. Otherwise this property has no value.
  • 2012 *
  • 2013 * @return the system identifier String object, or null if there is none.
  • 2014 */
  • 2015 public abstract String getDocumentTypeDeclarationSystemIdentifier();
  • 2016
  • 2017 /**
  • 2018 * Return the public identifier of the external subset,
  • 2019 * normalized as described in 4.2.2 External Entities [XML]. If there is
  • 2020 * no external subset or if it has no public identifier, this property
  • 2021 * has no value.
  • 2022 *
  • 2023 * @return the public identifier String object, or null if there is none.
  • 2024 */
  • 2025 public abstract String getDocumentTypeDeclarationPublicIdentifier();
  • 2026
  • 2027 /**
  • 2028 * Returns the <code>Element</code> whose <code>ID</code> is given by
  • 2029 * <code>elementId</code>. If no such element exists, returns
  • 2030 * <code>DTM.NULL</code>. Behavior is not defined if more than one element
  • 2031 * has this <code>ID</code>. Attributes (including those
  • 2032 * with the name "ID") are not of type ID unless so defined by DTD/Schema
  • 2033 * information available to the DTM implementation.
  • 2034 * Implementations that do not know whether attributes are of type ID or
  • 2035 * not are expected to return <code>DTM.NULL</code>.
  • 2036 *
  • 2037 * <p>%REVIEW% Presumably IDs are still scoped to a single document,
  • 2038 * and this operation searches only within a single document, right?
  • 2039 * Wouldn't want collisions between DTMs in the same process.</p>
  • 2040 *
  • 2041 * @param elementId The unique <code>id</code> value for an element.
  • 2042 * @return The handle of the matching element.
  • 2043 */
  • 2044 public abstract int getElementById(String elementId);
  • 2045
  • 2046 /**
  • 2047 * The getUnparsedEntityURI function returns the URI of the unparsed
  • 2048 * entity with the specified name in the same document as the context
  • 2049 * node (see [3.3 Unparsed Entities]). It returns the empty string if
  • 2050 * there is no such entity.
  • 2051 * <p>
  • 2052 * XML processors may choose to use the System Identifier (if one
  • 2053 * is provided) to resolve the entity, rather than the URI in the
  • 2054 * Public Identifier. The details are dependent on the processor, and
  • 2055 * we would have to support some form of plug-in resolver to handle
  • 2056 * this properly. Currently, we simply return the System Identifier if
  • 2057 * present, and hope that it a usable URI or that our caller can
  • 2058 * map it to one.
  • 2059 * TODO: Resolve Public Identifiers... or consider changing function name.
  • 2060 * <p>
  • 2061 * If we find a relative URI
  • 2062 * reference, XML expects it to be resolved in terms of the base URI
  • 2063 * of the document. The DOM doesn't do that for us, and it isn't
  • 2064 * entirely clear whether that should be done here; currently that's
  • 2065 * pushed up to a higher level of our application. (Note that DOM Level
  • 2066 * 1 didn't store the document's base URI.)
  • 2067 * TODO: Consider resolving Relative URIs.
  • 2068 * <p>
  • 2069 * (The DOM's statement that "An XML processor may choose to
  • 2070 * completely expand entities before the structure model is passed
  • 2071 * to the DOM" refers only to parsed entities, not unparsed, and hence
  • 2072 * doesn't affect this function.)
  • 2073 *
  • 2074 * @param name A string containing the Entity Name of the unparsed
  • 2075 * entity.
  • 2076 *
  • 2077 * @return String containing the URI of the Unparsed Entity, or an
  • 2078 * empty string if no such entity exists.
  • 2079 */
  • 2080 public abstract String getUnparsedEntityURI(String name);
  • 2081
  • 2082 // ============== Boolean methods ================
  • 2083
  • 2084 /**
  • 2085 * Return true if the xsl:strip-space or xsl:preserve-space was processed
  • 2086 * during construction of the DTM document.
  • 2087 *
  • 2088 * @return true if this DTM supports prestripping.
  • 2089 */
  • 2090 public boolean supportsPreStripping()
  • 2091 {
  • 2092 return true;
  • 2093 }
  • 2094
  • 2095 /**
  • 2096 * Figure out whether nodeHandle2 should be considered as being later
  • 2097 * in the document than nodeHandle1, in Document Order as defined
  • 2098 * by the XPath model. This may not agree with the ordering defined
  • 2099 * by other XML applications.
  • 2100 * <p>
  • 2101 * There are some cases where ordering isn't defined, and neither are
  • 2102 * the results of this function -- though we'll generally return false.
  • 2103 *
  • 2104 * @param nodeHandle1 Node handle to perform position comparison on.
  • 2105 * @param nodeHandle2 Second Node handle to perform position comparison on .
  • 2106 *
  • 2107 * @return true if node1 comes before node2, otherwise return false.
  • 2108 * You can think of this as
  • 2109 * <code>(node1.documentOrderPosition <= node2.documentOrderPosition)</code>.
  • 2110 */
  • 2111 public boolean isNodeAfter(int nodeHandle1, int nodeHandle2)
  • 2112 {
  • 2113 // These return NULL if the node doesn't belong to this document.
  • 2114 int index1 = makeNodeIdentity(nodeHandle1);
  • 2115 int index2 = makeNodeIdentity(nodeHandle2);
  • 2116
  • 2117 return index1!=NULL && index2!=NULL && index1 <= index2;
  • 2118 }
  • 2119
  • 2120 /**
  • 2121 * 2. [element content whitespace] A boolean indicating whether the
  • 2122 * character is white space appearing within element content (see [XML],
  • 2123 * 2.10 "White Space Handling"). Note that validating XML processors are
  • 2124 * required by XML 1.0 to provide this information. If there is no
  • 2125 * declaration for the containing element, this property has no value for
  • 2126 * white space characters. If no declaration has been read, but the [all
  • 2127 * declarations processed] property of the document information item is
  • 2128 * false (so there may be an unread declaration), then the value of this
  • 2129 * property is unknown for white space characters. It is always false for
  • 2130 * characters that are not white space.
  • 2131 *
  • 2132 * @param nodeHandle the node ID.
  • 2133 * @return <code>true</code> if the character data is whitespace;
  • 2134 * <code>false</code> otherwise.
  • 2135 */
  • 2136 public boolean isCharacterElementContentWhitespace(int nodeHandle)
  • 2137 {
  • 2138
  • 2139 // %TBD%
  • 2140 return false;
  • 2141 }
  • 2142
  • 2143 /**
  • 2144 * 10. [all declarations processed] This property is not strictly speaking
  • 2145 * part of the infoset of the document. Rather it is an indication of
  • 2146 * whether the processor has read the complete DTD. Its value is a
  • 2147 * boolean. If it is false, then certain properties (indicated in their
  • 2148 * descriptions below) may be unknown. If it is true, those properties
  • 2149 * are never unknown.
  • 2150 *
  • 2151 * @param documentHandle A node handle that must identify a document.
  • 2152 * @return <code>true</code> if all declarations were processed;
  • 2153 * <code>false</code> otherwise.
  • 2154 */
  • 2155 public boolean isDocumentAllDeclarationsProcessed(int documentHandle)
  • 2156 {
  • 2157 return true;
  • 2158 }
  • 2159
  • 2160 /**
  • 2161 * 5. [specified] A flag indicating whether this attribute was actually
  • 2162 * specified in the start-tag of its element, or was defaulted from the
  • 2163 * DTD.
  • 2164 *
  • 2165 * @param attributeHandle The attribute handle in question.
  • 2166 *
  • 2167 * @return <code>true</code> if the attribute was specified;
  • 2168 * <code>false</code> if it was defaulted.
  • 2169 */
  • 2170 public abstract boolean isAttributeSpecified(int attributeHandle);
  • 2171
  • 2172 // ========== Direct SAX Dispatch, for optimization purposes ========
  • 2173
  • 2174 /**
  • 2175 * Directly call the
  • 2176 * characters method on the passed ContentHandler for the
  • 2177 * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
  • 2178 * for the definition of a node's string-value). Multiple calls to the
  • 2179 * ContentHandler's characters methods may well occur for a single call to
  • 2180 * this method.
  • 2181 *
  • 2182 * @param nodeHandle The node ID.
  • 2183 * @param ch A non-null reference to a ContentHandler.
  • 2184 * @param normalize true if the content should be normalized according to
  • 2185 * the rules for the XPath
  • 2186 * <a href="http://www.w3.org/TR/xpath#function-normalize-space">normalize-space</a>
  • 2187 * function.
  • 2188 *
  • 2189 * @throws org.xml.sax.SAXException
  • 2190 */
  • 2191 public abstract void dispatchCharactersEvents(
  • 2192 int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
  • 2193 throws org.xml.sax.SAXException;
  • 2194
  • 2195 /**
  • 2196 * Directly create SAX parser events from a subtree.
  • 2197 *
  • 2198 * @param nodeHandle The node ID.
  • 2199 * @param ch A non-null reference to a ContentHandler.
  • 2200 *
  • 2201 * @throws org.xml.sax.SAXException
  • 2202 */
  • 2203 public abstract void dispatchToEvents(
  • 2204 int nodeHandle, org.xml.sax.ContentHandler ch)
  • 2205 throws org.xml.sax.SAXException;
  • 2206
  • 2207 /**
  • 2208 * Return an DOM node for the given node.
  • 2209 *
  • 2210 * @param nodeHandle The node ID.
  • 2211 *
  • 2212 * @return A node representation of the DTM node.
  • 2213 */
  • 2214 public org.w3c.dom.Node getNode(int nodeHandle)
  • 2215 {
  • 2216 return new DTMNodeProxy(this, nodeHandle);
  • 2217 }
  • 2218
  • 2219 // ==== Construction methods (may not be supported by some implementations!) =====
  • 2220
  • 2221 /**
  • 2222 * Append a child to the end of the document. Please note that the node
  • 2223 * is always cloned if it is owned by another document.
  • 2224 *
  • 2225 * <p>%REVIEW% "End of the document" needs to be defined more clearly.
  • 2226 * Does it become the last child of the Document? Of the root element?</p>
  • 2227 *
  • 2228 * @param newChild Must be a valid new node handle.
  • 2229 * @param clone true if the child should be cloned into the document.
  • 2230 * @param cloneDepth if the clone argument is true, specifies that the
  • 2231 * clone should include all it's children.
  • 2232 */
  • 2233 public void appendChild(int newChild, boolean clone, boolean cloneDepth)
  • 2234 {
  • 2235 error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendChild not yet supported!");
  • 2236 }
  • 2237
  • 2238 /**
  • 2239 * Append a text node child that will be constructed from a string,
  • 2240 * to the end of the document.
  • 2241 *
  • 2242 * <p>%REVIEW% "End of the document" needs to be defined more clearly.
  • 2243 * Does it become the last child of the Document? Of the root element?</p>
  • 2244 *
  • 2245 * @param str Non-null reverence to a string.
  • 2246 */
  • 2247 public void appendTextChild(String str)
  • 2248 {
  • 2249 error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendTextChild not yet supported!");
  • 2250 }
  • 2251
  • 2252 /**
  • 2253 * Simple error for asserts and the like.
  • 2254 *
  • 2255 * @param msg Error message to report.
  • 2256 */
  • 2257 protected void error(String msg)
  • 2258 {
  • 2259 throw new DTMException(msg);
  • 2260 }
  • 2261
  • 2262 /**
  • 2263 * Find out whether or not to strip whispace nodes.
  • 2264 *
  • 2265 *
  • 2266 * @return whether or not to strip whispace nodes.
  • 2267 */
  • 2268 protected boolean getShouldStripWhitespace()
  • 2269 {
  • 2270 return m_shouldStripWS;
  • 2271 }
  • 2272
  • 2273 /**
  • 2274 * Set whether to strip whitespaces and push in current value of
  • 2275 * m_shouldStripWS in m_shouldStripWhitespaceStack.
  • 2276 *
  • 2277 * @param shouldStrip Flag indicating whether to strip whitespace nodes
  • 2278 */
  • 2279 protected void pushShouldStripWhitespace(boolean shouldStrip)
  • 2280 {
  • 2281
  • 2282 m_shouldStripWS = shouldStrip;
  • 2283
  • 2284 if (null != m_shouldStripWhitespaceStack)
  • 2285 m_shouldStripWhitespaceStack.push(shouldStrip);
  • 2286 }
  • 2287
  • 2288 /**
  • 2289 * Set whether to strip whitespaces at this point by popping out
  • 2290 * m_shouldStripWhitespaceStack.
  • 2291 *
  • 2292 */
  • 2293 protected void popShouldStripWhitespace()
  • 2294 {
  • 2295 if (null != m_shouldStripWhitespaceStack)
  • 2296 m_shouldStripWS = m_shouldStripWhitespaceStack.popAndTop();
  • 2297 }
  • 2298
  • 2299 /**
  • 2300 * Set whether to strip whitespaces and set the top of the stack to
  • 2301 * the current value of m_shouldStripWS.
  • 2302 *
  • 2303 *
  • 2304 * @param shouldStrip Flag indicating whether to strip whitespace nodes
  • 2305 */
  • 2306 protected void setShouldStripWhitespace(boolean shouldStrip)
  • 2307 {
  • 2308
  • 2309 m_shouldStripWS = shouldStrip;
  • 2310
  • 2311 if (null != m_shouldStripWhitespaceStack)
  • 2312 m_shouldStripWhitespaceStack.setTop(shouldStrip);
  • 2313 }
  • 2314
  • 2315 /**
  • 2316 * A dummy routine to satisify the abstract interface. If the DTM
  • 2317 * implememtation that extends the default base requires notification
  • 2318 * of registration, they can override this method.
  • 2319 */
  • 2320 public void documentRegistration()
  • 2321 {
  • 2322 }
  • 2323
  • 2324 /**
  • 2325 * A dummy routine to satisify the abstract interface. If the DTM
  • 2326 * implememtation that extends the default base requires notification
  • 2327 * when the document is being released, they can override this method
  • 2328 */
  • 2329 public void documentRelease()
  • 2330 {
  • 2331 }
  • 2332
  • 2333 /**
  • 2334 * Migrate a DTM built with an old DTMManager to a new DTMManager.
  • 2335 * After the migration, the new DTMManager will treat the DTM as
  • 2336 * one that is built by itself.
  • 2337 * This is used to support DTM sharing between multiple transformations.
  • 2338 * @param mgr the DTMManager
  • 2339 */
  • 2340 public void migrateTo(DTMManager mgr)
  • 2341 {
  • 2342 m_mgr = mgr;
  • 2343 if(mgr instanceof DTMManagerDefault)
  • 2344 m_mgrDefault=(DTMManagerDefault)mgr;
  • 2345 }
  • 2346
  • 2347 /** Query which DTMManager this DTM is currently being handled by.
  • 2348 *
  • 2349 * %REVEW% Should this become part of the base DTM API?
  • 2350 *
  • 2351 * @return a DTMManager, or null if this is a "stand-alone" DTM.
  • 2352 */
  • 2353 public DTMManager getManager()
  • 2354 {
  • 2355 return m_mgr;
  • 2356 }
  • 2357
  • 2358 /** Query which DTMIDs this DTM is currently using within the DTMManager.
  • 2359 *
  • 2360 * %REVEW% Should this become part of the base DTM API?
  • 2361 *
  • 2362 * @return an IntVector, or null if this is a "stand-alone" DTM.
  • 2363 */
  • 2364 public SuballocatedIntVector getDTMIDs()
  • 2365 {
  • 2366 if(m_mgr==null) return null;
  • 2367 return m_dtmIdent;
  • 2368 }
  • 2369}

文件:DTMDefaultBase.java
包名:com.sun.org.apache.xml.internal.dtm.ref
类名:DTMDefaultBase
继承:
接口:[DTM]