org.cdlib.xtf.lazyTree
Class ElementImpl

Object
  extended by NodeImpl
      extended by ParentNodeImpl
          extended by ElementImpl
All Implemented Interfaces:
Source, SourceLocator, FingerprintedNode, Item, NodeInfo, ValueRepresentation
Direct Known Subclasses:
SearchElementImpl

public class ElementImpl
extends ParentNodeImpl

A node in the XML parse tree representing an XML element.

This class is an implementation of NodeInfo. The object is a wrapper around one entry in the arrays maintained by the LazyTree. Note that the same node might be represented by different LazyElementImpl objects at different times.

Author:
Michael H. Kay

Field Summary
(package private)  int[] attrNames
           
(package private)  String[] attrValues
           
(package private)  int nameSpace
           
 
Fields inherited from class ParentNodeImpl
childNum
 
Fields inherited from class NodeImpl
document, nameCode, nextSibNum, NODE_LETTER, nodeNum, parentNum, prevSibNum
 
Fields inherited from interface NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
ElementImpl()
           
 
Method Summary
 void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
          Copy this node to a given receiver
 String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 String getBaseURI()
          Get the base URI of this element node.
 int[] getDeclaredNamespaces(int[] buffer)
          Get all namespace undeclarations and undeclarations defined on this element.
(package private) static int[] getDeclaredNamespaces(LazyDocument doc, int nodeNr, int nameSpace, int[] buffer)
          Static method to get all namespace undeclarations and undeclarations defined on a given element, without instantiating the node object.
 int getNodeKind()
          Return the type of node.
 int getTypeAnnotation()
          Get the type annotation of this node, if any Returns Type.UNTYPED_ANY if there is no type annotation
 void init(int attrOffset, int nameSpace)
          Optional initialization function, depends on derived class
 void sendNamespaceDeclarations(Receiver out, boolean includeAncestors)
          Output all namespace nodes associated with this element.
 
Methods inherited from class ParentNodeImpl
enumerateChildren, getFirstChild, getLastChild, getStringValue, getStringValueCS, hasChildNodes, iterateAxis, iterateAxis
 
Methods inherited from class NodeImpl
atomize, compareOrder, equals, generateId, getColumnNumber, getConfiguration, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getLineNumber, getLocalPart, getNameCode, getNamePool, getNextInDocument, getNextSibling, getParent, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getRoot, getSequenceNumber, getSystemId, getTypedValue, getURI, hashCode, isSameNodeInfo, setSystemId
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameSpace

int nameSpace

attrNames

int[] attrNames

attrValues

String[] attrValues
Constructor Detail

ElementImpl

public ElementImpl()
Method Detail

init

public void init(int attrOffset,
                 int nameSpace)
          throws IOException
Description copied from class: NodeImpl
Optional initialization function, depends on derived class

Overrides:
init in class NodeImpl
Throws:
IOException

getNodeKind

public final int getNodeKind()
Return the type of node.

Returns:
Type.ELEMENT

getBaseURI

public String getBaseURI()
Get the base URI of this element node. This will be the same as the System ID unless xml:base has been used.

Specified by:
getBaseURI in interface NodeInfo
Overrides:
getBaseURI in class NodeImpl

getTypeAnnotation

public int getTypeAnnotation()
Get the type annotation of this node, if any Returns Type.UNTYPED_ANY if there is no type annotation

Specified by:
getTypeAnnotation in interface NodeInfo
Overrides:
getTypeAnnotation in class NodeImpl

sendNamespaceDeclarations

public void sendNamespaceDeclarations(Receiver out,
                                      boolean includeAncestors)
                               throws XPathException
Output all namespace nodes associated with this element.

Specified by:
sendNamespaceDeclarations in interface NodeInfo
Overrides:
sendNamespaceDeclarations in class NodeImpl
Parameters:
out - The relevant outputter
includeAncestors - True if namespaces associated with ancestor
Throws:
XPathException

getDeclaredNamespaces

public int[] getDeclaredNamespaces(int[] buffer)
Get all namespace undeclarations and undeclarations defined on this element.

Specified by:
getDeclaredNamespaces in interface NodeInfo
Overrides:
getDeclaredNamespaces in class NodeImpl
Parameters:
buffer - If this is non-null, and the result array fits in this buffer, then the result may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap.
Returns:
An array of integers representing the namespace declarations and undeclarations present on this element. For a node other than an element, return null. Otherwise, the returned array is a sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The top half word of each namespace code represents the prefix, the bottom half represents the URI. If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. The XML namespace is never included in the list. If the supplied array is larger than required, then the first unused entry will be set to -1.

For a node other than an element, the method returns null.


getDeclaredNamespaces

static int[] getDeclaredNamespaces(LazyDocument doc,
                                   int nodeNr,
                                   int nameSpace,
                                   int[] buffer)
Static method to get all namespace undeclarations and undeclarations defined on a given element, without instantiating the node object.

Parameters:
doc - The lazy document containing the given element node
nodeNr - The node number of the given element node within the tinyTree
buffer - If this is non-null, and the result array fits in this buffer, then the result may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap.
Returns:
An array of integers representing the namespace declarations and undeclarations present on this element. For a node other than an element, return null. Otherwise, the returned array is a sequence of namespace codes, whose meaning may be interpreted by reference to the name pool. The top half word of each namespace code represents the prefix, the bottom half represents the URI. If the bottom half is zero, then this is a namespace undeclaration rather than a declaration. The XML namespace is never included in the list. If the supplied array is larger than required, then the first unused entry will be set to -1.

For a node other than an element, the method returns null.


getAttributeValue

public String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node

Specified by:
getAttributeValue in interface NodeInfo
Overrides:
getAttributeValue in class NodeImpl
Parameters:
fingerprint - The fingerprint of the attribute name
Returns:
the attribute value if it exists or null if not

copy

public void copy(Receiver out,
                 int whichNamespaces,
                 boolean copyAnnotations,
                 int locationId)
          throws XPathException
Copy this node to a given receiver

Parameters:
whichNamespaces - indicates which namespaces should be copied: all, none, or local (i.e., those not declared on a parent element)
Throws:
XPathException