|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fatwire.agent.Path
public class Path
Item path.
Represents the path of an item inside a content repository. This path is unique for each item. The separator is '/' or '\' character by default although there is a way to specify a custom separator. When path is serialized to string '/' character is used as separator by default, although you may specify your own.When the path is constructed the input string is
The path could be rooted (starts with the separator) or not. It also could be used for other purposes as a convenient path-processing utility. Example usage:Path folderAbsolutePath = new Path(L"/usr/"); Path fileRelativePath = new Path(L"myproject/info.txt"); Path fileAbsolutePath = folderAbsolutePath.append( fileRelativePath ); System.println( "Top folder: " + fileAbsolutePath.get(0) ); System.println( "Parent folder: " + fileAbsolutePath.SubPath(0, fileAbsolutePath.getLength()-1) );
Constructor Summary | |
---|---|
Path(java.lang.String path)
Default constructor. |
|
Path(java.lang.String path,
char sep)
Constructor. |
|
Path(java.lang.String path,
char[] seps)
Constructor. |
Method Summary | |
---|---|
Path |
append(Path path)
Appends the path to this path. |
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
get(int pos)
Returns n-th part of path (zero-based). |
java.lang.String |
getExtension()
Extracts file extension from path. |
java.lang.String |
getFilename()
Extracts file name from this path. |
int |
getLength()
Returns path length. |
Path |
getParent()
Gets parent path. |
boolean |
isRooted()
Determines whether path starts with the path separator. |
Path |
subPath(int pos,
int npos)
Returns sub-path within the current path. |
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.String sep)
Serializes this path using a custom separator. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Path(java.lang.String path)
path
- path to parse.public Path(java.lang.String path, char sep)
path
- path string to parse.sep
- custom separator to use.public Path(java.lang.String path, char[] seps)
path
- path string to parse.seps
- custom separators to use.
Each character in this array is considered as a separator.Method Detail |
---|
public java.lang.String get(int pos) throws InvalidArgumentException
Path path = new Path(L"/usr/file.txt"); System.println(path.get(0)); // prints 'user'; System.println(path.get(1)); // prints 'file.txt' System.println(path.get(2)); // throws InvalidArgumentException
pos
- position to return.
InvalidArgumentException
- if pos is out of range.public Path subPath(int pos, int npos) throws InvalidArgumentException
pos
- zero-based position to start with.npos
- number of positions to return.
InvalidArgumentException
- if pos or npos are out of range.public boolean isRooted()
public java.lang.String getFilename() throws InvalidArgumentException
Path path = new Path(L"/usr/myproject/conf/config.xml"); System.println( path.getFilename() ); // prints 'config.xml' System.println( path.getExtension() ); // prints '.xml'
InvalidArgumentException
public java.lang.String getExtension() throws InvalidArgumentException
InvalidArgumentException
public Path getParent() throws InvalidArgumentException
InvalidArgumentException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int getLength()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String sep)
sep
- separator to use.
public Path append(Path path)
path
- path to append to this object.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |