|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.basedb.core.Path
public class Path
This class is used represent the path to a Directory
or File item. Some examples:
| / | The root diretory |
| /filename | A file in the root diretory |
| /directory | A directory in root diretory |
| /directory/filename | A file in a directory |
| /directory/subdirectory | A subdirectory |
| /directory/subdirectory/filename | A file in a subdirectory |
| ~ | The currently logged in user's home directory |
| ~/filename | A file in the current user's home directory |
| ~/directory | A directory in the current user's home directory |
| ~login | The home directory of the user with the specified login |
| ~login/filename | A file in the home directory of the user with the specified login |
| ~login/directory | A directory in the home directory of the user with the specified login |
| Nested Class Summary | |
|---|---|
static class |
Path.Type
An enum that describes what type the path is |
| Field Summary | |
|---|---|
private String[] |
directories
The directory part of the path. |
private String |
filename
The filename part of the path. |
private static Pattern |
invalid
A regexp checking for invalid characters. |
static String |
INVALID_CHARACTERS
These characters are not valid within a file or directory name: "~\\/:;*?<>|\"" |
private Path.Type |
type
The type of the path. |
private String |
userlogin
The userlogin part of the path. |
| Constructor Summary | |
|---|---|
Path(Path directoryPath,
String filename)
Create a new Path object. |
|
Path(String path,
Path.Type type)
Create a new Path object by parsing the given string. |
|
Path(String userlogin,
String[] directories,
String filename)
Create a new Path object. |
|
| Method Summary | |
|---|---|
String |
getDirectory(int i)
Get the name of the i:th directory on the path, starting with 0. |
int |
getDirectoryCount()
Get the number of directories on the path. |
String |
getFilename()
Get the filename part of the path. |
Path |
getParent()
Get the parent path. |
Path.Type |
getType()
Get the type of the path. |
String |
getUserLogin()
Get the userlogin part of the path. |
static boolean |
isValidName(String name)
Check if a name is valid as a partial path name, ie. it must not contain any of the characters in INVALID_CHARACTERS. |
static String |
makeSafeFilename(String originalName,
String replaceWith)
Convert a string to a name that is safe to use as a filename. |
String |
toString()
Get the string representation of the path. |
String |
toURLString(String enc)
Get this Path's URL-string encoded with a given character encoding. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String INVALID_CHARACTERS
private static final Pattern invalid
private Path.Type type
private String userlogin
private String[] directories
private String filename
| Constructor Detail |
|---|
public Path(String path,
Path.Type type)
throws InvalidPathException
Path object by parsing the given string.
path - The string representation of a pathtype - If the path represents a Path.Type.FILE or
Path.Type.DIRECTORY
InvalidPathException - If the path is not valid
Path(String userlogin,
String[] directories,
String filename)
Path object.
userlogin - The userlogin part of the pathdirectories - The directories in the pathfilename - The filename part of the path
Path(Path directoryPath,
String filename)
Path object.
directoryPath - The directory pathfilename - The filename part of the path| Method Detail |
|---|
public static boolean isValidName(String name)
INVALID_CHARACTERS.
name - The string to be tested.
public static String makeSafeFilename(String originalName,
String replaceWith)
INVALID_CHARACTERS charactes with the specified string.
originalName - The original namereplaceWith - The string to replace all unsafe characters withpublic Path getParent()
public Path.Type getType()
Path.Type of the Pathpublic String getUserLogin()
public int getDirectoryCount()
public String getDirectory(int i)
i - Should be between 0 and getDirectoryCount-1
public String getFilename()
public String toString()
toString in class Object
public String toURLString(String enc)
throws UnsupportedEncodingException
enc - The encoding to use. UTF-8 is used is this is null.
UnsupportedEncodingException - If the give encoding is not supported
|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||