ccc.api.types
Class ResourcePath

java.lang.Object
  extended by ccc.api.types.ResourcePath

public final class ResourcePath
extends java.lang.Object

This class models an absolute path to a resource.

Author:
Civic Computing Ltd

Field Summary
static java.lang.String PATH_PATTERN
          PATH_PATTERN : Pattern.
 
Constructor Summary
ResourcePath()
          Constructor.
ResourcePath(java.util.List<ResourceName> elements)
          Constructor.
ResourcePath(ResourceName name)
          Constructor.
ResourcePath(java.lang.String pathString)
          Constructor.
 
Method Summary
 ResourcePath append(ResourceName resourceName)
          Append a resource name to the end of an existing path.
 java.util.List<ResourceName> elements()
          Query method.
 java.util.List<ResourceName> elementsToTop()
          Returns list of all but topmost elements.
 boolean equals(java.lang.Object obj)
          
 int hashCode()
          
static boolean isValid(java.lang.String pathString)
          Tests whether the specified string is a valid path.
 ResourcePath parent()
          Return a path minus the bottom most (i.e.
 ResourcePath removeTop()
          Return a path minus the top most (i.e.
 ResourceName top()
          Return the top.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PATH_PATTERN

public static final java.lang.String PATH_PATTERN
PATH_PATTERN : Pattern.

See Also:
Constant Field Values
Constructor Detail

ResourcePath

public ResourcePath(java.lang.String pathString)
Constructor. Converts a string into a ResourcePath, performing validation. A valid path should match the regex regular expression defined by .

Parameters:
pathString - The absolute resource path, represented as a string.

ResourcePath

public ResourcePath()
Constructor.


ResourcePath

public ResourcePath(ResourceName name)
Constructor. Constructs a path with a single element.

Parameters:
name - The name of the path element.

ResourcePath

public ResourcePath(java.util.List<ResourceName> elements)
Constructor.

Parameters:
elements - A list of resource names.
Method Detail

isValid

public static boolean isValid(java.lang.String pathString)
Tests whether the specified string is a valid path.

Parameters:
pathString - The string to test.
Returns:
True if the string is valid, false otherwise.

append

public ResourcePath append(ResourceName resourceName)
Append a resource name to the end of an existing path. For example, with an existing path '/foo' calling append('bar') will return a new path object that represents '/foo/bar'.

Parameters:
resourceName - The name of the resource to append.
Returns:
A new resource path.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

elements

public java.util.List<ResourceName> elements()
Query method. Returns the elements of this path as a list of names.

Returns:
A list of resource names, representing the path.

elementsToTop

public java.util.List<ResourceName> elementsToTop()
Returns list of all but topmost elements. In case of root/empty path empty list is returned.

Returns:
A list of resource names.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

removeTop

public ResourcePath removeTop()
Return a path minus the top most (i.e. root) element.

Returns:
Resource path.

top

public ResourceName top()
Return the top.

Returns:
The name for the resource at the top of the path.

parent

public ResourcePath parent()
Return a path minus the bottom most (i.e. leaf) element.

Returns:
Resource path.


Copyright © 2010. All Rights Reserved.