|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.data.Path
public class Path
A general solution to the problem of dealing with representing a path to a node in a hierarchy. Generally you need a string representation, which of course causes encoding issues (embedded separators etc.). You also generally want to move up and down the hierarchy by pushing and popping subpaths.
This solution matches the way URLs represents paths. The string representation uses forward slashes (/) to separate subpaths. The root is represented as a single slash (/). Other paths look like /path/to/something.
Embedded slashes and other characters that are illegal in URLs are encoded the same way they are in URLs, using the recommended UTF-8 encoding. This may make the string representations look a little strange, since even spaces will be encoded.
See the the Wikipedia entry for Path for a description of the path concept.
Copyright 2005-2006 Partner Software, Inc.
| Constructor Summary | |
|---|---|
Path()
Constructs a path representing the current relative node ("./"). |
|
Path(PathBuilder builder)
Create a Path from a PathBuilder. |
|
Path(Path start,
Path subpath)
Creates a path derived from the given root and relative subpath. |
|
Path(Path start,
java.lang.String part)
Creates a path derived from the given root and part. |
|
Path(java.lang.String pathString)
Constructs a Path based on the String path representation. |
|
| Method Summary | |
|---|---|
Path |
createParentPath()
Creates a new instance of Path representing the "parent" of this path. |
static java.lang.String |
decode(java.lang.String string)
Decodes a String representing the name of a node in the path. |
static java.lang.String |
encode(java.lang.String string)
Encodes a String representing the name of a node in the path, so that e.g. |
static java.lang.String |
encodeAndJoin(java.lang.String[] parts)
Encodes each part to deal with embedded slashes and other problems, then joins them together into a single slash-separated String. |
java.lang.String |
getFileString()
Gets the path as a single, file-encoded String. |
java.lang.String |
getLastPart()
Returns the last path part. |
int |
getLength()
|
java.lang.String |
getPart(int index)
|
java.lang.String |
getPathString()
Gets the path as a single, URL-encoded String. |
boolean |
isAbsolute()
Returns true if this is an absolute path. |
java.util.Iterator |
iterator()
|
static java.lang.String[] |
splitAndDecode(java.lang.String pathString)
Splits the given Path String, decodes each part and returns it as a String array. |
Path |
subpath(int first)
This is intended to work like String.substring(). |
Path |
subpath(int first,
int last)
This is intended to work like String.substring(). |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Path()
public Path(java.lang.String pathString)
pathString - String representation, "/" delimited, of the path.
public Path(Path start,
Path subpath)
start - a path representing the starting nodesubpath - relative path to the starting node
public Path(Path start,
java.lang.String part)
start - a path representing the starting nodepart - next part in the pathpublic Path(PathBuilder builder)
builder - builder that built the path| Method Detail |
|---|
public static java.lang.String encode(java.lang.String string)
URLEncoder.
string - input name
public static java.lang.String decode(java.lang.String string)
URLDecoder.
string - input name
public static java.lang.String[] splitAndDecode(java.lang.String pathString)
pathString - Path represented and encoded as a String.
public static java.lang.String encodeAndJoin(java.lang.String[] parts)
parts - parts to join
public Path createParentPath()
public boolean isAbsolute()
public java.lang.String getPathString()
public java.lang.String getFileString()
public java.lang.String getLastPart()
public int getLength()
public java.lang.String getPart(int index)
public Path subpath(int first,
int last)
first - the index of the first path element to copy.last - the index after the last element to copy.
public Path subpath(int first)
first - the index of the first path element to copy.
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterable<java.lang.String>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||