public final class SourcePath extends Object
| Modifier and Type | Method and Description | 
|---|---|
| static SourceElement | getElement(SourceElement sourceElement,
          String path,
          boolean acceptEmpty)Gets a single source element which can be reached from the start element
 by a given path. | 
| static List<SourceElement> | getElements(SourceElement sourceElement,
           String path)Gets the elements which can be reached from the start element by a given
 path. | 
| static List<SourceElement> | getElementsFromRoot(SourceElement rootElement,
                   String path)Gets the elements which can be reached from the root element by a given
 path. | 
| 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. | 
| static Object | getObject(SourceElement root,
         String pathToBase,
         SourceElement sourceElement,
         String path,
         boolean acceptEmpty)Gets a single source element which can be reached from the start element
 by a given path. | 
| static String | getPathAsString(SourceElement sourceElement)Returns the path from the root element to the source element. | 
| 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. | 
| protected static ListIterator<SourceElement> | getSiblingIteratorPositionedOnSelf(SourceElement sourceElement,
                                  SourceElement parent)Returns a ListIterator of the siblings of the input source element. | 
| static boolean | hasChild(SourceElement sourceElement,
        String name)Returns whether children with the given name exist. | 
| static boolean | hasFollowing(SourceElement sourceElement)Returns whether a following element exists as a child of the parent of
 this element. | 
| 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. | 
| static boolean | hasPreceding(SourceElement sourceElement)Returns whether an preceding exists as a child of the parent of
 this element. | 
| 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. | 
| 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. | 
public static boolean hasChild(SourceElement sourceElement, String name)
sourceElement - the start element, not null.name - the name of the child element, not null.NullPointerException - if name is null.public static boolean hasFollowing(SourceElement sourceElement)
sourceElement - the start element, not null.public static boolean hasPreceding(SourceElement sourceElement)
sourceElement - the start element, not null.public static boolean hasFollowingSibling(SourceElement sourceElement)
sourceElement - the start element, not null.public static boolean hasPrecedingSibling(SourceElement sourceElement)
sourceElement - the start element, not null.public static List<SourceElement> getPreceding(SourceElement sourceElement, String name)
sourceElement - the start element, not null.name - the name of the preceding elements to select,
        or null to select all preceding elements.public static List<SourceElement> getFollowing(SourceElement sourceElement, String name)
sourceElement - the start element, not null.name - the name of the following elements to select,
        or null to select all following elements.protected static ListIterator<SourceElement> getSiblingIteratorPositionedOnSelf(SourceElement sourceElement, SourceElement parent)
sourceElement - the source element for which the sibling iterator
        should be created, not null.parent - the parent for the source element.IllegalArgumentException - if the element cannot be found in the
         list of children of its parent.public static Iterator<SourcePathPointer> iteratePointer(Object root, String pathToBase, Object base, String path)
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).public static List<SourceElement> getElements(SourceElement sourceElement, String path)
sourceElement - the start element, not null.path - the path to use, not null.public static List<SourceElement> getElementsFromRoot(SourceElement rootElement, String path)
rootElement - the root element of the source tree, not null.path - the path to use, null selects the root element.public static Object getObject(SourceElement root, String pathToBase, SourceElement sourceElement, String path, boolean acceptEmpty) throws GeneratorException
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)GeneratorException - if more than one source element matches,
       or if no source element matches and acceptEmpty=falsepublic static SourceElement getElement(SourceElement sourceElement, String path, boolean acceptEmpty) throws GeneratorException
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)GeneratorException - if more than one source element matches,
       or if no source element matches and acceptEmpty=falsepublic static String getPathAsString(SourceElement sourceElement) throws GeneratorException
sourceElement - the element to output, not null.GeneratorException - if the parent chain contains a closed loop.Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.