org.biojavax
Class SimpleNote

java.lang.Object
  extended by org.biojava.utils.AbstractChangeable
      extended by org.biojavax.SimpleNote
All Implemented Interfaces:
Comparable, Changeable, Note

public class SimpleNote
extends AbstractChangeable
implements Note

Simple implementation of Note.

Since:
1.5
Author:
Richard Holland, George Waldon - limited firing

Field Summary
 
Fields inherited from interface org.biojavax.Note
RANK, TERM, VALUE
 
Constructor Summary
protected SimpleNote()
           
  SimpleNote(ComparableTerm term, String value, int rank)
          Creates a new instance of SimpleNote with a given term, value and rank.
 
Method Summary
 int compareTo(Object o)
           Notes are compared first by rank, then by the term.
 boolean equals(Object o)
           Notes are equal if they have the same rank and term.
 int getRank()
          Gets the rank that defines this note.
 ComparableTerm getTerm()
          Gets the term that defines this note.
 String getValue()
          Gets the value that defines this note.
 int hashCode()
          
 void setRank(int rank)
          Sets the rank for this note.
 void setTerm(ComparableTerm term)
          Sets the term for this note.
 void setValue(String value)
          Sets the value for this note, or null for no value.
 String toString()
           Form: "(#rank) term: value"
 
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 

Constructor Detail

SimpleNote

public SimpleNote(ComparableTerm term,
                  String value,
                  int rank)
Creates a new instance of SimpleNote with a given term, value and rank.

Parameters:
term - the term of the note. Cannot be null.
value - the (optional) value to give it.
rank - the rank to give it.

SimpleNote

protected SimpleNote()
Method Detail

getTerm

public ComparableTerm getTerm()
Gets the term that defines this note.

Specified by:
getTerm in interface Note
Returns:
a ComparableTerm object that is the key to this note.

setTerm

public void setTerm(ComparableTerm term)
             throws ChangeVetoException
Sets the term for this note. It cannot be null.

Specified by:
setTerm in interface Note
Parameters:
term - the term to use.
Throws:
ChangeVetoException - if it doesn't like the term.

getValue

public String getValue()
Gets the value that defines this note.

Specified by:
getValue in interface Note
Returns:
a String object that is the value to this note.

setValue

public void setValue(String value)
              throws ChangeVetoException
Sets the value for this note, or null for no value.

Specified by:
setValue in interface Note
Parameters:
value - the value to use.
Throws:
ChangeVetoException - if it doesn't like the value.

getRank

public int getRank()
Gets the rank that defines this note.

Specified by:
getRank in interface Note
Returns:
an int that is the rank to this note.

setRank

public void setRank(int rank)
             throws ChangeVetoException
Sets the rank for this note.

Specified by:
setRank in interface Note
Parameters:
rank - the rank to use.
Throws:
ChangeVetoException - if it doesn't like the rank.

compareTo

public int compareTo(Object o)
Notes are compared first by rank, then by the term.

Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object o)
Notes are equal if they have the same rank and term.

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()
Form: "(#rank) term: value"

Overrides:
toString in class Object