edu.upenn.cis.spinal
Class GornAddress

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractList
          extended by java.util.ArrayList
              extended by edu.upenn.cis.spinal.GornAddress
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class GornAddress
extends ArrayList

Implements a way of referring unambiguously to a particular node in a tree. A Gorn address a1, a2,...an-1, an denotes the anth child of the an-1th child of .... the a2th child of the root. The root itself is always represented as zero. Gorn addresses are used in the LTAG-spinal annotation to specify attachment sites in spinal nodes.

Author:
Lucas Champollion
See Also:
Serialized Form

Field Summary
static String SEPARATOR
          The symbol used to separate elements of the Gorn address from one another.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
GornAddress(String s)
          Creates a Gorn address from a string representation.
 
Method Summary
 boolean equals(Object o)
          Returns if this is equal to another GornAddress.
 int hashCode()
          Returns a hash code based on the canonical representation as indicated by the toString() value.
 String toString()
          Returns the canonical representation of this Gorn address -- a series of integers separated by dots.
 String toString(String separator)
          Returns a custom representation of this Gorn address -- a series of integers separated by a user-supplied argument.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

SEPARATOR

public static final String SEPARATOR
The symbol used to separate elements of the Gorn address from one another.

See Also:
Constant Field Values
Constructor Detail

GornAddress

public GornAddress(String s)
            throws NumberFormatException
Creates a Gorn address from a string representation.

Parameters:
s - a string that consists of a series of 1 or more integers separated by dots, such as 0 or 0.1.1
Throws:
NumberFormatException - if the string cannot be parsed into numbers
Method Detail

toString

public String toString()
Returns the canonical representation of this Gorn address -- a series of integers separated by dots.

Overrides:
toString in class AbstractCollection
Returns:
a string like 0 or 0.1.1

toString

public String toString(String separator)
Returns a custom representation of this Gorn address -- a series of integers separated by a user-supplied argument.

Parameters:
separator - the string used to separate the integers
Returns:
a string like 0 or 0_1_1 (if _ is provided as the separator)

hashCode

public int hashCode()
Returns a hash code based on the canonical representation as indicated by the toString() value.

Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class AbstractList
Returns:
a hash code

equals

public boolean equals(Object o)
Returns if this is equal to another GornAddress. Two Gorn addresses are equal iff their canonical representation as indicated by toString() is identical.

Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class AbstractList
Parameters:
o - the other object
Returns:
a boolean value