Schnittstelle IDOMNode

Alle Superschnittstellen:
Cloneable
Alle bekannten Unterschnittstellen:
IDOMCompilationUnit, IDOMField, IDOMImport, IDOMInitializer, IDOMMember, IDOMMethod, IDOMPackage, IDOMType
Alle bekannten Implementierungsklassen:
DOMNode

public interface IDOMNode extends Cloneable
Veraltet.
The JDOM was made obsolete by the addition in 2.0 of the more powerful, fine-grained DOM/AST API found in the org.eclipse.jdt.core.dom package.
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:

  • clone - this creates a stand-alone copy of the DF that is in no way dependent on the DF that it was cloned from
  • remove - this orphans a DF from its host DF. The removed DF may still be dependent on its previous host (perhaps to generate its contents), and hanging onto the fragment means that its previous host is also retained in memory.
  • add/insert - this splices an un-parented DF (one that has been cloned, removed, or created stand-alone), into an existing DF such that the newly inserted DF is only dependent on its new host.

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[]".

  • Feldübersicht

    Felder
    Modifizierer und Typ
    Feld
    Beschreibung
    static final int
    Veraltet.
    Node type constant indicating a compilation unit.
    static final int
    Veraltet.
    Node type constant indicating a field declaration.
    static final int
    Veraltet.
    Node type constant indicating an import declaration.
    static final int
    Veraltet.
    Node type constant indicating an initializer declaration.
    static final int
    Veraltet.
    Node type constant indicating a method (or constructor) declaration.
    static final int
    Veraltet.
    Node type constant indicating a package declaration.
    static final int
    Veraltet.
    Node type constant indicating a type declaration.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    Veraltet.
    Adds the given un-parented node (document fragment) as the last child of this node.
    boolean
    Veraltet.
    Returns whether this node is allowed to have children.
    Veraltet.
    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[]
    Veraltet.
    Returns the current contents of this document fragment as a character array.
    Veraltet.
    Returns the first named child of this node with the given name.
    Veraltet.
    Returns an enumeration of children of this node.
    Veraltet.
    Returns the current contents of this document fragment.
    Veraltet.
    Returns the first child of this node.
    Veraltet.
    Returns a handle for the Java element associated with this document fragment, based on the parent Java element.
    Veraltet.
    Returns the name of this node.
    Veraltet.
    Returns the sibling node immediately following this node.
    int
    Veraltet.
    Returns the type of this node.
    Veraltet.
    Returns the parent of this node.
    Veraltet.
    Returns the sibling node immediately preceding this node.
    void
    Veraltet.
    Inserts the given un-parented node as a sibling of this node, immediately before this node.
    boolean
    Veraltet.
    Returns whether the given node is an allowable child for this node.
    boolean
    Veraltet.
    Returns whether this node's signature is equivalent to the given node's signature.
    void
    Veraltet.
    Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment.
    void
    Veraltet.
    Sets the name of this node.
  • Felddetails

    • COMPILATION_UNIT

      static final int COMPILATION_UNIT
      Veraltet.
      Node type constant indicating a compilation unit. Nodes of this type maybe by safely cast to IDOMCompilationUnit.
      Siehe auch:
    • PACKAGE

      static final int PACKAGE
      Veraltet.
      Node type constant indicating a package declaration. Nodes of this type maybe by safely cast to IDOMPackage.
      Siehe auch:
    • IMPORT

      static final int IMPORT
      Veraltet.
      Node type constant indicating an import declaration. Nodes of this type maybe by safely cast to IDOMImport.
      Siehe auch:
    • TYPE

      static final int TYPE
      Veraltet.
      Node type constant indicating a type declaration. Nodes of this type maybe by safely cast to IDOMType.
      Siehe auch:
    • FIELD

      static final int FIELD
      Veraltet.
      Node type constant indicating a field declaration. Nodes of this type maybe by safely cast to IDOMField.
      Siehe auch:
    • METHOD

      static final int METHOD
      Veraltet.
      Node type constant indicating a method (or constructor) declaration. Nodes of this type maybe by safely cast to IDOMMethod.
      Siehe auch:
    • INITIALIZER

      static final int INITIALIZER
      Veraltet.
      Node type constant indicating an initializer declaration. Nodes of this type maybe by safely cast to IDOMInitializer.
      Siehe auch:
  • Methodendetails

    • addChild

      void addChild(IDOMNode child) throws DOMException, IllegalArgumentException
      Veraltet.
      Adds the given un-parented node (document fragment) as the last child of this node.
      Parameter:
      child - the new child node
      Löst aus:
      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
      IllegalArgumentException - if the child is null
      Siehe auch:
    • canHaveChildren

      boolean canHaveChildren()
      Veraltet.
      Returns whether this node is allowed to have children.
      Gibt zurück:
      true if this node can have children
    • clone

      Object clone()
      Veraltet.
      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.
      Gibt zurück:
      a copy of type IDOMNode
      Siehe auch:
    • getCharacters

      char[] getCharacters()
      Veraltet.
      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.

      Gibt zurück:
      the contents, or null if this node has no contents
    • getChild

      IDOMNode getChild(String name)
      Veraltet.
      Returns the first named child of this node with the given name.
      Parameter:
      name - the name
      Gibt zurück:
      the child node, or null if no such child exists
    • getChildren

      Enumeration getChildren()
      Veraltet.
      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.
      Gibt zurück:
      an enumeration of the children
    • getContents

      String getContents()
      Veraltet.
      Returns the current contents of this document fragment.

      Note: To obtain complete source for the source file, ask a compilation unit node for its contents.

      Gibt zurück:
      the contents, or null if this node has no contents
    • getFirstChild

      IDOMNode getFirstChild()
      Veraltet.
      Returns the first child of this node. Children appear in the order in which they exist in the source code.
      Gibt zurück:
      the first child, or null if this node has no children
      Siehe auch:
    • getJavaElement

      IJavaElement getJavaElement(IJavaElement parent) throws IllegalArgumentException
      Veraltet.
      Returns a handle for the Java element associated with this document fragment, based on the parent Java element.
      Parameter:
      parent - the parent Java element
      Gibt zurück:
      a handle for the Java element associated with this document fragment, based on the parent Java element
      Löst aus:
      IllegalArgumentException - if the parent element is not of a valid parent type for this node
    • getName

      String getName()
      Veraltet.
      Returns the name of this node. More details are provided in each of the subtypes.
      Gibt zurück:
      the name, or null if it has no name
    • getNextNode

      IDOMNode getNextNode()
      Veraltet.
      Returns the sibling node immediately following this node.
      Gibt zurück:
      the next node, or null if there is no following node
    • getNodeType

      int getNodeType()
      Veraltet.
      Returns the type of this node.
      Gibt zurück:
      one of the node type constants defined in IDOMNode
    • getParent

      IDOMNode getParent()
      Veraltet.
      Returns the parent of this node.
      Gibt zurück:
      the parent node, or null if this node does not have a parent
    • getPreviousNode

      IDOMNode getPreviousNode()
      Veraltet.
      Returns the sibling node immediately preceding this node.
      Gibt zurück:
      the previous node, or null if there is no preceding node
    • insertSibling

      void insertSibling(IDOMNode sibling) throws DOMException, IllegalArgumentException
      Veraltet.
      Inserts the given un-parented node as a sibling of this node, immediately before this node.
      Parameter:
      sibling - the new sibling node
      Löst aus:
      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
      IllegalArgumentException - if the sibling is null
      Siehe auch:
    • isAllowableChild

      boolean isAllowableChild(IDOMNode node)
      Veraltet.
      Returns whether the given node is an allowable child for this node.
      Parameter:
      node - the potential child node
      Gibt zurück:
      true if the given node is an allowable child
    • isSignatureEqual

      boolean isSignatureEqual(IDOMNode node)
      Veraltet.
      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.
      Parameter:
      node - the other node
      Gibt zurück:
      true if the nodes have equivalent signatures
    • remove

      void remove()
      Veraltet.
      Separates this node from its parent and siblings, maintaining any ties that this node has to the underlying document fragment. A document fragment that is removed from its host document may still be dependent on that host document until it is inserted into a different document. Removing a root node has no effect.
      Siehe auch:
    • setName

      void setName(String name)
      Veraltet.
      Sets the name of this node. Name format depends on node type. More details are provided in each of the subtypes.
      Parameter:
      name - the name, or null to clear the name