Class DOMNode
IDOMNode
.
A node represents a document fragment. When a node is created, its contents are located in a contiguous range of a shared document. A shared document is a char array, and is shared in the sense that the contents of other document fragments may also be contained in the array.
A node maintains indicies of relevant portions of its contents in the shared document. Thus the original document and indicies create a form from which to generate the contents of the document fragment. As attributes of a node are changed, the node attempts to maintain the original formatting by only replacing relevant portions of the shared document with the value of new attributes (that is, filling in the form with replacement values).
When a node is first created, it is considered unfragmented. When any attribute of the node is altered, the node is then considered fragmented from that point on. A node is also considered fragmented if any of its descendants are fragmented. When a node is unfragmented, the contents of the node can be efficiently generated from the original shared document. When a node is fragmented, the contents of the node must be created using the original document and indicies as a form, filling in replacement values as required.
Generally, a node's contents consists of complete lines in a shared document. The contents of the node are normalized on creation to include any whitespace preceding the node on the line where the node begins, and to include and trailing whitespace up to the line where the next node begins. Any trailing // comments that begin on the line where the current node ends, are considered part of that node.
- See Also:
IDOMNode
-
Field Summary
Modifier and TypeFieldDescriptionprotected char[]
Deprecated.The shared document that the contents for this node are contained in.protected DOMNode
Deprecated.The first child of this node -null
when this node has no children.protected int
Deprecated.This position is the position of the end of the last line separator before the closing brace starting position of the receiver.protected boolean
Deprecated.True when this node has attributes that have been altered from their original state in the shared document, or when the attributes of a descendant have been altered.protected DOMNode
Deprecated.The last child of this node -null
when this node has no children.protected String
Deprecated.The name of this node.protected int[]
Deprecated.The original inclusive indicies of this node's name in the shared document.protected DOMNode
Deprecated.The sibling node following this node -null
for the last node in the sibling list.protected DOMNode
Deprecated.The parent of this node.protected DOMNode
Deprecated.The sibling node preceding this node -null
for the first node in the sibling list.protected int[]
Deprecated.The original entire inclusive range of this node's contents within its document.protected int
Deprecated.The current state of bit masks defined by this node.protected static int
Deprecated.A bit mask indicating this node has detailed source indexesprotected static int
Deprecated.A bit mask indicating this field has an initializer expressionprotected static int
Deprecated.A bit mask indicating this field is a secondary variable declarator for a previous field declaration.protected static int
Deprecated.A bit mask indicating this field's type has been altered from its original contents in the document.protected static int
Deprecated.A bit mask indicating this node currently has a body.protected static int
Deprecated.A bit mask indicating this node currently has a preceding comment.protected static int
Deprecated.A bit mask indicating this method is a constructor.protected static int
Deprecated.A bit mask indicating this node's name has been altered from its original contents in the document.protected static int
Deprecated.A bit mask indicating this return type of this method has been altered from the original contents.protected static int
Deprecated.A bit mask indicating this type implements or extends some interfacesprotected static int
Deprecated.A bit mask indicating this type has a superclass (requires or has an 'extends' clause).protected static int
Deprecated.A bit mask indicating this type is a class.Fields inherited from interface org.aspectj.org.eclipse.jdt.core.jdom.IDOMNode
COMPILATION_UNIT, FIELD, IMPORT, INITIALIZER, METHOD, PACKAGE, TYPE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Adds the given un-parented node (document fragment) as the last child of this node.protected void
appendContents(CharArrayBuffer buffer)
Deprecated.Appends the current contents of this document fragment to the givenCharArrayBuffer
.protected void
appendContentsOfChildren(CharArrayBuffer buffer)
Deprecated.Appends the contents of all children of this node to the givenCharArrayBuffer
.protected abstract void
appendFragmentedContents(CharArrayBuffer buffer)
Deprecated.Appends the contents of this node to the givenCharArrayBufer
, using the original document and indicies as a form for the current attribute values of this node.protected void
Deprecated.Generates detailed source indexes for this node if possible.boolean
Deprecated.Returns true if this node is allowed to have children, otherwise false.clone()
Deprecated.Returns a stand-alone copy of the document fragment represented by this node that is in no way dependent on the document this node is part of.protected void
fragment()
Deprecated.Sets this node's fragmented flag and all ancestor fragmented flags totrue
.
char[]
Deprecated.Returns the current contents of this document fragment as a character array.Deprecated.Returns the first named child of this node with the given name.Deprecated.Returns an enumeration of children of this node.Deprecated.Returns the current contents of this document fragment, ornull
if this node has no contents.protected DOMNode
Deprecated.Returns a new document fragment representing this node with detailed source indexes.protected char[]
Deprecated.Returns the document containing this node's original contents.int
Deprecated.Returns the original position of the last character of this node's contents in its document.protected IDOMFactory
Deprecated.Returns a factory with which to create new document fragments.Deprecated.Returns the first child of this node.int
Deprecated.Returns the position at which the first child of this node should be inserted.protected boolean
getMask(int mask)
Deprecated.Returnstrue
if the given mask of this node's state flag is turned on, otherwisefalse
.getName()
Deprecated.Returns the name of this node.protected char[]
Deprecated.Returns the source code to be used for this node's name.Deprecated.Returns the sibling node immediately following this node.Deprecated.Returns the parent of this node.protected int
Deprecated.Answers a source position which corresponds to the end of the parent element's declaration.Deprecated.Returns the sibling node immediately preceding this node.protected IDOMNode
getRoot()
Deprecated.Returns the root node of this document fragment.int
Deprecated.Returns the original position of the first character of this node's contents in its document.void
insertSibling(IDOMNode sibling)
Deprecated.Inserts the given un-parented node as a sibling of this node, immediately before this node.boolean
isAllowableChild(IDOMNode node)
Deprecated.Returns whether the given node is an allowable child for this node.protected boolean
isContentMergableWith(DOMNode node)
Deprecated.Returnstrue
if the contents of this node are from the same document as the given node, the contents of this node immediately follow the contents of the given node, and neither this node or the given node are fragmented - otherwisefalse
.protected boolean
Deprecated.Returnstrue
if this node has detailed source index information, orfalse
if this node has limited source index information.protected boolean
Deprecated.Returnstrue
if this node's or a descendant node's contents have been altered since this node was created.protected boolean
Deprecated.Returnstrue
if this noed's name has been altered from the original document contents.boolean
isSignatureEqual(IDOMNode node)
Deprecated.Returns whether this node's signature is equivalent to the given node's signature.protected void
Deprecated.Localizes the contents of this node and all descendant nodes, such that this node is no longer dependent on its original document in order to generate its contents.protected abstract DOMNode
Deprecated.Returns a new emptyDOMNode
for this instance.protected void
offset(int offset)
Deprecated.Offsets all the source indexes in this node by the given amount.protected void
offsetRange(int[] range, int offset)
Deprecated.Offsets the source range by the given amountprotected int[]
rangeCopy(int[] range)
Deprecated.Returns a copy of the given range.void
remove()
Deprecated.Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment.protected void
setMask(int mask, boolean on)
Deprecated.Sets the specified mask of this node's state mask on or off based on the boolean value - true -> on, false -> off.void
Deprecated.Sets the name of this node.protected void
setNameAltered(boolean altered)
Deprecated.Sets the state of this node as having its name attribute altered from the original document contents.protected void
setSourceRangeEnd(int end)
Deprecated.Sets the original position of the last character of this node's contents in its document.protected void
setStartPosition(int start)
Deprecated.Sets the original position of the first character of this node's contents in its document.protected void
shareContents(DOMNode node)
Deprecated.Sets the contents of this node and descendant nodes to be the (identical) contents of the given node and its descendants.abstract String
toString()
Deprecated.Returns aString
representing this node - for Debug purposes only.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.aspectj.org.eclipse.jdt.core.jdom.IDOMNode
getJavaElement, getNodeType
-
Field Details
-
fFirstChild
Deprecated.The first child of this node -null
when this node has no children. (Children of a node are implemented as a doubly linked list). -
fLastChild
Deprecated.The last child of this node -null
when this node has no children. Used for efficient access to the last child when adding new children at the end of the linked list of children. -
fNextNode
Deprecated.The sibling node following this node -null
for the last node in the sibling list. -
fParent
Deprecated.The parent of this node. Anull
parent indicates that this node is a root node of a document fragment. -
fPreviousNode
Deprecated.The sibling node preceding this node -null
for the first node in the sibling list. -
fIsFragmented
protected boolean fIsFragmentedDeprecated.True when this node has attributes that have been altered from their original state in the shared document, or when the attributes of a descendant have been altered. False when the contents of this node and all descendants are consistent with the content of the shared document. -
fName
Deprecated.The name of this node. For efficiency, the name of a node is duplicated in this variable on creation, rather than always having to fetch the name from the shared document. -
fNameRange
protected int[] fNameRangeDeprecated.The original inclusive indicies of this node's name in the shared document. Values of -1 indiciate the name does not exist in the document. -
fDocument
protected char[] fDocumentDeprecated.The shared document that the contents for this node are contained in. Attribute indicies are positions in this character array. -
fSourceRange
protected int[] fSourceRangeDeprecated.The original entire inclusive range of this node's contents within its document. Values of -1 indicate the contents of this node do not exist in the document. -
fStateMask
protected int fStateMaskDeprecated.The current state of bit masks defined by this node. Initially all bit flags are turned off. All bit masks are defined by this class to avoid overlap, although bit masks are node type specific.- See Also:
setMask(int, boolean)
,getMask(int)
-
fInsertionPosition
protected int fInsertionPositionDeprecated.This position is the position of the end of the last line separator before the closing brace starting position of the receiver. -
MASK_FIELD_HAS_INITIALIZER
protected static final int MASK_FIELD_HAS_INITIALIZERDeprecated.A bit mask indicating this field has an initializer expression- See Also:
- Constant Field Values
-
MASK_FIELD_IS_VARIABLE_DECLARATOR
protected static final int MASK_FIELD_IS_VARIABLE_DECLARATORDeprecated.A bit mask indicating this field is a secondary variable declarator for a previous field declaration.- See Also:
- Constant Field Values
-
MASK_FIELD_TYPE_ALTERED
protected static final int MASK_FIELD_TYPE_ALTEREDDeprecated.A bit mask indicating this field's type has been altered from its original contents in the document.- See Also:
- Constant Field Values
-
MASK_NAME_ALTERED
protected static final int MASK_NAME_ALTEREDDeprecated.A bit mask indicating this node's name has been altered from its original contents in the document.- See Also:
- Constant Field Values
-
MASK_HAS_BODY
protected static final int MASK_HAS_BODYDeprecated.A bit mask indicating this node currently has a body.- See Also:
- Constant Field Values
-
MASK_HAS_COMMENT
protected static final int MASK_HAS_COMMENTDeprecated.A bit mask indicating this node currently has a preceding comment.- See Also:
- Constant Field Values
-
MASK_IS_CONSTRUCTOR
protected static final int MASK_IS_CONSTRUCTORDeprecated.A bit mask indicating this method is a constructor.- See Also:
- Constant Field Values
-
MASK_TYPE_IS_CLASS
protected static final int MASK_TYPE_IS_CLASSDeprecated.A bit mask indicating this type is a class.- See Also:
- Constant Field Values
-
MASK_TYPE_HAS_SUPERCLASS
protected static final int MASK_TYPE_HAS_SUPERCLASSDeprecated.A bit mask indicating this type has a superclass (requires or has an 'extends' clause).- See Also:
- Constant Field Values
-
MASK_TYPE_HAS_INTERFACES
protected static final int MASK_TYPE_HAS_INTERFACESDeprecated.A bit mask indicating this type implements or extends some interfaces- See Also:
- Constant Field Values
-
MASK_RETURN_TYPE_ALTERED
protected static final int MASK_RETURN_TYPE_ALTEREDDeprecated.A bit mask indicating this return type of this method has been altered from the original contents.- See Also:
- Constant Field Values
-
MASK_DETAILED_SOURCE_INDEXES
protected static final int MASK_DETAILED_SOURCE_INDEXESDeprecated.A bit mask indicating this node has detailed source indexes- See Also:
- Constant Field Values
-
-
Method Details
-
addChild
Deprecated.Adds the given un-parented node (document fragment) as the last child of this node.When a child is added, this node must be considered fragmented such that the contents of this node are properly generated.
- Specified by:
addChild
in interfaceIDOMNode
- Parameters:
child
- the new child node- Throws:
IllegalArgumentException
- if the child isnull
DOMException
- if any of the following conditions hold:- this node is not allowed to have children,
- the child is not of an allowable type
- the child already has a parent
- the child is an ancestor of this node
- See Also:
IDOMNode.addChild(IDOMNode)
-
appendContents
Deprecated.Appends the current contents of this document fragment to the givenCharArrayBuffer
.If this node is fragmented, contents must be generated by using the original document and indicies as a form for the current attribute values of this node. If this node not fragmented, the contents can be obtained from the document.
-
appendContentsOfChildren
Deprecated.Appends the contents of all children of this node to the givenCharArrayBuffer
.This algorithm used minimizes String generation by merging adjacent unfragmented children into one substring operation.
-
appendFragmentedContents
Deprecated.Appends the contents of this node to the givenCharArrayBufer
, using the original document and indicies as a form for the current attribute values of this node. -
becomeDetailed
Deprecated.Generates detailed source indexes for this node if possible.- Throws:
DOMException
- if unable to generate detailed source indexes for this node
-
canHaveChildren
public boolean canHaveChildren()Deprecated.Returns true if this node is allowed to have children, otherwise false.Default implementation of
IDOMNode
interface method returns false; this method must be overridden by subclasses that implement nodes that allow children.- Specified by:
canHaveChildren
in interfaceIDOMNode
- Returns:
true
if this node can have children- See Also:
IDOMNode.canHaveChildren()
-
clone
Deprecated.Description copied from interface:IDOMNode
Returns a stand-alone copy of the document fragment represented by this node that is in no way dependent on the document this node is part of.- Specified by:
clone
in interfaceIDOMNode
- Overrides:
clone
in classObject
- Returns:
- a copy of type
IDOMNode
- See Also:
IDOMNode.clone()
-
fragment
protected void fragment()Deprecated.Sets this node's fragmented flag and all ancestor fragmented flags totrue
. This happens when an attribute of this node or a descendant node has been altered. When a node is fragmented, its contents must be generated from its attributes and original "form" rather than from the original contents in the document.
-
getCharacters
public char[] getCharacters()Deprecated.Description copied from interface:IDOMNode
Returns the current contents of this document fragment as a character array.Note: To obtain complete source for the source file, ask a compilation unit node for its contents.
- Specified by:
getCharacters
in interfaceIDOMNode
- Returns:
- the contents, or
null
if this node has no contents - See Also:
IDOMNode.getCharacters()
-
getChild
Deprecated.Description copied from interface:IDOMNode
Returns the first named child of this node with the given name.- Specified by:
getChild
in interfaceIDOMNode
- Parameters:
name
- the name- Returns:
- the child node, or
null
if no such child exists - See Also:
IDOMNode.getChild(String)
-
getChildren
Deprecated.Description copied from interface:IDOMNode
Returns an enumeration of children of this node. Returns an empty enumeration if this node has no children (including nodes that cannot have children). Children appear in the order in which they are declared in the source code.- Specified by:
getChildren
in interfaceIDOMNode
- Returns:
- an enumeration of the children
- See Also:
IDOMNode.getChildren()
-
getContents
Deprecated.Returns the current contents of this document fragment, ornull
if this node has no contents.If this node is fragmented, contents must be generated by using the original document and indicies as a form for the current attribute values of this node. If this node not fragmented, the contents can be obtained from the document.
- Specified by:
getContents
in interfaceIDOMNode
- Returns:
- the contents, or
null
if this node has no contents - See Also:
IDOMNode.getContents()
-
getDetailedNode
Deprecated.Returns a new document fragment representing this node with detailed source indexes. Subclasses that provide a detailed implementation must override this method. -
getDocument
protected char[] getDocument()Deprecated.Returns the document containing this node's original contents. The document may be shared by other nodes. -
getEndPosition
public int getEndPosition()Deprecated.Returns the original position of the last character of this node's contents in its document. -
getFactory
Deprecated.Returns a factory with which to create new document fragments. -
getFirstChild
Deprecated.Description copied from interface:IDOMNode
Returns the first child of this node. Children appear in the order in which they exist in the source code.- Specified by:
getFirstChild
in interfaceIDOMNode
- Returns:
- the first child, or
null
if this node has no children - See Also:
IDOMNode.getFirstChild()
-
getInsertionPosition
public int getInsertionPosition()Deprecated.Returns the position at which the first child of this node should be inserted. -
getMask
protected boolean getMask(int mask)Deprecated.Returnstrue
if the given mask of this node's state flag is turned on, otherwisefalse
. -
getName
Deprecated.Description copied from interface:IDOMNode
Returns the name of this node. More details are provided in each of the subtypes.- Specified by:
getName
in interfaceIDOMNode
- Returns:
- the name, or
null
if it has no name - See Also:
IDOMNode.getName()
-
getNameContents
protected char[] getNameContents()Deprecated.Returns the source code to be used for this node's name. -
getNextNode
Deprecated.Description copied from interface:IDOMNode
Returns the sibling node immediately following this node.- Specified by:
getNextNode
in interfaceIDOMNode
- Returns:
- the next node, or
null
if there is no following node - See Also:
IDOMNode.getNextNode()
-
getParent
Deprecated.Description copied from interface:IDOMNode
Returns the parent of this node.- Specified by:
getParent
in interfaceIDOMNode
- Returns:
- the parent node, or
null
if this node does not have a parent - See Also:
IDOMNode.getParent()
-
getParentEndDeclaration
protected int getParentEndDeclaration()Deprecated.Answers a source position which corresponds to the end of the parent element's declaration. -
getPreviousNode
Deprecated.Description copied from interface:IDOMNode
Returns the sibling node immediately preceding this node.- Specified by:
getPreviousNode
in interfaceIDOMNode
- Returns:
- the previous node, or
null
if there is no preceding node - See Also:
IDOMNode.getPreviousNode()
-
getRoot
Deprecated.Returns the root node of this document fragment. -
getStartPosition
public int getStartPosition()Deprecated.Returns the original position of the first character of this node's contents in its document. -
insertSibling
Deprecated.Description copied from interface:IDOMNode
Inserts the given un-parented node as a sibling of this node, immediately before this node.- Specified by:
insertSibling
in interfaceIDOMNode
- Parameters:
sibling
- the new sibling node- Throws:
IllegalArgumentException
- if the sibling isnull
DOMException
- if any of the following conditions hold:- this node is a document fragment root
- the sibling is not of the correct type
- the sibling already has a parent
- this sibling is an ancestor of this node
- See Also:
IDOMNode.insertSibling(IDOMNode)
-
isAllowableChild
Deprecated.Description copied from interface:IDOMNode
Returns whether the given node is an allowable child for this node.- Specified by:
isAllowableChild
in interfaceIDOMNode
- Parameters:
node
- the potential child node- Returns:
true
if the given node is an allowable child- See Also:
IDOMNode
-
isContentMergableWith
Deprecated.Returnstrue
if the contents of this node are from the same document as the given node, the contents of this node immediately follow the contents of the given node, and neither this node or the given node are fragmented - otherwisefalse
. -
isDetailed
protected boolean isDetailed()Deprecated.Returnstrue
if this node has detailed source index information, orfalse
if this node has limited source index information. To perform some manipulations, detailed indexes are required. -
isFragmented
protected boolean isFragmented()Deprecated.Returnstrue
if this node's or a descendant node's contents have been altered since this node was created. This indicates that the contents of this node are no longer consistent with the contents of this node's document. -
isNameAltered
protected boolean isNameAltered()Deprecated.Returnstrue
if this noed's name has been altered from the original document contents. -
isSignatureEqual
Deprecated.Description copied from interface:IDOMNode
Returns whether this node's signature is equivalent to the given node's signature. In other words, if the nodes were siblings, would the declarations collide because they represent the same declaration.- Specified by:
isSignatureEqual
in interfaceIDOMNode
- Parameters:
node
- the other node- Returns:
true
if the nodes have equivalent signatures- See Also:
By default, the signatures of two nodes are equal if their type and names are equal. Node types that have other requirements for equality must override this method.
-
localizeContents
protected void localizeContents()Deprecated.Localizes the contents of this node and all descendant nodes, such that this node is no longer dependent on its original document in order to generate its contents. This node and all descendant nodes become unfragmented and share a new document. -
newDOMNode
Deprecated.Returns a new emptyDOMNode
for this instance. -
offset
protected void offset(int offset)Deprecated.Offsets all the source indexes in this node by the given amount. -
offsetRange
protected void offsetRange(int[] range, int offset)Deprecated.Offsets the source range by the given amount -
rangeCopy
protected int[] rangeCopy(int[] range)Deprecated.Returns a copy of the given range. -
remove
public void remove()Deprecated.Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment.When a child is removed, its parent is fragmented such that it properly generates its contents.
- Specified by:
remove
in interfaceIDOMNode
- See Also:
IDOMNode.remove()
-
setMask
protected void setMask(int mask, boolean on)Deprecated.Sets the specified mask of this node's state mask on or off based on the boolean value - true -> on, false -> off. -
setName
Deprecated.Description copied from interface:IDOMNode
Sets the name of this node. Name format depends on node type. More details are provided in each of the subtypes.- Specified by:
setName
in interfaceIDOMNode
- Parameters:
name
- the name, ornull
to clear the name- See Also:
IDOMNode.setName(java.lang.String)
-
setNameAltered
protected void setNameAltered(boolean altered)Deprecated.Sets the state of this node as having its name attribute altered from the original document contents. -
setSourceRangeEnd
protected void setSourceRangeEnd(int end)Deprecated.Sets the original position of the last character of this node's contents in its document. This method is only used during DOM creation while normalizing the source range of each node. -
setStartPosition
protected void setStartPosition(int start)Deprecated.Sets the original position of the first character of this node's contents in its document. This method is only used during DOM creation while normalizing the source range of each node. -
toString
Deprecated.Returns aString
representing this node - for Debug purposes only.
-