gov.usda.gdpc
Class Identifier

java.lang.Object
  extended bygov.usda.gdpc.Identifier
All Implemented Interfaces:
java.lang.Comparable

public final class Identifier
extends java.lang.Object
implements java.lang.Comparable

This is an identifier which should uniquely identify a database element for a given database element type (e.g. Locus) and datasource.

Author:
terryc

Constructor Summary
Identifier(java.lang.String name)
          Identifier constructor.
Identifier(java.lang.String name, java.lang.String[] hints)
          Identifier constructor.
 
Method Summary
 java.lang.String asString()
          Returns string representation of this identifier.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object obj)
          This determines if two identifiers are equal.
 java.lang.String getHint(int index)
          Get hint at given index.
 java.lang.String[] getHints()
          Get list of hints.
 int getNumber()
          Return identifier as number.
 int numHints()
          Returns the number of defined hints.
 java.lang.String toString()
          Returns string representation of this identifier.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Identifier

public Identifier(java.lang.String name)
Identifier constructor.

Parameters:
name - Unique string representation of this identifier. Can not be null.

Identifier

public Identifier(java.lang.String name,
                  java.lang.String[] hints)
Identifier constructor.

Parameters:
name - Unique string representation of this identifier. Can not be null.
hints - Hints for convenience. These hints do not make the identifier unique.
Method Detail

asString

public java.lang.String asString()
Returns string representation of this identifier.

Returns:
string representation

toString

public java.lang.String toString()
Returns string representation of this identifier.

Returns:
string representation

numHints

public int numHints()
Returns the number of defined hints.

Returns:
number of hints

getHint

public java.lang.String getHint(int index)
                         throws java.lang.IndexOutOfBoundsException
Get hint at given index.

Parameters:
index - index
Returns:
hint
Throws:
java.lang.IndexOutOfBoundsException

getHints

public java.lang.String[] getHints()
Get list of hints.

Returns:
hints

getNumber

public int getNumber()
              throws java.lang.NumberFormatException
Return identifier as number. Only works if identifier is an integer number.

Returns:
number
Throws:
java.lang.NumberFormatException

equals

public boolean equals(java.lang.Object obj)
This determines if two identifiers are equal.

Parameters:
obj - object to test
Returns:
true if equal

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive. The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object.