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 theResourceStorageDaoimplementation. 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 intcompareTo(ResourcePath other)java.lang.String[]elements()booleanequals(java.lang.Object obj)static ResourcePathfromString(java.lang.String s)static ResourcePathget(java.lang.Iterable<java.lang.String> pathElements)Convenience method.static ResourcePathget(java.lang.String... path)Convenience method.static ResourcePathget(ResourcePath parent, java.lang.Iterable<java.lang.String> path)Convenience method.static ResourcePathget(ResourcePath parent, java.lang.String... path)Convenience method.java.lang.StringgetName()ResourcePathgetParent()inthashCode()booleanhasParent()java.util.Iterator<java.lang.String>iterator()intrelativeDepth(ResourcePath child)Determines the relative depth of a child path.static java.nio.file.PathresourceToFilesystemPath(ResourcePath path)Converts the given resource path to a relative path on filesystem.static java.lang.Stringsanitize(java.lang.String path)java.lang.StringtoString()static java.lang.StringtoString(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:
iteratorin interfacejava.lang.Iterable<java.lang.String>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(ResourcePath other)
- Specified by:
compareToin 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)
-
-