com.novell.sentinel.uri
Class GenericURI.Path

java.lang.Object
  extended by com.novell.sentinel.uri.GenericURI.Path
Enclosing class:
GenericURI

public static class GenericURI.Path
extends Object

A class used to parse and store path segments of the path component of a URI.


Field Summary
static PercentCodex PATH_CODEX
          An encoder that encodes a path segment.
 
Constructor Summary
GenericURI.Path()
          Construct an empty instance.
GenericURI.Path(GenericURI.Path src)
          Construct a deep-copy of the passed source instance.
GenericURI.Path(String... pathComponents)
          Construct an instance from the passed segments.
GenericURI.Path(String path)
          Construct an instance from an unparsed, encoded path component of a URI.
 
Method Summary
 void append(GenericURI.Path path)
          Append the passed information as segments in the path represented by this instance.
 void appendComponents(String... pathComponents)
          Append the passed literal strings as segments of this path.
 List<String> components()
          Return a List of path segments.
 String getRaw()
          Get the raw, unparsed, encoded string used to construct or set this instance, if any.
 boolean isAbsolute()
          Return true if the path is absolute (i.e., starts with '/').
 boolean isEmpty()
          Return if the path is empty or not.
 void set(String path)
          Set the path information from the passed, raw, encoded path component string.
 void setAbsolute()
          Set the instance to be an absolute path.
protected  void setRaw(String rawPath)
          Set the raw string.
 void setRelative()
          Set the instance to be a relative path.
 String toString()
          Output an encoded String for use in a URI as the path component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PATH_CODEX

public static final PercentCodex PATH_CODEX
An encoder that encodes a path segment. The reserved characters (those that are percent encoded in a constructed URI string) are: '/', '?', '#', '[', ']'.

Constructor Detail

GenericURI.Path

public GenericURI.Path()
Construct an empty instance.


GenericURI.Path

public GenericURI.Path(String... pathComponents)
Construct an instance from the passed segments. The passed segments are literal, unencoded strings.

Parameters:
pathComponents - The path segments.

GenericURI.Path

public GenericURI.Path(String path)
Construct an instance from an unparsed, encoded path component of a URI.

Parameters:
path - The raw path string.

GenericURI.Path

public GenericURI.Path(GenericURI.Path src)
Construct a deep-copy of the passed source instance.

Parameters:
src - The source instance to be copied.
Method Detail

isEmpty

public boolean isEmpty()
Return if the path is empty or not. The path is not considered empty if consists only of a leading '/' (in other words, is an otherwise empty absolute path).

Returns:
true if the path is empty, false if the path has one or more segments, or is an empty absolute path.

isAbsolute

public boolean isAbsolute()
Return true if the path is absolute (i.e., starts with '/').

Returns:
true if absolute.

setRelative

public void setRelative()
Set the instance to be a relative path. This will prevent a leading '/' from being output.


setAbsolute

public void setAbsolute()
Set the instance to be an absolute path. This will cause a leading '/' to be output.


components

public List<String> components()
Return a List of path segments. If there are no segments, an empty list is returned.

Returns:
The path segments, if any.

set

public void set(String path)
Set the path information from the passed, raw, encoded path component string.

Parameters:
path - The raw string.

append

public void append(GenericURI.Path path)
Append the passed information as segments in the path represented by this instance.

Parameters:
path - The instance whose segments are to be appended to this instance.

appendComponents

public void appendComponents(String... pathComponents)
Append the passed literal strings as segments of this path.

Parameters:
pathComponents - The segments to append.

toString

public String toString()
Output an encoded String for use in a URI as the path component.

Overrides:
toString in class Object

getRaw

public String getRaw()
Get the raw, unparsed, encoded string used to construct or set this instance, if any.

Returns:
The raw string, or null.

setRaw

protected void setRaw(String rawPath)
Set the raw string. This is designed to be used in conjunction with the various setters. If a structured setter is used, the raw data should be set to null.

Parameters:
rawPath - The string to set, or null.