org.oddjob.arooa.registry
Class Path

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

public class Path
extends Object
implements Serializable

Represent the path to a component.

See Also:
Serialized Form
Author:
Rob Gordon.

Field Summary
static String PATH_SEPARATOR
          The path separator.
 
Constructor Summary
Path()
          Constructor for an empty path.
Path(String path)
           
 
Method Summary
 Path addId(String id)
          Create a new path by adding a new path element identified by they id to this path.
 Path addPath(Path extra)
          Create a new path by adding a path to this path.
 boolean equals(Object obj)
           
 Path getChildPath()
          Get the path below the topmost element.
 String getId()
           
 Path getParent()
           
 String getRoot()
          Get the id of the top element in the path.
 int hashCode()
           
 Path relativeTo(Path other)
          Resolve the other path relative to this path.
 int size()
          Return the size or depth of this path.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final String PATH_SEPARATOR
The path separator.

See Also:
Constant Field Values
Constructor Detail

Path

public Path()
Constructor for an empty path.


Path

public Path(String path)
Method Detail

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