Package org.opennms.netmgt.model
Class ResourcePath
- java.lang.Object
-
- org.opennms.netmgt.model.ResourcePath
-
- All Implemented Interfaces:
java.lang.Comparable<ResourcePath>
,java.lang.Iterable<java.lang.String>
public class ResourcePath extends java.lang.Object implements java.lang.Iterable<java.lang.String>, java.lang.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(java.lang.Iterable<java.lang.String> pathElements)
ResourcePath(java.lang.String... path)
ResourcePath(ResourcePath parent, java.lang.Iterable<java.lang.String> pathElements)
ResourcePath(ResourcePath parent, java.lang.String... path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ResourcePath other)
java.lang.String[]
elements()
boolean
equals(java.lang.Object obj)
static ResourcePath
fromString(java.lang.String s)
static ResourcePath
get(java.lang.Iterable<java.lang.String> pathElements)
Convenience method.static ResourcePath
get(java.lang.String... path)
Convenience method.static ResourcePath
get(ResourcePath parent, java.lang.Iterable<java.lang.String> path)
Convenience method.static ResourcePath
get(ResourcePath parent, java.lang.String... path)
Convenience method.java.lang.String
getName()
ResourcePath
getParent()
int
hashCode()
boolean
hasParent()
java.util.Iterator<java.lang.String>
iterator()
int
relativeDepth(ResourcePath child)
Determines the relative depth of a child path.static java.nio.file.Path
resourceToFilesystemPath(ResourcePath path)
Converts the given resource path to a relative path on filesystem.static java.lang.String
sanitize(java.lang.String path)
java.lang.String
toString()
static java.lang.String
toString(ResourcePath path)
-
-
-
Constructor Detail
-
ResourcePath
public ResourcePath(java.lang.String... path)
-
ResourcePath
public ResourcePath(java.lang.Iterable<java.lang.String> pathElements)
-
ResourcePath
public ResourcePath(ResourcePath parent, java.lang.String... path)
-
ResourcePath
public ResourcePath(ResourcePath parent, java.lang.Iterable<java.lang.String> pathElements)
-
-
Method Detail
-
get
public static ResourcePath get(java.lang.String... path)
Convenience method.
-
get
public static ResourcePath get(java.lang.Iterable<java.lang.String> pathElements)
Convenience method.
-
get
public static ResourcePath get(ResourcePath parent, java.lang.String... path)
Convenience method.
-
get
public static ResourcePath get(ResourcePath parent, java.lang.Iterable<java.lang.String> path)
Convenience method.
-
getName
public java.lang.String getName()
-
elements
public java.lang.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()
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(ResourcePath other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ResourcePath>
-
sanitize
public static java.lang.String sanitize(java.lang.String path)
-
resourceToFilesystemPath
public static java.nio.file.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(java.lang.String s)
-
toString
public static java.lang.String toString(ResourcePath path)
-
-