Package org.opennms.netmgt.model
Class ResourcePath
- java.lang.Object
 - 
- org.opennms.netmgt.model.ResourcePath
 
 
- 
- All Implemented Interfaces:
 Comparable<ResourcePath>,Iterable<String>
public class ResourcePath extends Object implements Iterable<String>, Comparable<ResourcePath>
An abstract path used to represent a resource or its parent. The resource path may be may be mapped to a file-system path or some other form by theResourceStorageDaoimplementation. The elements of the path must not contain a forward slash (/).- Author:
 - jwhite
 
 
- 
- 
Constructor Summary
Constructors Constructor Description ResourcePath(Iterable<String> pathElements)ResourcePath(String... path)ResourcePath(ResourcePath parent, Iterable<String> pathElements)ResourcePath(ResourcePath parent, String... path) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ResourcePath other)String[]elements()booleanequals(Object obj)static ResourcePathfromString(String s)static ResourcePathget(Iterable<String> pathElements)Convenience method.static ResourcePathget(String... path)Convenience method.static ResourcePathget(ResourcePath parent, Iterable<String> path)Convenience method.static ResourcePathget(ResourcePath parent, String... path)Convenience method.StringgetName()ResourcePathgetParent()inthashCode()booleanhasParent()Iterator<String>iterator()intrelativeDepth(ResourcePath child)Determines the relative depth of a child path.static PathresourceToFilesystemPath(ResourcePath path)Converts the given resource path to a relative path on filesystem.static Stringsanitize(String path)StringtoString()static StringtoString(ResourcePath path)- 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface java.lang.Iterable
forEach, spliterator 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
ResourcePath
public ResourcePath(String... path)
 
- 
ResourcePath
public ResourcePath(ResourcePath parent, String... path)
 
- 
ResourcePath
public ResourcePath(ResourcePath parent, Iterable<String> pathElements)
 
 - 
 
- 
Method Detail
- 
get
public static ResourcePath get(String... path)
Convenience method. 
- 
get
public static ResourcePath get(Iterable<String> pathElements)
Convenience method. 
- 
get
public static ResourcePath get(ResourcePath parent, String... path)
Convenience method. 
- 
get
public static ResourcePath get(ResourcePath parent, Iterable<String> path)
Convenience method. 
- 
getName
public String getName()
 
- 
elements
public String[] elements()
 
- 
relativeDepth
public int relativeDepth(ResourcePath child)
Determines the relative depth of a child path.- Returns:
 - the relative depth >= 0, or -1 if the given child is not actually a child
 
 
- 
getParent
public ResourcePath getParent()
 
- 
hasParent
public boolean hasParent()
 
- 
compareTo
public int compareTo(ResourcePath other)
- Specified by:
 compareToin interfaceComparable<ResourcePath>
 
- 
resourceToFilesystemPath
public static Path resourceToFilesystemPath(ResourcePath path)
Converts the given resource path to a relative path on filesystem.- Parameters:
 path- the resource path to resolve- Returns:
 - the relative path of the resource on disk
 
 
- 
fromString
public static ResourcePath fromString(String s)
 
- 
toString
public static String toString(ResourcePath path)
 
 - 
 
 -