Methods Summary |
---|
protected int | _exptype(int identity)Get the expanded type ID for the given node identity.
if (identity == DTM.NULL)
return NULL;
// Reorganized test and loop into single flow
// Tiny performance improvement, saves a few bytes of code, clearer.
// %OPT% Other internal getters could be treated simliarly
while (identity>=m_size)
{
if (!nextNode() && identity >= m_size)
return NULL;
}
return m_exptype.elementAt(identity);
|
protected int | _firstch(int identity)Get the first child for the given node identity.
// Boiler-plate code for each of the _xxx functions, except for the array.
int info = (identity >= m_size) ? NOTPROCESSED : m_firstch.elementAt(identity);
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
// processed.
while (info == NOTPROCESSED)
{
boolean isMore = nextNode();
if (identity >= m_size &&!isMore)
return NULL;
else
{
info = m_firstch.elementAt(identity);
if(info == NOTPROCESSED && !isMore)
return NULL;
}
}
return info;
|
protected int | _level(int identity)Get the level in the tree for the given node identity.
while (identity>=m_size)
{
boolean isMore = nextNode();
if (!isMore && identity >= m_size)
return NULL;
}
int i=0;
while(NULL != (identity=_parent(identity)))
++i;
return i;
|
protected int | _nextsib(int identity)Get the next sibling for the given node identity.
// Boiler-plate code for each of the _xxx functions, except for the array.
int info = (identity >= m_size) ? NOTPROCESSED : m_nextsib.elementAt(identity);
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
// processed.
while (info == NOTPROCESSED)
{
boolean isMore = nextNode();
if (identity >= m_size &&!isMore)
return NULL;
else
{
info = m_nextsib.elementAt(identity);
if(info == NOTPROCESSED && !isMore)
return NULL;
}
}
return info;
|
protected int | _parent(int identity)Get the parent for the given node identity.
if (identity < m_size)
return m_parent.elementAt(identity);
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
// processed.
while (true)
{
boolean isMore = nextNode();
if (identity >= m_size && !isMore)
return NULL;
else if (identity < m_size)
return m_parent.elementAt(identity);
}
|
protected int | _prevsib(int identity)Get the previous sibling for the given node identity.
if (identity < m_size)
return m_prevsib.elementAt(identity);
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
// processed.
while (true)
{
boolean isMore = nextNode();
if (identity >= m_size && !isMore)
return NULL;
else if (identity < m_size)
return m_prevsib.elementAt(identity);
}
|
protected short | _type(int identity)Get the simple type ID for the given node identity.
int info = _exptype(identity);
if (NULL != info)
return m_expandedNameTable.getType(info);
else
return NULL;
|
public void | appendChild(int newChild, boolean clone, boolean cloneDepth)Append a child to the end of the document. Please note that the node
is always cloned if it is owned by another document.
%REVIEW% "End of the document" needs to be defined more clearly.
Does it become the last child of the Document? Of the root element?
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendChild not yet supported!");
|
public void | appendTextChild(java.lang.String str)Append a text node child that will be constructed from a string,
to the end of the document.
%REVIEW% "End of the document" needs to be defined more clearly.
Does it become the last child of the Document? Of the root element?
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"appendTextChild not yet supported!");
|
protected void | declareNamespaceInContext(int elementNodeIndex, int namespaceNodeIndex)Build table of namespace declaration
locations during DTM construction. Table is a Vector of
SuballocatedIntVectors containing the namespace node HANDLES declared at
that ID, plus an SuballocatedIntVector of the element node INDEXES at which
these declarations appeared.
NOTE: Since this occurs during model build, nodes will be encountered
in doucment order and thus the table will be ordered by element,
permitting binary-search as a possible retrieval optimization.
%REVIEW% Directly managed arrays rather than vectors?
%REVIEW% Handles or IDs? Given usage, I think handles. // on demand
SuballocatedIntVector nsList=null;
if(m_namespaceDeclSets==null)
{
// First
m_namespaceDeclSetElements=new SuballocatedIntVector(32);
m_namespaceDeclSetElements.addElement(elementNodeIndex);
m_namespaceDeclSets=new Vector();
nsList=new SuballocatedIntVector(32);
m_namespaceDeclSets.addElement(nsList);
}
else
{
// Most recent. May be -1 (none) if DTM was pruned.
// %OPT% Is there a lastElement() method? Should there be?
int last=m_namespaceDeclSetElements.size()-1;
if(last>=0 && elementNodeIndex==m_namespaceDeclSetElements.elementAt(last))
{
nsList=(SuballocatedIntVector)m_namespaceDeclSets.elementAt(last);
}
}
if(nsList==null)
{
m_namespaceDeclSetElements.addElement(elementNodeIndex);
SuballocatedIntVector inherited =
findNamespaceContext(_parent(elementNodeIndex));
if (inherited!=null) {
// %OPT% Count-down might be faster, but debuggability may
// be better this way, and if we ever decide we want to
// keep this ordered by expanded-type...
int isize=inherited.size();
// Base the size of a new namespace list on the
// size of the inherited list - but within reason!
nsList=new SuballocatedIntVector(Math.max(Math.min(isize+16,2048),
32));
for(int i=0;i<isize;++i)
{
nsList.addElement(inherited.elementAt(i));
}
} else {
nsList=new SuballocatedIntVector(32);
}
m_namespaceDeclSets.addElement(nsList);
}
// Handle overwriting inherited.
// %OPT% Keep sorted? (By expanded-name rather than by doc order...)
// Downside: Would require insertElementAt if not found,
// which has recopying costs. But these are generally short lists...
int newEType=_exptype(namespaceNodeIndex);
for(int i=nsList.size()-1;i>=0;--i)
{
if(newEType==getExpandedTypeID(nsList.elementAt(i)))
{
nsList.setElementAt(makeNodeHandle(namespaceNodeIndex),i);
return;
}
}
nsList.addElement(makeNodeHandle(namespaceNodeIndex));
|
public abstract void | dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)Directly call the
characters method on the passed ContentHandler for the
string-value of the given node (see http://www.w3.org/TR/xpath#data-model
for the definition of a node's string-value). Multiple calls to the
ContentHandler's characters methods may well occur for a single call to
this method.
|
public abstract void | dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)Directly create SAX parser events from a subtree.
|
public void | documentRegistration()A dummy routine to satisify the abstract interface. If the DTM
implememtation that extends the default base requires notification
of registration, they can override this method.
|
public void | documentRelease()A dummy routine to satisify the abstract interface. If the DTM
implememtation that extends the default base requires notification
when the document is being released, they can override this method
|
public void | dumpDTM(java.io.OutputStream os)Diagnostics function to dump the DTM.
try
{
if(os==null)
{
File f = new File("DTMDump"+((Object)this).hashCode()+".txt");
System.err.println("Dumping... "+f.getAbsolutePath());
os=new FileOutputStream(f);
}
PrintStream ps = new PrintStream(os);
while (nextNode()){}
int nRecords = m_size;
ps.println("Total nodes: " + nRecords);
for (int index = 0; index < nRecords; ++index)
{
int i=makeNodeHandle(index);
ps.println("=========== index=" + index + " handle=" + i + " ===========");
ps.println("NodeName: " + getNodeName(i));
ps.println("NodeNameX: " + getNodeNameX(i));
ps.println("LocalName: " + getLocalName(i));
ps.println("NamespaceURI: " + getNamespaceURI(i));
ps.println("Prefix: " + getPrefix(i));
int exTypeID = _exptype(index);
ps.println("Expanded Type ID: "
+ Integer.toHexString(exTypeID));
int type = _type(index);
String typestring;
switch (type)
{
case DTM.ATTRIBUTE_NODE :
typestring = "ATTRIBUTE_NODE";
break;
case DTM.CDATA_SECTION_NODE :
typestring = "CDATA_SECTION_NODE";
break;
case DTM.COMMENT_NODE :
typestring = "COMMENT_NODE";
break;
case DTM.DOCUMENT_FRAGMENT_NODE :
typestring = "DOCUMENT_FRAGMENT_NODE";
break;
case DTM.DOCUMENT_NODE :
typestring = "DOCUMENT_NODE";
break;
case DTM.DOCUMENT_TYPE_NODE :
typestring = "DOCUMENT_NODE";
break;
case DTM.ELEMENT_NODE :
typestring = "ELEMENT_NODE";
break;
case DTM.ENTITY_NODE :
typestring = "ENTITY_NODE";
break;
case DTM.ENTITY_REFERENCE_NODE :
typestring = "ENTITY_REFERENCE_NODE";
break;
case DTM.NAMESPACE_NODE :
typestring = "NAMESPACE_NODE";
break;
case DTM.NOTATION_NODE :
typestring = "NOTATION_NODE";
break;
case DTM.NULL :
typestring = "NULL";
break;
case DTM.PROCESSING_INSTRUCTION_NODE :
typestring = "PROCESSING_INSTRUCTION_NODE";
break;
case DTM.TEXT_NODE :
typestring = "TEXT_NODE";
break;
default :
typestring = "Unknown!";
break;
}
ps.println("Type: " + typestring);
int firstChild = _firstch(index);
if (DTM.NULL == firstChild)
ps.println("First child: DTM.NULL");
else if (NOTPROCESSED == firstChild)
ps.println("First child: NOTPROCESSED");
else
ps.println("First child: " + firstChild);
if (m_prevsib != null)
{
int prevSibling = _prevsib(index);
if (DTM.NULL == prevSibling)
ps.println("Prev sibling: DTM.NULL");
else if (NOTPROCESSED == prevSibling)
ps.println("Prev sibling: NOTPROCESSED");
else
ps.println("Prev sibling: " + prevSibling);
}
int nextSibling = _nextsib(index);
if (DTM.NULL == nextSibling)
ps.println("Next sibling: DTM.NULL");
else if (NOTPROCESSED == nextSibling)
ps.println("Next sibling: NOTPROCESSED");
else
ps.println("Next sibling: " + nextSibling);
int parent = _parent(index);
if (DTM.NULL == parent)
ps.println("Parent: DTM.NULL");
else if (NOTPROCESSED == parent)
ps.println("Parent: NOTPROCESSED");
else
ps.println("Parent: " + parent);
int level = _level(index);
ps.println("Level: " + level);
ps.println("Node Value: " + getNodeValue(i));
ps.println("String Value: " + getStringValue(i));
}
}
catch(IOException ioe)
{
ioe.printStackTrace(System.err);
System.exit(-1);
}
|
public java.lang.String | dumpNode(int nodeHandle)Diagnostics function to dump a single node.
%REVIEW% KNOWN GLITCH: If you pass it a node index rather than a
node handle, it works just fine... but the displayed identity
number before the colon is different, which complicates comparing
it with nodes printed the other way. We could always OR the DTM ID
into the value, to suppress that distinction...
%REVIEW% This might want to be moved up to DTMDefaultBase, or possibly
DTM itself, since it's a useful diagnostic and uses only DTM's public
APIs.
if(nodeHandle==DTM.NULL)
return "[null]";
String typestring;
switch (getNodeType(nodeHandle))
{
case DTM.ATTRIBUTE_NODE :
typestring = "ATTR";
break;
case DTM.CDATA_SECTION_NODE :
typestring = "CDATA";
break;
case DTM.COMMENT_NODE :
typestring = "COMMENT";
break;
case DTM.DOCUMENT_FRAGMENT_NODE :
typestring = "DOC_FRAG";
break;
case DTM.DOCUMENT_NODE :
typestring = "DOC";
break;
case DTM.DOCUMENT_TYPE_NODE :
typestring = "DOC_TYPE";
break;
case DTM.ELEMENT_NODE :
typestring = "ELEMENT";
break;
case DTM.ENTITY_NODE :
typestring = "ENTITY";
break;
case DTM.ENTITY_REFERENCE_NODE :
typestring = "ENT_REF";
break;
case DTM.NAMESPACE_NODE :
typestring = "NAMESPACE";
break;
case DTM.NOTATION_NODE :
typestring = "NOTATION";
break;
case DTM.NULL :
typestring = "null";
break;
case DTM.PROCESSING_INSTRUCTION_NODE :
typestring = "PI";
break;
case DTM.TEXT_NODE :
typestring = "TEXT";
break;
default :
typestring = "Unknown!";
break;
}
StringBuffer sb=new StringBuffer();
sb.append("["+nodeHandle+": "+typestring+
"(0x"+Integer.toHexString(getExpandedTypeID(nodeHandle))+") "+
getNodeNameX(nodeHandle)+" {"+getNamespaceURI(nodeHandle)+"}"+
"=\""+ getNodeValue(nodeHandle)+"\"]");
return sb.toString();
|
protected void | ensureSizeOfIndex(int namespaceID, int LocalNameID)Ensure that the size of the element indexes can hold the information.
if (null == m_elemIndexes)
{
m_elemIndexes = new int[namespaceID + 20][][];
}
else if (m_elemIndexes.length <= namespaceID)
{
int[][][] indexes = m_elemIndexes;
m_elemIndexes = new int[namespaceID + 20][][];
System.arraycopy(indexes, 0, m_elemIndexes, 0, indexes.length);
}
int[][] localNameIndex = m_elemIndexes[namespaceID];
if (null == localNameIndex)
{
localNameIndex = new int[LocalNameID + 100][];
m_elemIndexes[namespaceID] = localNameIndex;
}
else if (localNameIndex.length <= LocalNameID)
{
int[][] indexes = localNameIndex;
localNameIndex = new int[LocalNameID + 100][];
System.arraycopy(indexes, 0, localNameIndex, 0, indexes.length);
m_elemIndexes[namespaceID] = localNameIndex;
}
int[] elemHandles = localNameIndex[LocalNameID];
if (null == elemHandles)
{
elemHandles = new int[128];
localNameIndex[LocalNameID] = elemHandles;
elemHandles[0] = 1;
}
else if (elemHandles.length <= elemHandles[0] + 1)
{
int[] indexes = elemHandles;
elemHandles = new int[elemHandles[0] + 1024];
System.arraycopy(indexes, 0, elemHandles, 0, indexes.length);
localNameIndex[LocalNameID] = elemHandles;
}
|
protected void | error(java.lang.String msg)Simple error for asserts and the like.
throw new DTMException(msg);
|
int | findElementFromIndex(int nsIndex, int lnIndex, int firstPotential)Find the first matching element from the index at or after the
given node.
int[][][] indexes = m_elemIndexes;
if (null != indexes && nsIndex < indexes.length)
{
int[][] lnIndexs = indexes[nsIndex];
if (null != lnIndexs && lnIndex < lnIndexs.length)
{
int[] elems = lnIndexs[lnIndex];
if (null != elems)
{
int pos = findGTE(elems, 1, elems[0], firstPotential);
if (pos > -1)
{
return elems[pos];
}
}
}
}
return NOTPROCESSED;
|
protected int | findGTE(int[] list, int start, int len, int value)Find the first index that occurs in the list that is greater than or
equal to the given value.
int low = start;
int high = start + (len - 1);
int end = high;
while (low <= high)
{
int mid = (low + high) / 2;
int c = list[mid];
if (c > value)
high = mid - 1;
else if (c < value)
low = mid + 1;
else
return mid;
}
return (low <= end && list[low] > value) ? low : -1;
|
protected int | findInSortedSuballocatedIntVector(com.sun.org.apache.xml.internal.utils.SuballocatedIntVector vector, int lookfor)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?
// 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.
|
protected com.sun.org.apache.xml.internal.utils.SuballocatedIntVector | findNamespaceContext(int elementNodeIndex)Retrieve list of namespace declaration locations
active at this node. List is an SuballocatedIntVector whose
entries are the namespace node HANDLES declared at that ID.
%REVIEW% Directly managed arrays rather than vectors?
%REVIEW% Handles or IDs? Given usage, I think handles.
if (null!=m_namespaceDeclSetElements)
{
// %OPT% Is binary-search really saving us a lot versus linear?
// (... It may be, in large docs with many NS decls.)
int wouldBeAt=findInSortedSuballocatedIntVector(m_namespaceDeclSetElements,
elementNodeIndex);
if(wouldBeAt>=0) // Found it
return (SuballocatedIntVector) m_namespaceDeclSets.elementAt(wouldBeAt);
if(wouldBeAt == -1) // -1-wouldbeat == 0
return null; // Not after anything; definitely not found
// Not found, but we know where it should have been.
// Search back until we find an ancestor or run out.
wouldBeAt=-1-wouldBeAt;
// Decrement wouldBeAt to find last possible ancestor
int candidate=m_namespaceDeclSetElements.elementAt(-- wouldBeAt);
int ancestor=_parent(elementNodeIndex);
// Special case: if the candidate is before the given node, and
// is in the earliest possible position in the document, it
// must have the namespace declarations we're interested in.
if (wouldBeAt == 0 && candidate < ancestor) {
int rootHandle = getDocumentRoot(makeNodeHandle(elementNodeIndex));
int rootID = makeNodeIdentity(rootHandle);
int uppermostNSCandidateID;
if (getNodeType(rootHandle) == DTM.DOCUMENT_NODE) {
int ch = _firstch(rootID);
uppermostNSCandidateID = (ch != DTM.NULL) ? ch : rootID;
} else {
uppermostNSCandidateID = rootID;
}
if (candidate == uppermostNSCandidateID) {
return (SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
}
}
while(wouldBeAt>=0 && ancestor>0)
{
if (candidate==ancestor) {
// Found ancestor in list
return (SuballocatedIntVector)m_namespaceDeclSets.elementAt(wouldBeAt);
} else if (candidate<ancestor) {
// Too deep in tree
do {
ancestor=_parent(ancestor);
} while (candidate < ancestor);
} else if(wouldBeAt > 0){
// Too late in list
candidate=m_namespaceDeclSetElements.elementAt(--wouldBeAt);
}
else
break;
}
}
return null; // No namespaces known at this node
|
public abstract int | getAttributeNode(int nodeHandle, java.lang.String namespaceURI, java.lang.String name)Retrieves an attribute node by by qualified name and namespace URI.
|
public com.sun.org.apache.xml.internal.utils.SuballocatedIntVector | getDTMIDs()Query which DTMIDs this DTM is currently using within the DTMManager.
%REVEW% Should this become part of the base DTM API?
if(m_mgr==null) return null;
return m_dtmIdent;
|
public int | getDocument()Find the Document node handle for the document currently under construction.
PLEASE NOTE that most people should use getOwnerDocument(nodeHandle) instead;
this version of the operation is primarily intended for use during negotiation
with the DTM Manager.
return m_dtmIdent.elementAt(0); // makeNodeHandle(0)
|
public boolean | getDocumentAllDeclarationsProcessed()Return an indication of
whether the processor has read the complete DTD. Its value is a
boolean. If it is false, then certain properties (indicated in their
descriptions below) may be unknown. If it is true, those properties
are never unknown.
// %REVIEW% OK?
return true;
|
public java.lang.String | getDocumentBaseURI()Return the base URI of the document entity. If it is not known
(because the document was parsed from a socket connection or from
standard input, for example), the value of this property is unknown.
return m_documentBaseURI;
|
public java.lang.String | getDocumentEncoding(int nodeHandle)Return the name of the character encoding scheme
in which the document entity is expressed.
// %REVIEW% OK?? -sb
return "UTF-8";
|
public int | getDocumentRoot(int nodeHandle)Given a node handle, find the owning document node. Unlike the DOM,
this considers the owningDocument of a Document to be itself.
return getDocument();
|
public java.lang.String | getDocumentStandalone(int nodeHandle)Return an indication of the standalone status of the document,
either "yes" or "no". This property is derived from the optional
standalone document declaration in the XML declaration at the
beginning of the document entity, and has no value if there is no
standalone document declaration.
return null;
|
public java.lang.String | getDocumentSystemIdentifier(int nodeHandle)Return the system identifier of the document entity. If
it is not known, the value of this property is unknown.
// %REVIEW% OK? -sb
return m_documentBaseURI;
|
public abstract java.lang.String | getDocumentTypeDeclarationPublicIdentifier()Return the public identifier of the external subset,
normalized as described in 4.2.2 External Entities [XML]. If there is
no external subset or if it has no public identifier, this property
has no value.
|
public abstract java.lang.String | getDocumentTypeDeclarationSystemIdentifier()A document type declaration information item has the following properties:
1. [system identifier] The system identifier of the external subset, if
it exists. Otherwise this property has no value.
|
public java.lang.String | getDocumentVersion(int documentHandle)Return a string representing the XML version of the document. This
property is derived from the XML declaration optionally present at the
beginning of the document entity, and has no value if there is no XML
declaration.
return null;
|
public abstract int | getElementById(java.lang.String elementId)Returns the Element whose ID is given by
elementId . If no such element exists, returns
DTM.NULL . Behavior is not defined if more than one element
has this ID . Attributes (including those
with the name "ID") are not of type ID unless so defined by DTD/Schema
information available to the DTM implementation.
Implementations that do not know whether attributes are of type ID or
not are expected to return DTM.NULL .
%REVIEW% Presumably IDs are still scoped to a single document,
and this operation searches only within a single document, right?
Wouldn't want collisions between DTMs in the same process.
|
public int | getExpandedTypeID(int nodeHandle)Given a node handle, return an ID that represents the node's expanded name.
// %REVIEW% This _should_ only be null if someone asked the wrong DTM about the node...
// which one would hope would never happen...
int id=makeNodeIdentity(nodeHandle);
if(id==NULL)
return NULL;
return _exptype(id);
|
public int | getExpandedTypeID(java.lang.String namespace, java.lang.String localName, int type)Given an expanded name, return an ID. If the expanded-name does not
exist in the internal tables, the entry will be created, and the ID will
be returned. Any additional nodes that are created that have this
expanded name will use this ID.
ExpandedNameTable ent = m_expandedNameTable;
return ent.getExpandedTypeID(namespace, localName, type);
|
public int | getFirstAttribute(int nodeHandle)Given a node handle, get the index of the node's first attribute.
int nodeID = makeNodeIdentity(nodeHandle);
return makeNodeHandle(getFirstAttributeIdentity(nodeID));
|
protected int | getFirstAttributeIdentity(int identity)Given a node identity, get the index of the node's first attribute.
int type = _type(identity);
if (DTM.ELEMENT_NODE == type)
{
// Assume that attributes and namespaces immediately follow the element.
while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
{
// Assume this can not be null.
type = _type(identity);
if (type == DTM.ATTRIBUTE_NODE)
{
return identity;
}
else if (DTM.NAMESPACE_NODE != type)
{
break;
}
}
}
return DTM.NULL;
|
public int | getFirstChild(int nodeHandle)Given a node handle, get the handle of the node's first child.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
int identity = makeNodeIdentity(nodeHandle);
int firstChild = _firstch(identity);
return makeNodeHandle(firstChild);
|
public int | getFirstNamespaceNode(int nodeHandle, boolean inScope)Given a node handle, get the index of the node's first child.
If not yet resolved, waits for more nodes to be added to the document and
tries again
if(inScope)
{
int identity = makeNodeIdentity(nodeHandle);
if (_type(identity) == DTM.ELEMENT_NODE)
{
SuballocatedIntVector nsContext=findNamespaceContext(identity);
if(nsContext==null || nsContext.size()<1)
return NULL;
return nsContext.elementAt(0);
}
else
return NULL;
}
else
{
// Assume that attributes and namespaces immediately
// follow the element.
//
// %OPT% Would things be faster if all NS nodes were built
// before all Attr nodes? Some costs at build time for 2nd
// pass...
int identity = makeNodeIdentity(nodeHandle);
if (_type(identity) == DTM.ELEMENT_NODE)
{
while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
{
int type = _type(identity);
if (type == DTM.NAMESPACE_NODE)
return makeNodeHandle(identity);
else if (DTM.ATTRIBUTE_NODE != type)
break;
}
return NULL;
}
else
return NULL;
}
|
public int | getLastChild(int nodeHandle)Given a node handle, advance to its last child.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
int identity = makeNodeIdentity(nodeHandle);
int child = _firstch(identity);
int lastChild = DTM.NULL;
while (child != DTM.NULL)
{
lastChild = child;
child = _nextsib(child);
}
return makeNodeHandle(lastChild);
|
public short | getLevel(int nodeHandle)Get the depth level of this node in the tree (equals 1 for
a parentless node).
// Apparently, the axis walker stuff requires levels to count from 1.
int identity = makeNodeIdentity(nodeHandle);
return (short) (_level(identity) + 1);
|
public abstract java.lang.String | getLocalName(int nodeHandle)Given a node handle, return its XPath-style localname.
(As defined in Namespaces, this is the portion of the name after any
colon character).
|
public java.lang.String | getLocalNameFromExpandedNameID(int expandedNameID)Given an expanded-name ID, return the local name part.
return m_expandedNameTable.getLocalName(expandedNameID);
|
public com.sun.org.apache.xml.internal.dtm.DTMManager | getManager()Query which DTMManager this DTM is currently being handled by.
%REVEW% Should this become part of the base DTM API?
return m_mgr;
|
public java.lang.String | getNamespaceFromExpandedNameID(int expandedNameID)Given an expanded-name ID, return the namespace URI part.
return m_expandedNameTable.getNamespace(expandedNameID);
|
public int | getNamespaceType(int nodeHandle)Returns the namespace type of a specific node
int identity = makeNodeIdentity(nodeHandle);
int expandedNameID = _exptype(identity);
return m_expandedNameTable.getNamespaceID(expandedNameID);
|
public abstract java.lang.String | getNamespaceURI(int nodeHandle)Given a node handle, return its DOM-style namespace URI
(As defined in Namespaces, this is the declared URI which this node's
prefix -- or default in lieu thereof -- was mapped to.)
%REVIEW% Null or ""? -sb
|
public int | getNextAttribute(int nodeHandle)Given a node handle, advance to the next attribute.
If an attr, we advance to
the next attr on the same node. If not an attribute, we return NULL.
int nodeID = makeNodeIdentity(nodeHandle);
if (_type(nodeID) == DTM.ATTRIBUTE_NODE) {
return makeNodeHandle(getNextAttributeIdentity(nodeID));
}
return DTM.NULL;
|
protected int | getNextAttributeIdentity(int identity)Given a node identity for an attribute, advance to the next attribute.
// Assume that attributes and namespace nodes immediately follow the element
while (DTM.NULL != (identity = getNextNodeIdentity(identity))) {
int type = _type(identity);
if (type == DTM.ATTRIBUTE_NODE) {
return identity;
} else if (type != DTM.NAMESPACE_NODE) {
break;
}
}
return DTM.NULL;
|
public int | getNextNamespaceNode(int baseHandle, int nodeHandle, boolean inScope)Given a namespace handle, advance to the next namespace.
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;
|
protected abstract int | getNextNodeIdentity(int identity)Get the next node identity value in the list, and call the iterator
if it hasn't been added yet.
|
public int | getNextSibling(int nodeHandle)Given a node handle, advance to its next sibling.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
if (nodeHandle == DTM.NULL)
return DTM.NULL;
return makeNodeHandle(_nextsib(makeNodeIdentity(nodeHandle)));
|
public org.w3c.dom.Node | getNode(int nodeHandle)Return an DOM node for the given node.
return new DTMNodeProxy(this, nodeHandle);
|
public int | getNodeHandle(int nodeId)Get the handle of this node in the tree
/*if (nodeId != DTM.NULL)
return nodeId | m_dtmIdent;
else
return DTM.NULL;*/
return makeNodeHandle(nodeId);
|
public int | getNodeIdent(int nodeHandle)Get the identity of this node in the tree
/*if (nodeHandle != DTM.NULL)
return nodeHandle & m_mask;
else
return DTM.NULL;*/
return makeNodeIdentity(nodeHandle);
|
public abstract java.lang.String | getNodeName(int nodeHandle)Given a node handle, return its DOM-style node name. This will
include names such as #text or #document.
|
public java.lang.String | getNodeNameX(int nodeHandle)Given a node handle, return the XPath node name. This should be
the name as described by the XPath data model, NOT the DOM-style
name.
/** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMDefaultBase abstract method */
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"Not yet supported!");
return null;
|
public short | getNodeType(int nodeHandle)Given a node handle, return its DOM-style node type.
%REVIEW% Generally, returning short is false economy. Return int?
%REVIEW% Make assumption that node has already arrived. Is OK?
if (nodeHandle == DTM.NULL)
return DTM.NULL;
return m_expandedNameTable.getType(_exptype(makeNodeIdentity(nodeHandle)));
|
public abstract java.lang.String | getNodeValue(int nodeHandle)Given a node handle, return its node value. This is mostly
as defined by the DOM, but may ignore some conveniences.
|
protected abstract int | getNumberOfNodes()Get the number of nodes that have been added.
|
public int | getOwnerDocument(int nodeHandle)Given a node handle, find the owning document node. This has the exact
same semantics as the DOM Document method of the same name, in that if
the nodeHandle is a document node, it will return NULL.
%REVIEW% Since this is DOM-specific, it may belong at the DOM
binding layer. Included here as a convenience function and to
aid porting of DOM code to DTM.
if (DTM.DOCUMENT_NODE == getNodeType(nodeHandle))
return DTM.NULL;
return getDocumentRoot(nodeHandle);
|
public int | getParent(int nodeHandle)Given a node handle, find its parent node.
int identity = makeNodeIdentity(nodeHandle);
if (identity > 0)
return makeNodeHandle(_parent(identity));
else
return DTM.NULL;
|
public abstract java.lang.String | getPrefix(int nodeHandle)Given a namespace handle, return the prefix that the namespace decl is
mapping.
Given a node handle, return the prefix used to map to the namespace.
%REVIEW% Are you sure you want "" for no prefix?
%REVIEW-COMMENT% I think so... not totally sure. -sb
|
public int | getPreviousSibling(int nodeHandle)Given a node handle, find its preceeding sibling.
WARNING: DTM is asymmetric; this operation is resolved by search, and is
relatively expensive.
if (nodeHandle == DTM.NULL)
return DTM.NULL;
if (m_prevsib != null)
return makeNodeHandle(_prevsib(makeNodeIdentity(nodeHandle)));
else
{
// If the previous sibling array is not built, we get at
// the previous sibling using the parent, firstch and
// nextsib arrays.
int nodeID = makeNodeIdentity(nodeHandle);
int parent = _parent(nodeID);
int node = _firstch(parent);
int result = DTM.NULL;
while (node != nodeID)
{
result = node;
node = _nextsib(node);
}
return makeNodeHandle(result);
}
|
protected boolean | getShouldStripWhitespace()Find out whether or not to strip whispace nodes.
return m_shouldStripWS;
|
public abstract com.sun.org.apache.xml.internal.utils.XMLString | getStringValue(int nodeHandle)Get the string-value of a node as a String object
(see http://www.w3.org/TR/xpath#data-model
for the definition of a node's string-value).
|
public char[] | getStringValueChunk(int nodeHandle, int chunkIndex, int[] startAndLen)Get a character array chunk in the string-value of a node.
(see http://www.w3.org/TR/xpath#data-model
for the definition of a node's string-value).
Note that a single text node may have multiple text chunks.
// %TBD%
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//"getStringValueChunk not yet supported!");
return null;
|
public int | getStringValueChunkCount(int nodeHandle)Get number of character array chunks in
the string-value of a node.
(see http://www.w3.org/TR/xpath#data-model
for the definition of a node's string-value).
Note that a single text node may have multiple text chunks.
// %TBD%
error(XMLMessages.createXMLMessage(XMLErrorResources.ER_METHOD_NOT_SUPPORTED, null));//("getStringValueChunkCount not yet supported!");
return 0;
|
protected int | getTypedAttribute(int nodeHandle, int attType)Given a node handle and an expanded type ID, get the index of the node's
attribute of that type, if any.
int type = getNodeType(nodeHandle);
if (DTM.ELEMENT_NODE == type) {
int identity = makeNodeIdentity(nodeHandle);
while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
{
type = _type(identity);
if (type == DTM.ATTRIBUTE_NODE)
{
if (_exptype(identity) == attType) return makeNodeHandle(identity);
}
else if (DTM.NAMESPACE_NODE != type)
{
break;
}
}
}
return DTM.NULL;
|
public int | getTypedFirstChild(int nodeHandle, int nodeType)Given a node handle, get the handle of the node's first child.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
int firstChild, eType;
if (nodeType < DTM.NTYPES) {
for (firstChild = _firstch(makeNodeIdentity(nodeHandle));
firstChild != DTM.NULL;
firstChild = _nextsib(firstChild)) {
eType = _exptype(firstChild);
if (eType == nodeType
|| (eType >= DTM.NTYPES
&& m_expandedNameTable.getType(eType) == nodeType)) {
return makeNodeHandle(firstChild);
}
}
} else {
for (firstChild = _firstch(makeNodeIdentity(nodeHandle));
firstChild != DTM.NULL;
firstChild = _nextsib(firstChild)) {
if (_exptype(firstChild) == nodeType) {
return makeNodeHandle(firstChild);
}
}
}
return DTM.NULL;
|
public int | getTypedNextSibling(int nodeHandle, int nodeType)Given a node handle, advance to its next sibling.
If not yet resolved, waits for more nodes to be added to the document and
tries again.
if (nodeHandle == DTM.NULL)
return DTM.NULL;
int node = makeNodeIdentity(nodeHandle);
int eType;
while ((node = _nextsib(node)) != DTM.NULL &&
((eType = _exptype(node)) != nodeType &&
m_expandedNameTable.getType(eType)!= nodeType));
//_type(node) != nodeType));
return (node == DTM.NULL ? DTM.NULL : makeNodeHandle(node));
|
public abstract java.lang.String | getUnparsedEntityURI(java.lang.String name)The getUnparsedEntityURI function returns the URI of the unparsed
entity with the specified name in the same document as the context
node (see [3.3 Unparsed Entities]). It returns the empty string if
there is no such entity.
XML processors may choose to use the System Identifier (if one
is provided) to resolve the entity, rather than the URI in the
Public Identifier. The details are dependent on the processor, and
we would have to support some form of plug-in resolver to handle
this properly. Currently, we simply return the System Identifier if
present, and hope that it a usable URI or that our caller can
map it to one.
TODO: Resolve Public Identifiers... or consider changing function name.
If we find a relative URI
reference, XML expects it to be resolved in terms of the base URI
of the document. The DOM doesn't do that for us, and it isn't
entirely clear whether that should be done here; currently that's
pushed up to a higher level of our application. (Note that DOM Level
1 didn't store the document's base URI.)
TODO: Consider resolving Relative URIs.
(The DOM's statement that "An XML processor may choose to
completely expand entities before the structure model is passed
to the DOM" refers only to parsed entities, not unparsed, and hence
doesn't affect this function.)
|
public boolean | hasChildNodes(int nodeHandle)Given a node handle, test if it has child nodes.
%REVIEW% This is obviously useful at the DOM layer, where it
would permit testing this without having to create a proxy
node. It's less useful in the DTM API, where
(dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
almost as self-evident. But it's a convenience, and eases porting
of DOM code to DTM.
int identity = makeNodeIdentity(nodeHandle);
int firstChild = _firstch(identity);
return firstChild != DTM.NULL;
|
protected void | indexNode(int expandedTypeID, int identity)Add a node to the element indexes. The node will not be added unless
it's an element.
ExpandedNameTable ent = m_expandedNameTable;
short type = ent.getType(expandedTypeID);
if (DTM.ELEMENT_NODE == type)
{
int namespaceID = ent.getNamespaceID(expandedTypeID);
int localNameID = ent.getLocalNameID(expandedTypeID);
ensureSizeOfIndex(namespaceID, localNameID);
int[] index = m_elemIndexes[namespaceID][localNameID];
index[index[0]] = identity;
index[0]++;
}
|
public abstract boolean | isAttributeSpecified(int attributeHandle)5. [specified] A flag indicating whether this attribute was actually
specified in the start-tag of its element, or was defaulted from the
DTD.
|
public boolean | isCharacterElementContentWhitespace(int nodeHandle)2. [element content whitespace] A boolean indicating whether the
character is white space appearing within element content (see [XML],
2.10 "White Space Handling"). Note that validating XML processors are
required by XML 1.0 to provide this information. If there is no
declaration for the containing element, this property has no value for
white space characters. If no declaration has been read, but the [all
declarations processed] property of the document information item is
false (so there may be an unread declaration), then the value of this
property is unknown for white space characters. It is always false for
characters that are not white space.
// %TBD%
return false;
|
public boolean | isDocumentAllDeclarationsProcessed(int documentHandle)10. [all declarations processed] This property is not strictly speaking
part of the infoset of the document. Rather it is an indication of
whether the processor has read the complete DTD. Its value is a
boolean. If it is false, then certain properties (indicated in their
descriptions below) may be unknown. If it is true, those properties
are never unknown.
return true;
|
public boolean | isNodeAfter(int nodeHandle1, int nodeHandle2)Figure out whether nodeHandle2 should be considered as being later
in the document than nodeHandle1, in Document Order as defined
by the XPath model. This may not agree with the ordering defined
by other XML applications.
There are some cases where ordering isn't defined, and neither are
the results of this function -- though we'll generally return false.
// These return NULL if the node doesn't belong to this document.
int index1 = makeNodeIdentity(nodeHandle1);
int index2 = makeNodeIdentity(nodeHandle2);
return index1!=NULL & index2!=NULL & index1 <= index2;
|
public boolean | isSupported(java.lang.String feature, java.lang.String version)Tests whether DTM DOM implementation implements a specific feature and
that feature is supported by this node.
// %TBD%
return false;
|
public final int | makeNodeHandle(int nodeIdentity)Given a node identity, return a node handle. If extended addressing
has been used (multiple DTM IDs), we need to map the high bits of the
identity into the proper DTM ID.
This has been made FINAL to facilitate inlining, since we do not expect
any subclass of DTMDefaultBase to ever change the algorithm. (I don't
really like doing so, and would love to have an excuse not to...)
%REVIEW% Is it worth trying to specialcase small documents?
%REVIEW% Should this be exposed at the package/public layers?
if(NULL==nodeIdentity) return NULL;
if(JJK_DEBUG && nodeIdentity>DTMManager.IDENT_NODE_DEFAULT)
System.err.println("GONK! (only useful in limited situations)");
return m_dtmIdent.elementAt(nodeIdentity >>> DTMManager.IDENT_DTM_NODE_BITS)
+ (nodeIdentity & DTMManager.IDENT_NODE_DEFAULT) ;
|
public final int | makeNodeIdentity(int nodeHandle)Given a node handle, return a node identity. If extended addressing
has been used (multiple DTM IDs), we need to map the high bits of the
identity into the proper DTM ID and thence find the proper offset
to add to the low bits of the identity
This has been made FINAL to facilitate inlining, since we do not expect
any subclass of DTMDefaultBase to ever change the algorithm. (I don't
really like doing so, and would love to have an excuse not to...)
%OPT% Performance is critical for this operation.
%REVIEW% Should this be exposed at the package/public layers?
if(NULL==nodeHandle) return NULL;
if(m_mgrDefault!=null)
{
// Optimization: use the DTMManagerDefault's fast DTMID-to-offsets
// table. I'm not wild about this solution but this operation
// needs need extreme speed.
int whichDTMindex=nodeHandle>>>DTMManager.IDENT_DTM_NODE_BITS;
// %REVIEW% Wish I didn't have to perform the pre-test, but
// someone is apparently asking DTMs whether they contain nodes
// which really don't belong to them. That's probably a bug
// which should be fixed, but until it is:
if(m_mgrDefault.m_dtms[whichDTMindex]!=this)
return NULL;
else
return
m_mgrDefault.m_dtm_offsets[whichDTMindex]
| (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
}
int whichDTMid=m_dtmIdent.indexOf(nodeHandle & DTMManager.IDENT_DTM_DEFAULT);
return (whichDTMid==NULL)
? NULL
: (whichDTMid << DTMManager.IDENT_DTM_NODE_BITS)
+ (nodeHandle & DTMManager.IDENT_NODE_DEFAULT);
|
public void | migrateTo(com.sun.org.apache.xml.internal.dtm.DTMManager mgr)Migrate a DTM built with an old DTMManager to a new DTMManager.
After the migration, the new DTMManager will treat the DTM as
one that is built by itself.
This is used to support DTM sharing between multiple transformations.
m_mgr = mgr;
if(mgr instanceof DTMManagerDefault)
m_mgrDefault=(DTMManagerDefault)mgr;
|
protected abstract boolean | nextNode()This method should try and build one or more nodes in the table.
|
protected void | popShouldStripWhitespace()Set whether to strip whitespaces at this point by popping out
m_shouldStripWhitespaceStack.
if (null != m_shouldStripWhitespaceStack)
m_shouldStripWS = m_shouldStripWhitespaceStack.popAndTop();
|
protected void | pushShouldStripWhitespace(boolean shouldStrip)Set whether to strip whitespaces and push in current value of
m_shouldStripWS in m_shouldStripWhitespaceStack.
m_shouldStripWS = shouldStrip;
if (null != m_shouldStripWhitespaceStack)
m_shouldStripWhitespaceStack.push(shouldStrip);
|
public void | setDocumentBaseURI(java.lang.String baseURI)Set the base URI of the document entity.
m_documentBaseURI = baseURI;
|
public void | setFeature(java.lang.String featureId, boolean state)Set an implementation dependent feature.
%REVIEW% Do we really expect to set features on DTMs?
|
protected void | setShouldStripWhitespace(boolean shouldStrip)Set whether to strip whitespaces and set the top of the stack to
the current value of m_shouldStripWS.
m_shouldStripWS = shouldStrip;
if (null != m_shouldStripWhitespaceStack)
m_shouldStripWhitespaceStack.setTop(shouldStrip);
|
public boolean | supportsPreStripping()Return true if the xsl:strip-space or xsl:preserve-space was processed
during construction of the DTM document.
return true;
|