Klasse SourcePath

java.lang.Object
org.apache.torque.generator.source.SourcePath

public final class SourcePath extends Object
Methods for traversing a source tree.
  • Methodendetails

    • hasChild

      public static boolean hasChild(SourceElement sourceElement, String name)
      Returns whether children with the given name exist.
      Parameter:
      sourceElement - the start element, not null.
      name - the name of the child element, not null.
      Gibt zurück:
      true if children with the given name exist, false otherwise.
      Löst aus:
      NullPointerException - if name is null.
    • hasFollowing

      public static boolean hasFollowing(SourceElement sourceElement)
      Returns whether a following element exists as a child of the parent of this element.
      Parameter:
      sourceElement - the start element, not null.
      Gibt zurück:
      true if a following element exists, false if not.
    • hasPreceding

      public static boolean hasPreceding(SourceElement sourceElement)
      Returns whether an preceding exists as a child of the parent of this element.
      Parameter:
      sourceElement - the start element, not null.
      Gibt zurück:
      true if a preceding element exists, false if not.
    • hasFollowingSibling

      public static boolean hasFollowingSibling(SourceElement sourceElement)
      Returns whether a following element exists as a child of the parent of this element, which has the same name as this source element.
      Parameter:
      sourceElement - the start element, not null.
      Gibt zurück:
      true if a following sibling exists, false if not.
    • hasPrecedingSibling

      public static boolean hasPrecedingSibling(SourceElement sourceElement)
      Returns whether an preceding exists as a child of the parent of this element, which has the same name as this source element.
      Parameter:
      sourceElement - the start element, not null.
      Gibt zurück:
      true if a preceding sibling exists, false if not.
    • getPreceding

      public static List<SourceElement> getPreceding(SourceElement sourceElement, String name)
      Returns all the preceding elements in the child list of the default parent which appear 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.
      Parameter:
      sourceElement - the start element, not null.
      name - the name of the preceding elements to select, or null to select all preceding elements.
      Gibt zurück:
      a list containing the preceding elements with the given name, never null.
      Siehe auch:
    • getFollowing

      public static List<SourceElement> getFollowing(SourceElement sourceElement, String name)
      Returns all the following elements in the child list of the default parent which appear 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.
      Parameter:
      sourceElement - the start element, not null.
      name - the name of the following elements to select, or null to select all following elements.
      Gibt zurück:
      a list containing the following elements with the given name, never null.
      Siehe auch:
    • getSiblingIteratorPositionedOnSelf

      protected static ListIterator<SourceElement> getSiblingIteratorPositionedOnSelf(SourceElement sourceElement, SourceElement parent)
      Returns a ListIterator of the siblings of the input source element. The iterator is positioned such that the next method returns the element after the input element, and the previous method returns the input element.
      Parameter:
      sourceElement - the source element for which the sibling iterator should be created, not null.
      parent - the parent for the source element.
      Gibt zurück:
      the sibling iterator, or null if the input source element has no parent.
      Löst aus:
      IllegalArgumentException - if the element cannot be found in the list of children of its parent.
    • iteratePointer

      public static Iterator<SourcePathPointer> iteratePointer(Object root, String pathToBase, Object base, String path)
      Gets the elements which can be reached from the start element by a given path. If the model root is null, only objects which are children of base can be retrieved.
      Parameter:
      root - the model root, or null if no model root exists (in the latter case, no elements only reachable via base's parent can be accessed)
      pathToBase - the path from root to base, must be not null if root is not null, is disregarded if root is null.
      base - the base object, not null.
      path - the path to use, or null (which refers base).
      Gibt zurück:
      the list of matching source elements, not null, may be empty.
      Siehe auch:
    • getElements

      public static List<SourceElement> getElements(SourceElement sourceElement, String path)
      Gets the elements which can be reached from the start element by a given path.
      Parameter:
      sourceElement - the start element, not null.
      path - the path to use, not null.
      Gibt zurück:
      the list of matching source elements, not null, may be empty.
      Siehe auch:
    • getElementsFromRoot

      public static List<SourceElement> getElementsFromRoot(SourceElement rootElement, String path)
      Gets the elements which can be reached from the root element by a given path. The name of the root element must appear first in the path, otherwise nothing is selected.
      Parameter:
      rootElement - the root element of the source tree, not null.
      path - the path to use, null selects the root element.
      Gibt zurück:
      the list of matching source elements, not null, may be empty.
      Siehe auch:
    • getObject

      public static Object getObject(SourceElement root, String pathToBase, SourceElement sourceElement, String path, boolean acceptEmpty) throws GeneratorException
      Gets a single source element which can be reached from the start element by a given path.
      Parameter:
      root - the model root, or null if no model root exists (in the latter case, no elements only reachable via base's parent can be accessed)
      pathToBase - the path from root to base, must be not null if root is not null, is disregarded if root is null.
      sourceElement - the start element, not null.
      path - the path to use, not null.
      acceptEmpty - whether no match is an error(acceptEmpty=false) or not (acceptEmpty=true)
      Gibt zurück:
      the single matching source elements, may be null only if acceptEmpty=true.
      Löst aus:
      GeneratorException - if more than one source element matches, or if no source element matches and acceptEmpty=false
      Siehe auch:
    • getElement

      public static SourceElement getElement(SourceElement sourceElement, String path, boolean acceptEmpty) throws GeneratorException
      Gets a single source element which can be reached from the start element by a given path.
      Parameter:
      sourceElement - the start element, not null.
      path - the path to use, not null.
      acceptEmpty - whether no match is an error(acceptEmpty=false) or not (acceptEmpty=true)
      Gibt zurück:
      the single matching source elements, may be null only if acceptEmpty=true.
      Löst aus:
      GeneratorException - if more than one source element matches, or if no source element matches and acceptEmpty=false
      Siehe auch:
    • getPathAsString

      public static String getPathAsString(SourceElement sourceElement) throws GeneratorException
      Returns the path from the root element to the source element. The element names are separated by slashes. Example: root/firstLevelElement/secondLevelElement/currentNode
      Parameter:
      sourceElement - the element to output, not null.
      Gibt zurück:
      the path from root, not null.
      Löst aus:
      GeneratorException - if the parent chain contains a closed loop.