bibliothek.extension.gui.dock.util
Class Path

java.lang.Object
  extended by bibliothek.extension.gui.dock.util.Path

public final class Path
extends Object

A path is a description of the position of some resource. A path consists of segments, segments are separated by a dot. A segment must be a valid java-identifier.

Author:
Benjamin Sigg

Field Summary
static Path TYPE_BOOLEAN_PATH
          standard path for Boolean
static Path TYPE_INT_PATH
          standard path for Integer
static Path TYPE_KEYSTROKE_PATH
          standard path for KeyStroke, can use KeyStrokeValidator as information
static Path TYPE_MODIFIER_MASK_PATH
          standard path for ModifierMask
static Path TYPE_STRING_CHOICE_PATH
          standard path for a choice using a String as value and a Choice as information
static Path TYPE_STRING_PATH
          standard path for String
 
Constructor Summary
Path()
          Creates a new root path.
Path(String path)
          Creates a new path.
 
Method Summary
 Path append(Path path)
          Creates a new path which is a combination of this and path.
 Path append(String segments)
          Creates a new path appending segments to this path.
 boolean equals(Object obj)
           
 String getLastSegment()
          Gets the last segment of this path or null if this is the root path.
 Path getParent()
          Returns the parent of this path.
 String getSegment(int index)
          Gets the index'th segment of this path.
 int getSegmentCount()
          Gets the number of segments of this path.
 int hashCode()
           
 Path subPath(int offset, int length)
          Creates a new path that is a subset of this path.
 String toString()
           
 Path uniqueAppend(Path path)
          Creates a new path which is not only a combination of this and path, but is also unique in the way that x+y.z would not yield the same as x.y+z.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_INT_PATH

public static final Path TYPE_INT_PATH
standard path for Integer


TYPE_STRING_PATH

public static final Path TYPE_STRING_PATH
standard path for String


TYPE_BOOLEAN_PATH

public static final Path TYPE_BOOLEAN_PATH
standard path for Boolean


TYPE_KEYSTROKE_PATH

public static final Path TYPE_KEYSTROKE_PATH
standard path for KeyStroke, can use KeyStrokeValidator as information


TYPE_MODIFIER_MASK_PATH

public static final Path TYPE_MODIFIER_MASK_PATH
standard path for ModifierMask


TYPE_STRING_CHOICE_PATH

public static final Path TYPE_STRING_CHOICE_PATH
standard path for a choice using a String as value and a Choice as information

Constructor Detail

Path

public Path()
Creates a new root path.


Path

public Path(String path)
Creates a new path.

Parameters:
path - the dot-separated segments of this path, each segment must be a valid Java-identifier. Note that no segment should start with "_"
Method Detail

getSegmentCount

public int getSegmentCount()
Gets the number of segments of this path.

Returns:
the number of segments

getSegment

public String getSegment(int index)
Gets the index'th segment of this path.

Parameters:
index - the location of the segment
Returns:
the segment

getLastSegment

public String getLastSegment()
Gets the last segment of this path or null if this is the root path.

Returns:
the last segment or null

subPath

public Path subPath(int offset,
                    int length)
Creates a new path that is a subset of this path.

Parameters:
offset - the begin of the new path
length - the length of the new path, at least 1
Returns:
the new path

append

public Path append(Path path)
Creates a new path which is a combination of this and path.

Parameters:
path - the path to add
Returns:
the new path

uniqueAppend

public Path uniqueAppend(Path path)
Creates a new path which is not only a combination of this and path, but is also unique in the way that x+y.z would not yield the same as x.y+z. This implies also that (x+y)+z would result in another path than x+(y+z). Note that the result of this method differs from append(Path). Note also that the new path has a different prefix than this.

Parameters:
path - the additional path
Returns:
the new path

append

public Path append(String segments)
Creates a new path appending segments to this path.

Parameters:
segments - the additional segments
Returns:
the new path

getParent

public Path getParent()
Returns the parent of this path.

Returns:
the parent or null if this is the root

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

toString

public String toString()
Overrides:
toString in class Object