org.biojavax
Class SimpleRankedDocRef

java.lang.Object
  extended by org.biojavax.SimpleRankedDocRef
All Implemented Interfaces:
Comparable, RankedDocRef

public class SimpleRankedDocRef
extends Object
implements RankedDocRef

Represents a documentary reference.

Since:
1.5
Author:
Richard Holland

Constructor Summary
protected SimpleRankedDocRef()
           
  SimpleRankedDocRef(DocRef docref, Integer start, Integer end, int rank)
          Constructs a new docref for a given location.
  SimpleRankedDocRef(DocRef docref, RichLocation location, int rank)
          Constructs a new docref for a given location.
 
Method Summary
 int compareTo(Object o)
           Ranked document references are sorted first by rank then by actual document reference.
 boolean equals(Object obj)
           Two ranked document references are equal if they have the same rank and refer to the same document reference.
 DocRef getDocumentReference()
          Represents a reference to a document.
 Integer getEnd()
          The end position in the sequence that this reference is referred to from.
 RichLocation getLocation()
          If this object was constructed using a location instead of two integers, then this method will return that location.
 int getRank()
          The rank of this reference.
 Integer getStart()
          The start position in the sequence that this reference is referred to from.
 int hashCode()
          
protected  void setLocation(RichLocation location)
           
 String toString()
           Form: "(#rank) docref"
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleRankedDocRef

public SimpleRankedDocRef(DocRef docref,
                          Integer start,
                          Integer end,
                          int rank)
Constructs a new docref for a given location. If one or the other of start and end are null, only the non-null value is used. If both are null, no value is used for the location.

Parameters:
docref - the document reference. Must not be null.
start - the start position of the location.
end - the end position of the location.

SimpleRankedDocRef

public SimpleRankedDocRef(DocRef docref,
                          RichLocation location,
                          int rank)
Constructs a new docref for a given location.

Parameters:
docref - the document reference. Must not be null.
location - the position of the document reference. Must not be null.

SimpleRankedDocRef

protected SimpleRankedDocRef()
Method Detail

getRank

public int getRank()
The rank of this reference. This value is intended to be set by the constructor of the implementing class.

Specified by:
getRank in interface RankedDocRef
Returns:
the rank.

getDocumentReference

public DocRef getDocumentReference()
Represents a reference to a document. This value is intended to be set by the constructor of the implementing class.

Specified by:
getDocumentReference in interface RankedDocRef
Returns:
the document reference.

getStart

public Integer getStart()
The start position in the sequence that this reference is referred to from. This value is intended to be set by the constructor of the implementing class. The position returned is from 1 to the length of the sequence.

Specified by:
getStart in interface RankedDocRef
Returns:
the start position.

getEnd

public Integer getEnd()
The end position in the sequence that this reference is referred to from. This value is intended to be set by the constructor of the implementing class. The position returned is from 1 to the length of the sequence.

Specified by:
getEnd in interface RankedDocRef
Returns:
the end position.

setLocation

protected void setLocation(RichLocation location)

getLocation

public RichLocation getLocation()
Description copied from interface: RankedDocRef
If this object was constructed using a location instead of two integers, then this method will return that location. The getStart() and getEnd() methods will then return the min and max of that location, using the default location position resolver to resolve them to exact positions. If this object was constructed using two integers, then this method will return a simple location whose min and max correspond to those integers.

Specified by:
getLocation in interface RankedDocRef
Returns:
the location of this reference on the sequence.

equals

public boolean equals(Object obj)
Two ranked document references are equal if they have the same rank and refer to the same document reference.

Overrides:
equals in class Object

compareTo

public int compareTo(Object o)
Ranked document references are sorted first by rank then by actual document reference.

Specified by:
compareTo in interface Comparable

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()
Form: "(#rank) docref"

Overrides:
toString in class Object