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 theResourceStorageDao
implementation. 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 int
compareTo(ResourcePath other)
String[]
elements()
boolean
equals(Object obj)
static ResourcePath
fromString(String s)
static ResourcePath
get(Iterable<String> pathElements)
Convenience method.static ResourcePath
get(String... path)
Convenience method.static ResourcePath
get(ResourcePath parent, Iterable<String> path)
Convenience method.static ResourcePath
get(ResourcePath parent, String... path)
Convenience method.String
getName()
ResourcePath
getParent()
int
hashCode()
boolean
hasParent()
Iterator<String>
iterator()
int
relativeDepth(ResourcePath child)
Determines the relative depth of a child path.static Path
resourceToFilesystemPath(ResourcePath path)
Converts the given resource path to a relative path on filesystem.static String
sanitize(String path)
String
toString()
static String
toString(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:
compareTo
in 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)
-
-