|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IDOMNode
Nodes represent structural fragments of a Java source file, also known as document fragments. Their implementation
is known as a DOM (Document Object Model) - in this case a JDOM (Java DOM). A root node (node
with no parent or siblings) represents the root of a document fragment (DF). A complete Java document is
represented by a compilation unit node (IDOMCompilationUnit
). In this way, a DF is
comprised of DFs, and a document itself (compilation unit) is also a DF.
A DF may be created empty and programmatically filled, or it may be created from
a source code string. The IDOMFactory
allows the creation of all kinds
of nodes from source code strings. Manipulations performed on a DF are immediately
reflected in the DF's contents.
Children fragments are represented as a linked list of nodes. Children are inserted via their parent node, and are automatically linked up with previous and next nodes.
The contents of any node (DF) may be retrieved at any time. In this way it is possible to retrieve source code representing fragments of the compilation unit (for example, a type or a method), since the contents of any node (not just the root node) may be obtained.
The following manipulations on DFs are distinct:
Wherever types are specified in DOM APIs, type names must be specified as they would appear
in source code. The DOM does not have a notion of type signatures, only raw text. Example type
names are "Object"
, "java.io.File"
, and "int[]"
.
Field Summary | |
---|---|
static int |
COMPILATION_UNIT
Deprecated. Node type constant indicating a compilation unit. |
static int |
FIELD
Deprecated. Node type constant indicating a field declaration. |
static int |
IMPORT
Deprecated. Node type constant indicating an import declaration. |
static int |
INITIALIZER
Deprecated. Node type constant indicating an initializer declaration. |
static int |
METHOD
Deprecated. Node type constant indicating a method (or constructor) declaration. |
static int |
PACKAGE
Deprecated. Node type constant indicating a package declaration. |
static int |
TYPE
Deprecated. Node type constant indicating a type declaration. |
Method Summary | |
---|---|
void |
addChild(IDOMNode child)
Deprecated. Adds the given un-parented node (document fragment) as the last child of this node. |
boolean |
canHaveChildren()
Deprecated. Returns whether this node is allowed to have children. |
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. |
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. |
IDOMNode |
getFirstChild()
Deprecated. Returns the first child of this node. |
IJavaElement |
getJavaElement(IJavaElement parent)
Deprecated. Returns a handle for the Java element associated with this document fragment, based on the parent Java element. |
java.lang.String |
getName()
Deprecated. Returns the name of this node. |
IDOMNode |
getNextNode()
Deprecated. Returns the sibling node immediately following this node. |
int |
getNodeType()
Deprecated. Returns the type of this node. |
IDOMNode |
getParent()
Deprecated. Returns the parent of this node. |
IDOMNode |
getPreviousNode()
Deprecated. Returns the sibling node immediately preceding this node. |
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. |
boolean |
isSignatureEqual(IDOMNode node)
Deprecated. Returns whether this node's signature is equivalent to the given node's signature. |
void |
remove()
Deprecated. Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment. |
void |
setName(java.lang.String name)
Deprecated. Sets the name of this node. |
Field Detail |
---|
static final int COMPILATION_UNIT
IDOMCompilationUnit
.
getNodeType()
,
Constant Field Valuesstatic final int PACKAGE
IDOMPackage
.
getNodeType()
,
Constant Field Valuesstatic final int IMPORT
IDOMImport
.
getNodeType()
,
Constant Field Valuesstatic final int TYPE
IDOMType
.
getNodeType()
,
Constant Field Valuesstatic final int FIELD
IDOMField
.
getNodeType()
,
Constant Field Valuesstatic final int METHOD
IDOMMethod
.
getNodeType()
,
Constant Field Valuesstatic final int INITIALIZER
IDOMInitializer
.
getNodeType()
,
Constant Field ValuesMethod Detail |
---|
void addChild(IDOMNode child) throws DOMException, java.lang.IllegalArgumentException
child
- the new child node
DOMException
- if any of the following conditions hold:java.lang.IllegalArgumentException
- if the child is null
insertSibling(IDOMNode)
,
remove()
boolean canHaveChildren()
true
if this node can have childrenjava.lang.Object clone()
IDOMNode
addChild(IDOMNode)
,
insertSibling(IDOMNode)
,
remove()
char[] getCharacters()
Note: To obtain complete source for the source file, ask a compilation unit node for its contents.
null
if this node has no contentsIDOMNode getChild(java.lang.String name)
name
- the name
null
if no such child existsjava.util.Enumeration getChildren()
java.lang.String getContents()
Note: To obtain complete source for the source file, ask a compilation unit node for its contents.
null
if this node has no contentsIDOMNode getFirstChild()
null
if this node has no childrengetChildren()
IJavaElement getJavaElement(IJavaElement parent) throws java.lang.IllegalArgumentException
parent
- the parent Java element
java.lang.IllegalArgumentException
- if the parent element is not
of a valid parent type for this nodejava.lang.String getName()
null
if it has no nameIDOMNode getNextNode()
null
if there is no following nodeint getNodeType()
IDOMNode
IDOMNode getParent()
null
if this node does not have a
parentIDOMNode getPreviousNode()
null
if there is no preceding nodevoid insertSibling(IDOMNode sibling) throws DOMException, java.lang.IllegalArgumentException
sibling
- the new sibling node
DOMException
- if any of the following conditions hold:java.lang.IllegalArgumentException
- if the sibling is null
addChild(IDOMNode)
,
clone()
,
remove()
boolean isAllowableChild(IDOMNode node)
node
- the potential child node
true
if the given node is an allowable childboolean isSignatureEqual(IDOMNode node)
node
- the other node
true
if the nodes have equivalent signaturesvoid remove()
addChild(IDOMNode)
,
clone()
,
insertSibling(IDOMNode)
void setName(java.lang.String name)
name
- the name, or null
to clear the name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |