- All Implemented Interfaces:
DtoFactory<Path>
,Internable<Path>
,Serializable
,Comparable<Path>
- Be non-null
- Be non-empty
- Start with a
/
- Not contain any null characters
- Not contain any /../ or /./ path elements
- Not end with /.. or /.
- Not contain any // in the path
Note, this concept of path is minimally restrictive and only represents a well-formed path. The path may not be valid for some contexts, such as the path part of a URL. This does not implement RFC 3986.
TODO: Should we disallow any number path element that is all dots, such as "...." and not just "." and ".."?
TODO: This matches UnixPath
in aoserv-client with the exception of allowing trailing slash.
Remove this redundancy?
- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
getDto()
int
hashCode()
intern()
Interns this path much in the same fashion asString.intern()
.prefix
(int len) Gets a prefix path of the given length.subPath
(int beginIndex, int endIndex) Gets a sub path of the given beginning and end.suffix
(int beginIndex) Gets a suffix path starting at the given index.toString()
static ValidationResult
static Path
-
Field Details
-
SEPARATOR_CHAR
public static final char SEPARATOR_CHARThe path separator as a char'/'
.- See Also:
-
SEPARATOR_STRING
The path separator as a single-character String"/"
. -
ROOT
The root path"/"
. This is implemented as a singleton as is safe for direct object equality check "==
".
-
-
Method Details
-
validate
-
valueOf
- Parameters:
path
- whennull
, returnsnull
- Throws:
ValidationException
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<Path>
-
toString
-
intern
Interns this path much in the same fashion asString.intern()
.- Specified by:
intern
in interfaceInternable<Path>
- See Also:
-
getDto
- Specified by:
getDto
in interfaceDtoFactory<Path>
-
subPath
public Path subPath(int beginIndex, int endIndex) throws IllegalArgumentException, IndexOutOfBoundsException Gets a sub path of the given beginning and end.- Parameters:
beginIndex
- Must align with aSEPARATOR_CHAR
.endIndex
- One-past the last character to include. Must be greater thanbeginIndex
.- Throws:
IllegalArgumentException
IndexOutOfBoundsException
- See Also:
-
prefix
Gets a prefix path of the given length.Implementation Note:
CallssubPath(0, len)
- Parameters:
len
- Must be greater than0
.- Throws:
IllegalArgumentException
IndexOutOfBoundsException
- See Also:
-
suffix
Gets a suffix path starting at the given index.Implementation Note:
CallssubPath(beginIndex, path.length())
- Parameters:
beginIndex
- Must align with aSEPARATOR_CHAR
.- Throws:
IllegalArgumentException
IndexOutOfBoundsException
- See Also:
-