edu.upenn.cis.spinal
Class GornAddress
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
java.util.ArrayList
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. |
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 |
SEPARATOR
public static final String SEPARATOR
- The symbol used to separate elements of the Gorn address from one another.
- See Also:
- Constant Field Values
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
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