public abstract class DOMNode extends java.lang.Object implements IDOMNode
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.
IDOMNode| Modifier and Type | Field and Description |
|---|---|
protected char[] |
fDocument
Deprecated.
The shared document that the contents for this node
are contained in.
|
protected DOMNode |
fFirstChild
Deprecated.
The first child of this node -
null
when this node has no children. |
protected int |
fInsertionPosition
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 |
fIsFragmented
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 |
fLastChild
Deprecated.
The last child of this node -
null
when this node has no children. |
protected java.lang.String |
fName
Deprecated.
The name of this node.
|
protected int[] |
fNameRange
Deprecated.
The original inclusive indicies of this node's name in
the shared document.
|
protected DOMNode |
fNextNode
Deprecated.
The sibling node following this node -
null
for the last node in the sibling list. |
protected DOMNode |
fParent
Deprecated.
The parent of this node.
|
protected DOMNode |
fPreviousNode
Deprecated.
The sibling node preceding this node -
null
for the first node in the sibling list. |
protected int[] |
fSourceRange
Deprecated.
The original entire inclusive range of this node's contents
within its document.
|
protected int |
fStateMask
Deprecated.
The current state of bit masks defined by this node.
|
protected static int |
MASK_DETAILED_SOURCE_INDEXES
Deprecated.
A bit mask indicating this node has detailed source indexes
|
protected static int |
MASK_FIELD_HAS_INITIALIZER
Deprecated.
A bit mask indicating this field has an initializer
expression
|
protected static int |
MASK_FIELD_IS_VARIABLE_DECLARATOR
Deprecated.
A bit mask indicating this field is a secondary variable
declarator for a previous field declaration.
|
protected static int |
MASK_FIELD_TYPE_ALTERED
Deprecated.
A bit mask indicating this field's type has been
altered from its original contents in the document.
|
protected static int |
MASK_HAS_BODY
Deprecated.
A bit mask indicating this node currently has a
body.
|
protected static int |
MASK_HAS_COMMENT
Deprecated.
A bit mask indicating this node currently has a
preceding comment.
|
protected static int |
MASK_IS_CONSTRUCTOR
Deprecated.
A bit mask indicating this method is a constructor.
|
protected static int |
MASK_NAME_ALTERED
Deprecated.
A bit mask indicating this node's name has been
altered from its original contents in the document.
|
protected static int |
MASK_RETURN_TYPE_ALTERED
Deprecated.
A bit mask indicating this return type of this method has
been altered from the original contents.
|
protected static int |
MASK_TYPE_HAS_INTERFACES
Deprecated.
A bit mask indicating this type implements
or extends some interfaces
|
protected static int |
MASK_TYPE_HAS_SUPERCLASS
Deprecated.
A bit mask indicating this type has a superclass
(requires or has an 'extends' clause).
|
protected static int |
MASK_TYPE_IS_CLASS
Deprecated.
A bit mask indicating this type is a class.
|
COMPILATION_UNIT, FIELD, IMPORT, INITIALIZER, METHOD, PACKAGE, TYPE| Modifier and Type | Method and Description |
|---|---|
void |
addChild(IDOMNode child)
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 given
CharArrayBuffer. |
protected void |
appendContentsOfChildren(CharArrayBuffer buffer)
Deprecated.
Appends the contents of all children of this node to the
given
CharArrayBuffer. |
protected abstract void |
appendFragmentedContents(CharArrayBuffer buffer)
Deprecated.
Appends the contents of this node to the given
CharArrayBufer, using
the original document and indicies as a form for the current attribute
values of this node. |
protected void |
becomeDetailed()
Deprecated.
Generates detailed source indexes for this node if possible.
|
boolean |
canHaveChildren()
Deprecated.
Returns true if this node is allowed to have children, otherwise false.
|
java.lang.Object |
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
to
true |
char[] |
getCharacters()
Deprecated.
Returns the current contents of this document fragment as a character array.
|
IDOMNode |
getChild(java.lang.String name)
Deprecated.
Returns the first named child of this node with the given name.
|
java.util.Enumeration |
getChildren()
Deprecated.
Returns an enumeration of children of this node.
|
java.lang.String |
getContents()
Deprecated.
Returns the current contents of this document fragment,
or
null if this node has no contents. |
protected DOMNode |
getDetailedNode()
Deprecated.
Returns a new document fragment representing this node with
detailed source indexes.
|
protected char[] |
getDocument()
Deprecated.
Returns the document containing this node's original contents.
|
int |
getEndPosition()
Deprecated.
Returns the original position of the last character of this
node's contents in its document.
|
protected IDOMFactory |
getFactory()
Deprecated.
Returns a factory with which to create new document fragments.
|
IDOMNode |
getFirstChild()
Deprecated.
Returns the first child of this node.
|
int |
getInsertionPosition()
Deprecated.
Returns the position at which the first child of this node should be inserted.
|
protected boolean |
getMask(int mask)
Deprecated.
Returns
true if the given mask of this node's state flag
is turned on, otherwise false. |
java.lang.String |
getName()
Deprecated.
Returns the name of this node.
|
protected char[] |
getNameContents()
Deprecated.
Returns the source code to be used for this node's name.
|
IDOMNode |
getNextNode()
Deprecated.
Returns the sibling node immediately following this node.
|
IDOMNode |
getParent()
Deprecated.
Returns the parent of this node.
|
protected int |
getParentEndDeclaration()
Deprecated.
Answers a source position which corresponds to the end of the parent
element's declaration.
|
IDOMNode |
getPreviousNode()
Deprecated.
Returns the sibling node immediately preceding this node.
|
protected IDOMNode |
getRoot()
Deprecated.
Returns the root node of this document fragment.
|
int |
getStartPosition()
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.
Returns
true 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 -
otherwise false. |
protected boolean |
isDetailed()
Deprecated.
Returns
true if this node has detailed source index information,
or false if this node has limited source index information. |
protected boolean |
isFragmented()
Deprecated.
Returns
true if this node's or a descendant node's contents
have been altered since this node was created. |
protected boolean |
isNameAltered()
Deprecated.
Returns
true 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 |
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.
|
protected abstract DOMNode |
newDOMNode()
Deprecated.
Returns a new empty
DOMNode 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 amount
|
protected 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 |
setName(java.lang.String name)
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 java.lang.String |
toString()
Deprecated.
Returns a
String representing this node - for Debug purposes only. |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetJavaElement, getNodeTypeprotected DOMNode fFirstChild
null
when this node has no children. (Children of a node
are implemented as a doubly linked list).protected DOMNode fLastChild
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.protected DOMNode fNextNode
null
for the last node in the sibling list.protected DOMNode fParent
null
parent indicates that this node is a root
node of a document fragment.protected DOMNode fPreviousNode
null
for the first node in the sibling list.protected boolean fIsFragmented
protected java.lang.String fName
protected int[] fNameRange
protected char[] fDocument
protected int[] fSourceRange
protected int fStateMask
setMask(int, boolean),
getMask(int)protected int fInsertionPosition
protected static final int MASK_FIELD_HAS_INITIALIZER
protected static final int MASK_FIELD_IS_VARIABLE_DECLARATOR
protected static final int MASK_FIELD_TYPE_ALTERED
protected static final int MASK_NAME_ALTERED
protected static final int MASK_HAS_BODY
protected static final int MASK_HAS_COMMENT
protected static final int MASK_IS_CONSTRUCTOR
protected static final int MASK_TYPE_IS_CLASS
protected static final int MASK_TYPE_HAS_SUPERCLASS
protected static final int MASK_TYPE_HAS_INTERFACES
protected static final int MASK_RETURN_TYPE_ALTERED
protected static final int MASK_DETAILED_SOURCE_INDEXES
public void addChild(IDOMNode child) throws java.lang.IllegalArgumentException, DOMException
When a child is added, this node must be considered fragmented such that the contents of this node are properly generated.
addChild in interface IDOMNodechild - the new child nodejava.lang.IllegalArgumentException - if the child is nullDOMException - if any of the following conditions hold:IDOMNode.addChild(IDOMNode)protected void appendContents(CharArrayBuffer buffer)
CharArrayBuffer.
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.
protected void appendContentsOfChildren(CharArrayBuffer buffer)
CharArrayBuffer.
This algorithm used minimizes String generation by merging adjacent unfragmented children into one substring operation.
protected abstract void appendFragmentedContents(CharArrayBuffer buffer)
CharArrayBufer, using
the original document and indicies as a form for the current attribute
values of this node.protected void becomeDetailed()
throws DOMException
DOMException - if unable to generate detailed source indexes
for this nodepublic boolean canHaveChildren()
Default implementation of IDOMNode interface method returns false; this
method must be overridden by subclasses that implement nodes that allow
children.
canHaveChildren in interface IDOMNodetrue if this node can have childrenIDOMNode.canHaveChildren()public java.lang.Object clone()
IDOMNodeclone in interface IDOMNodeclone in class java.lang.ObjectIDOMNodeIDOMNode.clone()protected void fragment()
true. 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.public char[] getCharacters()
IDOMNodeNote: To obtain complete source for the source file, ask a compilation unit node for its contents.
getCharacters in interface IDOMNodenull if this node has no contentsIDOMNode.getCharacters()public IDOMNode getChild(java.lang.String name)
IDOMNodegetChild in interface IDOMNodename - the namenull if no such child existsIDOMNode.getChild(String)public java.util.Enumeration getChildren()
IDOMNodegetChildren in interface IDOMNodeIDOMNode.getChildren()public java.lang.String getContents()
null 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.
getContents in interface IDOMNodenull if this node has no contentsIDOMNode.getContents()protected DOMNode getDetailedNode()
protected char[] getDocument()
public int getEndPosition()
protected IDOMFactory getFactory()
public IDOMNode getFirstChild()
IDOMNodegetFirstChild in interface IDOMNodenull if this node has no childrenIDOMNode.getFirstChild()public int getInsertionPosition()
protected boolean getMask(int mask)
true if the given mask of this node's state flag
is turned on, otherwise false.public java.lang.String getName()
IDOMNodegetName in interface IDOMNodenull if it has no nameIDOMNode.getName()protected char[] getNameContents()
public IDOMNode getNextNode()
IDOMNodegetNextNode in interface IDOMNodenull if there is no following nodeIDOMNode.getNextNode()public IDOMNode getParent()
IDOMNodegetParent in interface IDOMNodenull if this node does not have a
parentIDOMNode.getParent()protected int getParentEndDeclaration()
public IDOMNode getPreviousNode()
IDOMNodegetPreviousNode in interface IDOMNodenull if there is no preceding nodeIDOMNode.getPreviousNode()protected IDOMNode getRoot()
public int getStartPosition()
public void insertSibling(IDOMNode sibling) throws java.lang.IllegalArgumentException, DOMException
IDOMNodeinsertSibling in interface IDOMNodesibling - the new sibling nodejava.lang.IllegalArgumentException - if the sibling is nullDOMException - if any of the following conditions hold:IDOMNode.insertSibling(IDOMNode)public boolean isAllowableChild(IDOMNode node)
IDOMNodeisAllowableChild in interface IDOMNodenode - the potential child nodetrue if the given node is an allowable childIDOMNodeprotected boolean isContentMergableWith(DOMNode node)
true 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 -
otherwise false.protected boolean isDetailed()
true if this node has detailed source index information,
or false if this node has limited source index information. To
perform some manipulations, detailed indexes are required.protected boolean isFragmented()
true 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.protected boolean isNameAltered()
true if this noed's name has been altered
from the original document contents.public boolean isSignatureEqual(IDOMNode node)
IDOMNodeisSignatureEqual in interface IDOMNodenode - the other nodetrue if the nodes have equivalent signaturesBy 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.
protected void localizeContents()
protected abstract DOMNode newDOMNode()
DOMNode for this instance.protected void offset(int offset)
protected void offsetRange(int[] range,
int offset)
protected int[] rangeCopy(int[] range)
public void remove()
When a child is removed, its parent is fragmented such that it properly generates its contents.
remove in interface IDOMNodeIDOMNode.remove()protected void setMask(int mask,
boolean on)
public void setName(java.lang.String name)
IDOMNodesetName in interface IDOMNodename - the name, or null to clear the nameIDOMNode.setName(java.lang.String)protected void setNameAltered(boolean altered)
protected void setSourceRangeEnd(int end)
protected void setStartPosition(int start)
protected void shareContents(DOMNode node)
public abstract java.lang.String toString()
String representing this node - for Debug purposes only.toString in class java.lang.Object