|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface PathFinder
An interface to file path finders. The path finder maintains mappings between keys and folders. The finder searches for files with relative pathnames from the specified key folders in their definition order. The first one found is returned. If none is found, an abstract pathname to the first defined folder mapped to the specified key is returned.
A set of standard keys are defined as constants, but new ones can be freely added.
| Field Summary | |
|---|---|
static String |
BINARY
The binany folders key. |
static String |
CGI_BIN
The cgi-bin folders key. |
static String |
CONFIG
The config folders key. |
static String |
CONTEXT
The context folders key. |
static String |
CSV_EXTENSION
The CSV file extension. |
static String |
DATA
The data folders key. |
static String |
DEFAULT_DATA_PROPERTY
The system property for defining the default data folder. |
static String |
DEFAULT_LOGS_PROPERTY
The system property for defining the default logs folder. |
static String |
DEFAULT_TEMP_PROPERTY
The system property for defining the default temp folder. |
static String |
LIBRARY
The library folders key. |
static String |
LICENSE
The license folders key. |
static String |
LOGS
The logs folders key. |
static String |
MEDIA
The media folders key. |
static String |
PROPERTIES_EXTENSION
The property file extension. |
static String |
RESOURCE
The resource folders key. |
static String |
SCRIPT
The script folders key. |
static String |
SECURITY
The security folders key. |
static String |
START
The start folders key. |
static String |
STOP
The stop folders key. |
static String |
TEMP
The temp folders key. |
static String |
TEMPLATE
The template folders key. |
static String |
XML_EXTENSION
The XML file extension. |
| Method Summary | |
|---|---|
void |
addContextPath(int index,
String path)
Adds a context path to the specified index. |
void |
addContextPath(String path)
Adds a context path if not already specified. |
void |
addFolderPath(String key,
int index,
String path)
Adds a key folder path to the specified index. |
void |
addFolderPath(String key,
String path)
Adds a key folder path if not already specified. |
void |
clearContext()
Clears all context paths. |
void |
clearFolder(String key)
Clears a key folder. |
void |
clearFolders()
Clears all key folders. |
boolean |
deleteFile(File file)
Deletes a file or folder and its contents. |
File |
findFile(String path)
Finds a file relative to the root folder. |
File |
findFile(String key,
String path)
Finds a file relative to a key folder. |
File |
findFile(String key,
String path,
Locale locale)
Finds a localized file relative to a key folder. |
File |
findFile(String key,
String path,
Locale locale,
String variant)
Finds a localized file with an optional variant relative to a key folder. |
OrderedSet |
findFolders(String key)
Finds all existing folders corresponding to the specified key by applying the context paths of this path finder. |
URL |
findResource(String path)
Finds a root resource using a local class loader. |
URL |
findResource(String key,
String path)
Finds a key resource using a local class loader. |
URL |
findResource(String key,
String path,
Locale locale)
Finds a localized key resource using a local class loader. |
URL |
findResource(String key,
String path,
Locale locale,
String variant)
Finds a localized key resource with an optional variant using a local class loader. |
URL |
findURL(String path)
Finds a file relative to the root folder or a root resource using a local class loader. |
URL |
findURL(String key,
String path)
Finds a file relative to a key folder or a key resource using a local class loader. |
URL |
findURL(String key,
String path,
Locale locale)
Finds a localized file relative to a key folder or a localized key resource using a local class loader. |
URL |
findURL(String key,
String path,
Locale locale,
String variant)
Finds a localized file relative to a key folder or a localized key resource, with an optional variant, using a local class loader. |
Set |
folderKeySet()
Returns a read-only set of specified folder keys. |
ClassLoader |
getContextClassLoader()
Gets a context class loader loading resources from context paths of this path finder. |
String[] |
getContextPaths()
Gets the context paths. |
String[] |
getFolderPaths(String key)
Gets the specified key folder paths. |
File |
getRootFolder()
Gets the root folder. |
String |
getRootPath()
Gets the root path. |
File |
getSystemFolder()
Gets the operating system folder. |
boolean |
isNormalizedPaths()
Checks whether requested paths are normalized before search to reject absolute search paths and references outside context paths folders. |
void |
removeContextPath(String path)
Removes a context path. |
void |
removeFolderPath(String key,
String path)
Removes a key folder path. |
void |
setContextPaths(String[] paths)
Sets the context paths.. |
void |
setFolderPaths(String key,
String[] paths)
Sets the specified key folder paths. |
void |
setNormalizedPaths(boolean flag)
Sets whether requested paths are normalized before search to reject absolute search paths and references outside context paths folders. |
void |
setRootPath(String path)
Sets the root path. |
URL |
toURL(String path)
Converts a URL path, local path or jar path relative to the root folder to a URL instance. |
URL |
toURL(String key,
String path)
Converts a URL path, local path or jar path relative to the key folder to a URL instance. |
| Field Detail |
|---|
static final String CONTEXT
static final String BINARY
static final String LIBRARY
static final String LICENSE
static final String MEDIA
static final String CGI_BIN
static final String RESOURCE
static final String TEMPLATE
static final String DATA
static final String TEMP
static final String LOGS
static final String START
static final String STOP
static final String SCRIPT
static final String CONFIG
static final String SECURITY
static final String XML_EXTENSION
static final String CSV_EXTENSION
static final String PROPERTIES_EXTENSION
static final String DEFAULT_DATA_PROPERTY
static final String DEFAULT_TEMP_PROPERTY
static final String DEFAULT_LOGS_PROPERTY
| Method Detail |
|---|
boolean isNormalizedPaths()
void setNormalizedPaths(boolean flag)
flag - true if normalized, false otherwise.File getRootFolder()
String getRootPath()
void setRootPath(String path)
path - the root path.String[] getContextPaths()
void setContextPaths(String[] paths)
paths - an array of context paths.void addContextPath(String path)
path - the context path.
void addContextPath(int index,
String path)
index - the path index.path - the context path.void removeContextPath(String path)
path - the context path.void clearContext()
String[] getFolderPaths(String key)
key - the folder key.
void setFolderPaths(String key,
String[] paths)
key - the folder key.paths - an array of key folder paths.
void addFolderPath(String key,
String path)
key - the folder key.path - the key folder path.
void addFolderPath(String key,
int index,
String path)
key - the folder key.index - the path index.path - the key folder path.
void removeFolderPath(String key,
String path)
key - the folder key.path - the key folder path.void clearFolder(String key)
key - the folder key.void clearFolders()
Set folderKeySet()
boolean deleteFile(File file)
file - the file to delete.
OrderedSet findFolders(String key)
key - a folder key.
java.io.File instances.URL findURL(String path)
path - a path to find.
URL findURL(String key,
String path)
key - a folder key or null for the root.path - a path to find.
URL findURL(String key,
String path,
Locale locale)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.
URL findURL(String key,
String path,
Locale locale,
String variant)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.variant - a variant to the locale.
File findFile(String path)
path - a path to find.
File findFile(String key,
String path)
key - a folder key or null for the root.path - a path to find.
File findFile(String key,
String path,
Locale locale)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.
File findFile(String key,
String path,
Locale locale,
String variant)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.variant - a variant to the locale.
URL findResource(String path)
path - a path to find.
URL findResource(String key,
String path)
key - a folder key or null for the root.path - a path to find.
URL findResource(String key,
String path,
Locale locale)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.
URL findResource(String key,
String path,
Locale locale,
String variant)
key - a folder key or null for the root.path - a path to find.locale - the locale of the path.variant - a variant to the locale.
URL toURL(String path)
throws MalformedURLException
path - a path to find.
MalformedURLException - for an invalid URL path.
URL toURL(String key,
String path)
throws MalformedURLException
key - a folder key.path - a path to find.
MalformedURLException - for an invalid URL path.ClassLoader getContextClassLoader()
File getSystemFolder()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||