org.entityfs.el
Class AbstractLocation<T extends EntityLocation<?>>

java.lang.Object
  extended by org.entityfs.el.AbstractLocation<T>
All Implemented Interfaces:
Serializable, EntityLocation<T>
Direct Known Subclasses:
AbsoluteLocation, RelativeLocation

public abstract class AbstractLocation<T extends EntityLocation<?>>
extends Object
implements EntityLocation<T>

Abstract base class with implementations of EntityLocation methods.

Since:
1.0
Author:
Karl Gustafsson
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.entityfs.el.EntityLocation
CURRENT_DIRECTORY_STRING, EXTENSION_SEPARATOR, PARENT_DIRECTORY_STRING, SEPARATOR, SEPARATOR_CHAR
 
Constructor Summary
AbstractLocation()
           
 
Method Summary
 boolean equals(Object o)
           
 String getBaseName()
          Return the entity name without extensions.
 String getExtension()
          Get the entity name extension without the separator ( ".").
 String getName()
          Get a name from a location string.
 LinkedList<String> getPathSegmentStack()
          Get this entity location represented as a list of entity names.
 int hashCode()
           
 boolean isRootDir()
          Is this entity location an absolute entity location referencing the root directory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.entityfs.el.EntityLocation
getChildLocation, getLocation, getLocation, getParentLocation
 

Constructor Detail

AbstractLocation

public AbstractLocation()
Method Detail

isRootDir

public boolean isRootDir()
Description copied from interface: EntityLocation
Is this entity location an absolute entity location referencing the root directory. In other words, is el.getLocation().equals(AbsoluteLocation.ROOT_DIR) true?

Specified by:
isRootDir in interface EntityLocation<T extends EntityLocation<?>>
Returns:
true if this entity location is an absolute location pointing to the root directory, false otherwise.

getName

public String getName()
Get a name from a location string. The name is taken to be the string after the last separator (omitting separators ending the location string).

Specified by:
getName in interface EntityLocation<T extends EntityLocation<?>>
Returns:
The name part of the location.

getExtension

public String getExtension()
Description copied from interface: EntityLocation
Get the entity name extension without the separator ( "."). For instance, new AbsoluteLocation("/d1/f.txt").getExtension() returns txt.

Specified by:
getExtension in interface EntityLocation<T extends EntityLocation<?>>
Returns:
The entity name extension or an empty string if the entity name does not have an extension.

getBaseName

public String getBaseName()
Description copied from interface: EntityLocation
Return the entity name without extensions. If the entity name has one extension (one dot), then getName().equals(getBaseName() + "." + getExtension()) == true holds.

If the entity name starts with a dot, that first dot is ignored.

Specified by:
getBaseName in interface EntityLocation<T extends EntityLocation<?>>
Returns:
The entity name without extensions.

getPathSegmentStack

public LinkedList<String> getPathSegmentStack()
Description copied from interface: EntityLocation
Get this entity location represented as a list of entity names. For instance, the relative entity location ../foo/bar gives the following path segment stack:
  1. ..
  2. foo
  3. bar
If the path only consists of a dot, an empty stack (length 0) is returned. If the entity location ends with a slash, the last path segment is an empty string.

Specified by:
getPathSegmentStack in interface EntityLocation<T extends EntityLocation<?>>
Returns:
The stack of entity names in this entity location.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object