|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface EntityLocation<T extends EntityLocation<?>>
Interface for an file system entity location. An entity location describes an
entity's position in the file system hierarchy (its absolute path) or its
position relative to other entities (relative paths). Think of entity
locations as the path handling parts of java.io.File
.
An entity location consists of entity names separated by a SEPARATOR
("/"). An AbsoluteLocation
starts with a
"/". The two special entity names,
CURRENT_DIRECTORY_STRING
and PARENT_DIRECTORY_STRING
represents the current directory and the parent directory, respectively. A
valid entity name is a name that matches the regular expression
.
[^/\\\\]+
When an entity location object is created, its path is normalized,
which means that all parent and current directory entity strings are
expanded. For instance, new
AbsoluteLocation("/d1/d2/../d2p/f1").getLocation()
returns "/d1/d2p/f1"
. A canonical entity location is a normalized entity
location where symbolic links have been dereferenced (see java.io.File
documentation and
Entities.getCanonicalLocation(EntityView)
). For
file systems that don't support symbolic links, an entity's canonical
location is always equal to its normalized location.
Entity locations are always case sensitive.
Entity location objects are immutable value objects.
File
Field Summary | |
---|---|
static String |
CURRENT_DIRECTORY_STRING
The special entity name representing the current entity ("." ). |
static String |
EXTENSION_SEPARATOR
The separator in an entity name between the base entity name and the entity name extension ("." ). |
static String |
PARENT_DIRECTORY_STRING
The special entity name representing the parent directory (".." ). |
static String |
SEPARATOR
The separator between relative path entries in an entity location ("/" ). |
static char |
SEPARATOR_CHAR
A char representation of the SEPARATOR (47 ). |
Method Summary | |
---|---|
String |
getBaseName()
Return the entity name without extensions. |
T |
getChildLocation(String name)
Get the location of the named child entity relative to this location. |
String |
getExtension()
Get the entity name extension without the separator ( "."). |
String |
getLocation()
Get a string representation of the entity location. |
T |
getLocation(RelativeLocation loc)
Get the location of this entity location combined with the given relative location, represented by the same entity location type as this entity location. |
String |
getName()
Get the name of the entity referenced by this entity location. |
T |
getParentLocation()
Get the parent location of this entity location. |
LinkedList<String> |
getPathSegmentStack()
Get this entity location represented as a list of entity names. |
boolean |
isRootDir()
Is this entity location an absolute entity location referencing the root directory. |
Field Detail |
---|
static final String SEPARATOR
static final char SEPARATOR_CHAR
SEPARATOR
(47 ).
static final String EXTENSION_SEPARATOR
static final String CURRENT_DIRECTORY_STRING
static final String PARENT_DIRECTORY_STRING
Method Detail |
---|
String getLocation()
This always holds: new ELT(s).equals(new ELT(new
ELT(s).getLocation())) == true
for all valid entity location strings
s
and concrete entity location classes ELT
.
String getName()
String getExtension()
new
AbsoluteLocation("/d1/f.txt").getExtension()
returns txt
.
String getBaseName()
getName().equals(getBaseName() + "." +
getExtension()) == true
holds.
If the entity name starts with a dot, that first dot is ignored.
boolean isRootDir()
el.getLocation().equals(AbsoluteLocation.ROOT_DIR)
true
?
true
if this entity location is an absolute location
pointing to the root directory, false
otherwise.T getParentLocation() throws InvalidEntityLocationException
InvalidEntityLocationException
- If this is called on an absolute
entity location referencing the file system root.T getChildLocation(String name)
name
- The child entity name.
T getLocation(RelativeLocation loc) throws InvalidEntityLocationException
loc
- The location relative to this entity location.
InvalidEntityLocationException
- If the resulting location is an
absolute entity location pointing outside of the file system.LinkedList<String> getPathSegmentStack()
../foo/bar
gives the
following path segment stack:
..
foo
bar
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |