java.lang.Object
com.aoapps.net.Path
- All Implemented Interfaces:
- DtoFactory<Path>,- Internable<Path>,- Serializable,- Comparable<Path>
public final class Path
extends Object
implements Comparable<Path>, Serializable, DtoFactory<Path>, Internable<Path>
Represents a full path.  Paths must:
 
- 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 SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionintbooleangetDto()inthashCode()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 ValidationResultstatic Path
- 
Field Details- 
SEPARATOR_CHARpublic static final char SEPARATOR_CHARThe path separator as a char'/'.- See Also:
 
- 
SEPARATOR_STRINGThe path separator as a single-character String"/".
- 
ROOTThe root path"/". This is implemented as a singleton as is safe for direct object equality check "==".
 
- 
- 
Method Details- 
validate
- 
valueOf- Parameters:
- path- when- null, returns- null
- Throws:
- ValidationException
 
- 
equals
- 
hashCodepublic int hashCode()
- 
compareTo- Specified by:
- compareToin interface- Comparable<Path>
 
- 
toString
- 
internInterns this path much in the same fashion asString.intern().- Specified by:
- internin interface- Internable<Path>
- See Also:
 
- 
getDto- Specified by:
- getDtoin interface- DtoFactory<Path>
 
- 
subPathpublic Path subPath(int beginIndex, int endIndex) throws IllegalArgumentException, IndexOutOfBoundsException Gets a sub path of the given beginning and end.- Parameters:
- beginIndex- Must align with a- SEPARATOR_CHAR.
- endIndex- One-past the last character to include. Must be greater than- beginIndex.
- Throws:
- IllegalArgumentException
- IndexOutOfBoundsException
- See Also:
 
- 
prefixGets a prefix path of the given length.Implementation Note: 
 CallssubPath(0, len)- Parameters:
- len- Must be greater than- 0.
- Throws:
- IllegalArgumentException
- IndexOutOfBoundsException
- See Also:
 
- 
suffixGets a suffix path starting at the given index.Implementation Note: 
 CallssubPath(beginIndex, path.length())- Parameters:
- beginIndex- Must align with a- SEPARATOR_CHAR.
- Throws:
- IllegalArgumentException
- IndexOutOfBoundsException
- See Also:
 
 
- 

