Class SimpleAlphabet
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.bio.symbol.AbstractAlphabet
-
- org.biojava.bio.symbol.SimpleAlphabet
-
- All Implemented Interfaces:
Serializable
,Annotatable
,Alphabet
,FiniteAlphabet
,Changeable
public class SimpleAlphabet extends AbstractAlphabet implements Serializable
A simple no-frills implementation of the FiniteAlphabet interface.- Author:
- Matthew Pocock
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
-
-
Field Summary
Fields Modifier and Type Field Description protected ChangeForwarder
annotationForwarder
-
Fields inherited from interface org.biojava.bio.symbol.Alphabet
EMPTY_ALPHABET, PARSERS, SYMBOLS
-
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
-
-
Constructor Summary
Constructors Constructor Description SimpleAlphabet()
SimpleAlphabet(String name)
SimpleAlphabet(Set symbols)
SimpleAlphabet(Set symbols, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addSymbolImpl(AtomicSymbol s)
protected boolean
containsImpl(AtomicSymbol s)
List
getAlphabets()
Return an ordered List of the alphabets which make up a compound alphabet.Annotation
getAnnotation()
Should return the associated annotation object.protected ChangeSupport
getChangeSupport(ChangeType ct)
Called to retrieve the ChangeSupport for this object.String
getName()
Get the name of the alphabet.protected AtomicSymbol
getSymbolImpl(List symL)
Iterator
iterator()
Retrieve an Iterator over the AtomicSymbols in this FiniteAlphabet.void
removeSymbol(Symbol s)
Remove a symbol from this alphabet.void
setName(String name)
Assign a name to the alphabetint
size()
The number of symbols in the alphabet.-
Methods inherited from class org.biojava.bio.symbol.AbstractAlphabet
addSymbol, contains, getAmbiguity, getAmbiguityImpl, getGapSymbol, getSymbol, getTokenization, putTokenization, readResolve, toString, validate
-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
annotationForwarder
protected transient ChangeForwarder annotationForwarder
-
-
Constructor Detail
-
SimpleAlphabet
public SimpleAlphabet()
-
SimpleAlphabet
public SimpleAlphabet(Set symbols)
-
SimpleAlphabet
public SimpleAlphabet(String name)
-
SimpleAlphabet
public SimpleAlphabet(Set symbols, String name)
-
-
Method Detail
-
iterator
public Iterator iterator()
Description copied from interface:FiniteAlphabet
Retrieve an Iterator over the AtomicSymbols in this FiniteAlphabet.Each AtomicSymbol as for which this.contains(as) is true will be returned exactly once by this iterator in no specified order.
- Specified by:
iterator
in interfaceFiniteAlphabet
- Returns:
- an Iterator over the contained AtomicSymbol objects
-
getName
public String getName()
Description copied from interface:Alphabet
Get the name of the alphabet.
-
setName
public void setName(String name)
Assign a name to the alphabet- Parameters:
name
- the name you wish to give this alphabet
-
getAnnotation
public Annotation getAnnotation()
Description copied from interface:Annotatable
Should return the associated annotation object.- Specified by:
getAnnotation
in interfaceAnnotatable
- Returns:
- an Annotation object, never null
-
size
public int size()
Description copied from interface:FiniteAlphabet
The number of symbols in the alphabet.- Specified by:
size
in interfaceFiniteAlphabet
- Returns:
- the size of the alphabet
-
containsImpl
protected boolean containsImpl(AtomicSymbol s)
- Specified by:
containsImpl
in classAbstractAlphabet
-
addSymbolImpl
protected void addSymbolImpl(AtomicSymbol s) throws IllegalSymbolException, ChangeVetoException
- Specified by:
addSymbolImpl
in classAbstractAlphabet
- Throws:
IllegalSymbolException
ChangeVetoException
-
removeSymbol
public void removeSymbol(Symbol s) throws IllegalSymbolException
Description copied from interface:FiniteAlphabet
Remove a symbol from this alphabet.If the symbol matches multiple AtomicSymbols, then each matching symbol it will be removed.
- Specified by:
removeSymbol
in interfaceFiniteAlphabet
- Parameters:
s
- the Symbol to removeintGot- Throws:
IllegalSymbolException
- if the symbol is null, or if for any reason it can't be removed
-
getAlphabets
public List getAlphabets()
Description copied from interface:Alphabet
Return an ordered List of the alphabets which make up a compound alphabet. For simple alphabets, this will return a singleton list of itself. The returned list should be immutable.- Specified by:
getAlphabets
in interfaceAlphabet
- Returns:
- a List of alphabets
-
getSymbolImpl
protected AtomicSymbol getSymbolImpl(List symL) throws IllegalSymbolException
- Specified by:
getSymbolImpl
in classAbstractAlphabet
- Throws:
IllegalSymbolException
-
getChangeSupport
protected ChangeSupport getChangeSupport(ChangeType ct)
Description copied from class:AbstractChangeable
Called to retrieve the ChangeSupport for this object.Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to be transient and lazily instantiated. Be sure to register & unregister the forwarder in the code that does the ChangeEvent handling in setter methods.ChangeSupport cs = super.getChangeSupport(ct); if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) { someForwarder = new ChangeForwarder(... this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange); } return cs;
- Overrides:
getChangeSupport
in classAbstractChangeable
-
-