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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected char[]Deprecated.The shared document that the contents for this node are contained in.protected DOMNodeDeprecated.The first child of this node -nullwhen this node has no children.protected intDeprecated.This position is the position of the end of the last line separator before the closing brace starting position of the receiver.protected booleanDeprecated.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 DOMNodeDeprecated.The last child of this node -nullwhen this node has no children.protected StringDeprecated.The name of this node.protected int[]Deprecated.The original inclusive indicies of this node's name in the shared document.protected DOMNodeDeprecated.The sibling node following this node -nullfor the last node in the sibling list.protected DOMNodeDeprecated.The parent of this node.protected DOMNodeDeprecated.The sibling node preceding this node -nullfor the first node in the sibling list.protected int[]Deprecated.The original entire inclusive range of this node's contents within its document.protected intDeprecated.The current state of bit masks defined by this node.protected static final intDeprecated.A bit mask indicating this node has detailed source indexesprotected static final intDeprecated.A bit mask indicating this field has an initializer expressionprotected static final intDeprecated.A bit mask indicating this field is a secondary variable declarator for a previous field declaration.protected static final intDeprecated.A bit mask indicating this field's type has been altered from its original contents in the document.protected static final intDeprecated.A bit mask indicating this node currently has a body.protected static final intDeprecated.A bit mask indicating this node currently has a preceding comment.protected static final intDeprecated.A bit mask indicating this method is a constructor.protected static final intDeprecated.A bit mask indicating this node's name has been altered from its original contents in the document.protected static final intDeprecated.A bit mask indicating this return type of this method has been altered from the original contents.protected static final intDeprecated.A bit mask indicating this type implements or extends some interfacesprotected static final intDeprecated.A bit mask indicating this type has a superclass (requires or has an 'extends' clause).protected static final intDeprecated.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 TypeMethodDescriptionvoidDeprecated.Adds the given un-parented node (document fragment) as the last child of this node.protected voidappendContents(CharArrayBuffer buffer) Deprecated.Appends the current contents of this document fragment to the givenCharArrayBuffer.protected voidDeprecated.Appends the contents of all children of this node to the givenCharArrayBuffer.protected abstract voidDeprecated.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 voidDeprecated.Generates detailed source indexes for this node if possible.booleanDeprecated.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 voidfragment()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, ornullif this node has no contents.protected DOMNodeDeprecated.Returns a new document fragment representing this node with detailed source indexes.protected char[]Deprecated.Returns the document containing this node's original contents.intDeprecated.Returns the original position of the last character of this node's contents in its document.protected IDOMFactoryDeprecated.Returns a factory with which to create new document fragments.Deprecated.Returns the first child of this node.intDeprecated.Returns the position at which the first child of this node should be inserted.protected booleangetMask(int mask) Deprecated.Returnstrueif 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 intDeprecated.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 IDOMNodegetRoot()Deprecated.Returns the root node of this document fragment.intDeprecated.Returns the original position of the first character of this node's contents in its document.voidinsertSibling(IDOMNode sibling) Deprecated.Inserts the given un-parented node as a sibling of this node, immediately before this node.booleanisAllowableChild(IDOMNode node) Deprecated.Returns whether the given node is an allowable child for this node.protected booleanisContentMergableWith(DOMNode node) Deprecated.Returnstrueif 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 booleanDeprecated.Returnstrueif this node has detailed source index information, orfalseif this node has limited source index information.protected booleanDeprecated.Returnstrueif this node's or a descendant node's contents have been altered since this node was created.protected booleanDeprecated.Returnstrueif this noed's name has been altered from the original document contents.booleanisSignatureEqual(IDOMNode node) Deprecated.Returns whether this node's signature is equivalent to the given node's signature.protected voidDeprecated.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 DOMNodeDeprecated.Returns a new emptyDOMNodefor this instance.protected voidoffset(int offset) Deprecated.Offsets all the source indexes in this node by the given amount.protected voidoffsetRange(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.voidremove()Deprecated.Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment.protected voidsetMask(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.voidDeprecated.Sets the name of this node.protected voidsetNameAltered(boolean altered) Deprecated.Sets the state of this node as having its name attribute altered from the original document contents.protected voidsetSourceRangeEnd(int end) Deprecated.Sets the original position of the last character of this node's contents in its document.protected voidsetStartPosition(int start) Deprecated.Sets the original position of the first character of this node's contents in its document.protected voidshareContents(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 StringtoString()Deprecated.Returns aStringrepresenting this node - for Debug purposes only.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.aspectj.org.eclipse.jdt.core.jdom.IDOMNode
getJavaElement, getNodeType
-
Field Details
-
fFirstChild
Deprecated.The first child of this node -nullwhen this node has no children. (Children of a node are implemented as a doubly linked list). -
fLastChild
Deprecated.The last child of this node -nullwhen 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 -nullfor the last node in the sibling list. -
fParent
Deprecated.The parent of this node. Anullparent indicates that this node is a root node of a document fragment. -
fPreviousNode
Deprecated.The sibling node preceding this node -nullfor 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:
-
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:
-
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:
-
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:
-
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:
-
MASK_HAS_BODY
protected static final int MASK_HAS_BODYDeprecated.A bit mask indicating this node currently has a body.- See Also:
-
MASK_HAS_COMMENT
protected static final int MASK_HAS_COMMENTDeprecated.A bit mask indicating this node currently has a preceding comment.- See Also:
-
MASK_IS_CONSTRUCTOR
protected static final int MASK_IS_CONSTRUCTORDeprecated.A bit mask indicating this method is a constructor.- See Also:
-
MASK_TYPE_IS_CLASS
protected static final int MASK_TYPE_IS_CLASSDeprecated.A bit mask indicating this type is a class.- See Also:
-
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:
-
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:
-
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:
-
MASK_DETAILED_SOURCE_INDEXES
protected static final int MASK_DETAILED_SOURCE_INDEXESDeprecated.A bit mask indicating this node has detailed source indexes- See Also:
-
-
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:
addChildin interfaceIDOMNode- Parameters:
child- the new child node- Throws:
IllegalArgumentException- if the child isnullDOMException- 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:
-
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
IDOMNodeinterface method returns false; this method must be overridden by subclasses that implement nodes that allow children.- Specified by:
canHaveChildrenin interfaceIDOMNode- Returns:
trueif this node can have children- See Also:
-
clone
Deprecated.Description copied from interface:IDOMNodeReturns 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. -
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:IDOMNodeReturns 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:
getCharactersin interfaceIDOMNode- Returns:
- the contents, or
nullif this node has no contents - See Also:
-
getChild
-
getChildren
Deprecated.Description copied from interface:IDOMNodeReturns 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:
getChildrenin interfaceIDOMNode- Returns:
- an enumeration of the children
- See Also:
-
getContents
Deprecated.Returns the current contents of this document fragment, ornullif 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:
getContentsin interfaceIDOMNode- Returns:
- the contents, or
nullif this node has no contents - See Also:
-
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:IDOMNodeReturns the first child of this node. Children appear in the order in which they exist in the source code.- Specified by:
getFirstChildin interfaceIDOMNode- Returns:
- the first child, or
nullif this node has no children - See Also:
-
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.Returnstrueif the given mask of this node's state flag is turned on, otherwisefalse. -
getName
-
getNameContents
protected char[] getNameContents()Deprecated.Returns the source code to be used for this node's name. -
getNextNode
Deprecated.Description copied from interface:IDOMNodeReturns the sibling node immediately following this node.- Specified by:
getNextNodein interfaceIDOMNode- Returns:
- the next node, or
nullif there is no following node - See Also:
-
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:IDOMNodeReturns the sibling node immediately preceding this node.- Specified by:
getPreviousNodein interfaceIDOMNode- Returns:
- the previous node, or
nullif there is no preceding node - See Also:
-
getRoot
-
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:IDOMNodeInserts the given un-parented node as a sibling of this node, immediately before this node.- Specified by:
insertSiblingin interfaceIDOMNode- Parameters:
sibling- the new sibling node- Throws:
IllegalArgumentException- if the sibling isnullDOMException- 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:
-
isAllowableChild
Deprecated.Description copied from interface:IDOMNodeReturns whether the given node is an allowable child for this node.- Specified by:
isAllowableChildin interfaceIDOMNode- Parameters:
node- the potential child node- Returns:
trueif the given node is an allowable child- See Also:
-
isContentMergableWith
Deprecated.Returnstrueif 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.Returnstrueif this node has detailed source index information, orfalseif this node has limited source index information. To perform some manipulations, detailed indexes are required. -
isFragmented
protected boolean isFragmented()Deprecated.Returnstrueif 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.Returnstrueif this noed's name has been altered from the original document contents. -
isSignatureEqual
Deprecated.Description copied from interface:IDOMNodeReturns 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:
isSignatureEqualin interfaceIDOMNode- Parameters:
node- the other node- Returns:
trueif the nodes have equivalent signatures- See Also:
-
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
-
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.
-
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:IDOMNodeSets the name of this node. Name format depends on node type. More details are provided in each of the subtypes. -
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
-