Class Path

java.lang.Object
org.oddjob.arooa.registry.Path
All Implemented Interfaces:
Serializable

public class Path extends Object implements Serializable
Represent the path to a component.
Author:
Rob Gordon.
See Also:
  • Field Details

  • Constructor Details

    • Path

      public Path()
      Constructor for an empty path.
    • Path

      public Path(String path)
  • Method Details

    • size

      public int size()
      Return the size or depth of this path. a/b/c has a size of 3.
      Returns:
      The size of this path.
    • getRoot

      public String getRoot()
      Get the id of the top element in the path. This can be used to lookup the component which contains the component which is the next part of the path.
      Returns:
      The id of the topmost element.
    • getId

      public String getId()
    • getChildPath

      public Path getChildPath()
      Get the path below the topmost element. This can be used to traverse down to lookup a component
      Returns:
      The child path or null if this path is a single element.
    • addId

      public Path addId(String id)
      Create a new path by adding a new path element identified by they id to this path. If the id is null a new null path element will be added.
      Parameters:
      id - The id of the new path element. May be null.
      Returns:
      The new path.
    • getParent

      public Path getParent()
    • addPath

      public Path addPath(Path extra)
      Create a new path by adding a path to this path.
      Parameters:
      extra - The extra path.
      Returns:
      The new path.
    • relativeTo

      public Path relativeTo(Path other)
      Resolve the other path relative to this path. if this path is a/b and other is a/b/c/d the resultant relative path is c/d.
      Parameters:
      other - The other path.
      Returns:
      The relative path, null if the other path is not in this hierarchy.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object