org.apache.torque.generator.source

## Class SourceElement

- java.lang.Object
- - org.apache.torque.generator.source.SourceElement

- All Implemented Interfaces:
    Serializable

      public class SourceElement
      extends Object
      implements Serializable

  An element in the source graph.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SourceElement(SourceElementName sourceElementName)` Constructor.
    `SourceElement(String name)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SourceElement` | `copy()` Creates a deep copy of this RichSourceelementImpl object.
    `Object` | `getAttribute(SourceAttributeName sourceAttributeName)` Returns the object stored in a given attribute.
    `Object` | `getAttribute(String name)` Returns the object stored in a given attribute.
    `Set<String>` | `getAttributeNames()` Returns the name of all set attributes.
    `SourceElement` | `getChild(SourceElementName sourceElementName)` Returns the first child of this SourceElement which has the given name.
    `SourceElement` | `getChild(String name)` Returns the first child of this SourceElement which has the given name.
    `List<SourceElement>` | `getChildren()` Returns all children of this SourceElement.
    `List<SourceElement>` | `getChildren(SourceElementName sourceElementName)` Returns all children of this SourceElement which have the given name.
    `List<SourceElement>` | `getChildren(String name)` Returns all children of this SourceElement which have the given name.
    `SourceElement` | `getFirstChild()` Returns the first child of this source element.
    `List<SourceElement>` | `getFollowing(String name)` Returns all the following elements after this element with the given name.
    `SourceElement` | `getFollowingSourceElement(SourceElement parent)` Returns the following element after this element If this element has no parent, null is returned.
    `SourceElement` | `getLastChild()` Returns the last child of this source element.
    `String` | `getName()` Returns the name of this source element.
    `SourceElement` | `getParent()` Returns the primary parent of this SourceElement.
    `List<SourceElement>` | `getParents()` Returns the list of parents of this SourceElement.
    `List<SourceElement>` | `getPreceding(String name)` Returns all the preceding elements before this element with the given name.
    `SourceElement` | `getPrecedingSourceElement(SourceElement parent)` Returns the preceding element after this element.
    `Object` | `getTextAttribute()` Returns the object stored in the attribute with key null.
    `boolean` | `graphEquals(SourceElement toCompare)` Checks whether the source element graph of this sourceElement, and its position therein, equals the source element graph and the position of the provided SourceElement.
    `boolean` | `hasChild(String name)` Returns whether children with the given name exist.
    `boolean` | `hasFollowing()` Returns whether a following element exists as a child of the parent of this element.
    `boolean` | `hasFollowingSibling()` Returns whether a following element exists as a child of the parent of this element, which has the same name as this source element.
    `boolean` | `hasPreceding()` Returns whether an preceding exists as a child of the parent of this element.
    `boolean` | `hasPrecedingSibling()` Returns whether an preceding exists as a child of the parent of this element, which has the same name as this source element.
    `Object` | `setAttribute(SourceAttributeName sourceAttributeName, Object value)` Sets the attribute of a Source element.
    `Object` | `setAttribute(String name, Object value)` Sets the attribute of a Source element.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SourceElement

          public SourceElement(String name)

      Constructor.
      Parameters:
        `name` - the name of the element, not null.
      Throws:
        `NullPointerException` - if name is null.

    - #### SourceElement

          public SourceElement(SourceElementName sourceElementName)

      Constructor.
      Parameters:
        `sourceElementName` - sourceElementName name of the element, not null.
      Throws:
        `NullPointerException` - if sourceElementName is null.

  - ### Method Detail

    - #### getName

          public String getName()

      Returns the name of this source element.
      Returns:
        the name of this source element, never null.

    - #### getParent

          public SourceElement getParent()

      Returns the primary parent of this SourceElement.
      Returns:
        the primary parent of this SourceElement, or null if this is a root element of the source graph.

    - #### getParents

          public List<SourceElement> getParents()

      Returns the list of parents of this SourceElement. Parents can be added and removed via the methods exposed by the returned list.
      Returns:
        the list of parents of this source element, never null.

    - #### getChildren

          public List<SourceElement> getChildren()

      Returns all children of this SourceElement. Children can be added and removed via the methods exposed by the returned list.
      Returns:
        the list of children of this source element, never null.

    - #### getChildren

          public List<SourceElement> getChildren(String name)

      Returns all children of this SourceElement which have the given name. Modifications on the returned list have no effect on the list of children of this SourceElement.
      Parameters:
        `name` - the name of the children to select, not null.
      Returns:
        the list of children of this source element with the given name, never null.
      Throws:
        `NullPointerException` - if name is null.

    - #### getChildren

          public List<SourceElement> getChildren(SourceElementName sourceElementName)

      Returns all children of this SourceElement which have the given name. Modifications on the returned list have no effect on the list of children of this SourceElement.
      Parameters:
        `sourceElementName` - contains the name of the child to select, not null.
      Returns:
        the list of children of this source element with the given name, never null.
      Throws:
        `NullPointerException` - if sourceElementName is null.

    - #### getChild

          public SourceElement getChild(String name)

      Returns the first child of this SourceElement which has the given name.
      Parameters:
        `name` - the name of the child to select, not null.
      Returns:
        the first child with the given name, or null if no child with the given name exits.
      Throws:
        `NullPointerException` - if name is null.

    - #### getChild

          public SourceElement getChild(SourceElementName sourceElementName)

      Returns the first child of this SourceElement which has the given name.
      Parameters:
        `sourceElementName` - contains the name of the child to select, not null.
      Returns:
        the first child with the given name, or null if no child with the given name exits.
      Throws:
        `NullPointerException` - if sourceElementName is null.

    - #### hasChild

          public boolean hasChild(String name)

      Returns whether children with the given name exist.
      Parameters:
        `name` - the name of the child element, not null.
      Returns:
        true if children with the given name exist, false otherwise.
      Throws:
        `NullPointerException` - if name is null.

    - #### getFirstChild

          public SourceElement getFirstChild()

      Returns the first child of this source element.
      Returns:
        the first child, or null if this source element has no children.

    - #### getLastChild

          public SourceElement getLastChild()

      Returns the last child of this source element.
      Returns:
        the last child, or null if this source element has no children.

    - #### getFollowing

          public List<SourceElement> getFollowing(String name)

      Returns all the following elements after this element with the given name. If name is null, all following elements are returned. If this element has no parent, an empty list is returned.
      Parameters:
        `name` - the name of the following elements to select, or null to select all following elements.
      Returns:
        a list containing the following elements with the given name, never null.
      See Also:

    - #### getFollowingSourceElement

          public SourceElement getFollowingSourceElement(SourceElement parent)

      Returns the following element after this element If this element has no parent, null is returned.
      Parameters:
        `parent` - the parent of this source Element in which child list the following element should be looked for.
      Returns:
        the following source element, or null if no following source element exists.
      Throws:
        `IllegalArgumentException` - if parent is not a parent of this SourceElement.

    - #### hasFollowing

          public boolean hasFollowing()

      Returns whether a following element exists as a child of the parent of this element.
      Returns:
        true if a following element exists, false if not.

    - #### hasPreceding

          public boolean hasPreceding()

      Returns whether an preceding exists as a child of the parent of this element.
      Returns:
        true if a preceding element exists, false if not.

    - #### hasFollowingSibling

          public boolean hasFollowingSibling()

      Returns whether a following element exists as a child of the parent of this element, which has the same name as this source element.
      Returns:
        true if a following sibling exists, false if not.

    - #### hasPrecedingSibling

          public boolean hasPrecedingSibling()

      Returns whether an preceding exists as a child of the parent of this element, which has the same name as this source element.
      Returns:
        true if a preceding sibling exists, false if not.

    - #### getPreceding

          public List<SourceElement> getPreceding(String name)

      Returns all the preceding elements before this element with the given name. If name is null, all preceding elements are returned. If this element has no parent, an empty list is returned.
      Parameters:
        `name` - the name of the preceding elements to select, or null to select all preceding elements.
      Returns:
        a list containing the following elements with the given name, never null.
      See Also:

    - #### getPrecedingSourceElement

          public SourceElement getPrecedingSourceElement(SourceElement parent)

      Returns the preceding element after this element. If this element has no parent, null is returned.
      Parameters:
        `parent` - the parent of this source Element in which child list the following element should be looked for.
      Returns:
        the preceding source element, or null if no preceding source element exists.
      Throws:
        `IllegalArgumentException` - if parent is not a parent of this SourceElement.

    - #### getTextAttribute

          public Object getTextAttribute()

      Returns the object stored in the attribute with key null.
      Returns:
        the stored object, or null if no object is stored under the key null.

    - #### getAttribute

          public Object getAttribute(String name)

      Returns the object stored in a given attribute.
      Parameters:
        `name` - the name of the attribute, can be null.
      Returns:
        the stored object, or null if no object is stored under that key.

    - #### getAttribute

          public Object getAttribute(SourceAttributeName sourceAttributeName)

      Returns the object stored in a given attribute.
      Parameters:
        `sourceAttributeName` - contains the name of the attribute, not null.
      Returns:
        the stored object, or null if no object is stored under that key.
      Throws:
        `NullPointerException` - if sourceAttributeName is null.

    - #### setAttribute

          public Object setAttribute(String name,
                                     Object value)

      Sets the attribute of a Source element.
      Parameters:
        `name` - the name of the attribute.
        `value` - the value of the attribute, or null to remove the attribute.
      Returns:
        the previous value of this attribute.

    - #### setAttribute

          public Object setAttribute(SourceAttributeName sourceAttributeName,
                                     Object value)

      Sets the attribute of a Source element.
      Parameters:
        `sourceAttributeName` - contains the name of the attribute, not null.
        `value` - the value of the attribute, or null to remove the attribute.
      Returns:
        the previous value of this attribute.

    - #### getAttributeNames

          public Set<String> getAttributeNames()

      Returns the name of all set attributes. Note : null may be contained in the set.
      Returns:
        the name of all set values.

    - #### copy

          public SourceElement copy()

      Creates a deep copy of this RichSourceelementImpl object. All the elements in the source graph of this Element are copied as well (i.e the copy contains the children, the children's children, ...., the parents, the parent's parents...)
      Returns:
        the copy, not null.

    - #### graphEquals

          public boolean graphEquals(SourceElement toCompare)

      Checks whether the source element graph of this sourceElement, and its position therein, equals the source element graph and the position of the provided SourceElement. This is an expensive operation if the graphs are large.
      Parameters:
        `toCompare` - the source element to compare, may be null.
      Returns:
        true if all source elements in the toCompare tree have the equal content as the source elements in this tree.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.