it.could.util.location
Class Path

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byit.could.util.location.Path
All Implemented Interfaces:
Collection, Encodable, EncodingAware, List

public class Path
extends AbstractList
implements Encodable

The Path class is an ordered collection of Element instances representing a path structure.

Author:
Pier Fumagalli

Nested Class Summary
static class Path.Element
          The Element class represents a path element within the Path structure.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface it.could.util.encoding.EncodingAware
DEFAULT_ENCODING, PLATFORM_ENCODING
 
Constructor Summary
Path(List elements, boolean absolute, boolean collection)
          Create a new Path instance.
Path(List elements, boolean absolute, boolean collection, Parameters parameters)
          Create a new Path instance.
 
Method Summary
 boolean equals(Object object)
          Check if the specified Object is equal to this Path instance.
 Object get(int index)
          Return the Element instance at the specified index.
 Parameters getParameters()
          Returns the collection of Parameters contained by this instance or null.
 int hashCode()
          Return the hash code value of this Path instance.
 boolean isAbsolute()
          Checks if this Path instance represents an absolute path.
 boolean isCollection()
          Checks if this Path instance represents a collection.
static Path parse(String path)
          Parse the specified String into a Path structure.
static Path parse(String path, String encoding)
          Parse the specified String into a Path structure.
 Path relativize(Path path)
          Retrieve the relativization path from this Path to the specified Path.
 Path relativize(String path)
          Parse the specified String into a Path and relativize it against this one.
 Path relativize(String path, String encoding)
          Parse the specified String into a Path and relativize it against this one.
 Path resolve(Path path)
          Resolve the specified Path against this one.
 Path resolve(String path)
          Parse the specified String into a Path and resolve it against this one.
 Path resolve(String path, String encoding)
          Parse the specified String into a Path and resolve it against this one.
 int size()
          Return the number of Element instances contained by this instance.
 String toString()
          Return the URL-encoded String representation of this Path instance.
 String toString(String encoding)
          Return the URL-encoded String representation of this Path instance using the specified character encoding.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

Path

public Path(List elements,
            boolean absolute,
            boolean collection)

Create a new Path instance.

Throws:
ClassCastException - if any of the elements in the List was not a Element.

Path

public Path(List elements,
            boolean absolute,
            boolean collection,
            Parameters parameters)

Create a new Path instance.

Throws:
ClassCastException - if any of the elements in the List was not a Element.
Method Detail

parse

public static Path parse(String path)

Parse the specified String into a Path structure.


parse

public static Path parse(String path,
                         String encoding)
                  throws UnsupportedEncodingException

Parse the specified String into a Path structure.

Throws:
UnsupportedEncodingException

resolve

public Path resolve(Path path)

Resolve the specified Path against this one.


resolve

public Path resolve(String path)

Parse the specified String into a Path and resolve it against this one.


resolve

public Path resolve(String path,
                    String encoding)
             throws UnsupportedEncodingException

Parse the specified String into a Path and resolve it against this one.

Throws:
NullPointerException - if the path String was null.
UnsupportedEncodingException

relativize

public Path relativize(String path)

Parse the specified String into a Path and relativize it against this one.


relativize

public Path relativize(String path,
                       String encoding)
                throws UnsupportedEncodingException

Parse the specified String into a Path and relativize it against this one.

Throws:
UnsupportedEncodingException

relativize

public Path relativize(Path path)

Retrieve the relativization path from this Path to the specified Path.


get

public Object get(int index)

Return the Element instance at the specified index.

Specified by:
get in interface List

size

public int size()

Return the number of Element instances contained by this instance.

Specified by:
size in interface List

isAbsolute

public boolean isAbsolute()

Checks if this Path instance represents an absolute path.


isCollection

public boolean isCollection()

Checks if this Path instance represents a collection.


getParameters

public Parameters getParameters()

Returns the collection of Parameters contained by this instance or null.


toString

public String toString()

Return the URL-encoded String representation of this Path instance.

Specified by:
toString in interface Encodable

toString

public String toString(String encoding)
                throws UnsupportedEncodingException

Return the URL-encoded String representation of this Path instance using the specified character encoding.

Specified by:
toString in interface Encodable
Throws:
UnsupportedEncodingException - if the specified encoding is not supported by the platform.

hashCode

public int hashCode()

Return the hash code value of this Path instance.

Specified by:
hashCode in interface List

equals

public boolean equals(Object object)

Check if the specified Object is equal to this Path instance.

The specified Object is considered equal to this one if it is non-null, is a Path instance and its string representation equals this one's.

Specified by:
equals in interface List