## org.biojava.bio.symbol
Interface Alphabet

All Known Subinterfaces:
  CrossProductAlphabet, FiniteAlphabet

All Known Implementing Classes:
  DoubleAlphabet, IntegerAlphabet

public interface Alphabet
extends Annotatable

The set of AtomicSymbols which can be concatanated together to make a SymbolList.

A non-atomic symbol is considered to be contained within this alphabet if all of the atomic symbols that it could match are members of this alphabet.

The alphabet concept may need to be widened to include alphabets that extend others, or checks to see if two alphabets are equivalent, or other set-wise operations. As yet, I have baulked at this as it may make Alphabet too heavy to easily implement.

Author:
  Matthew Pocock

Inner Class Summary
`static class` `Alphabet.EmptyAlphabet` The class that implements Alphabet and is empty.

Field Summary
`static Alphabet` `EMPTY_ALPHABET` A really useful static alphabet that is always empty.

Method Summary
`boolean` `contains(Symbol r)` Returns whether or not this Alphabet contains the symbol.
`java.lang.String` `getName()` Get the name of the alphabet.
`SymbolParser` `getParser(java.lang.String name)` Get a parser by name.
`void` `validate(Symbol r)` Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.

Methods inherited from interface org.biojava.bio.Annotatable
`getAnnotation`

Field Detail

### EMPTY_ALPHABET

    public static final Alphabet EMPTY_ALPHABET

  A really useful static alphabet that is always empty.

Method Detail

### getName

    public java.lang.String getName()

  Get the name of the alphabet.
  Returns:
    the name as a string.

### contains

    public boolean contains(Symbol r)

  Returns whether or not this Alphabet contains the symbol.

  An alphabet contains an ambiguity symbol iff the ambiguity symbol's getMemberAlphabet() returns an alphabe that is a propper sub-set of this alphabet. That means that every one of the symbols that could mach the ambiguity symbol is also a member of this alphabet.

  Parameters:
    `r` - the Symbol to check
  Returns:
    boolean true if the Alphabet contains the symbol and false otherwise

### validate

    public void validate(Symbol r)
                  throws IllegalSymbolException

  Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.

  This function is used all over the code to validate symbols as they enter a method. Also, the code is littered with catches for IllegalSymbolException. There is a preferred style of handling this, which should be covererd in the package documentation.

  Parameters:
    `r` - the Symbol to validate
  Throws:
    IllegalSymbolException - if r is not contained in this alphabet

### getParser

    public SymbolParser getParser(java.lang.String name)
                           throws java.util.NoSuchElementException,
                                  BioException

  Get a parser by name.

  The parser returned is guaranteed to return Symbols and SymbolLists that conform to this alphabet.

  Every alphabet should have a SymbolParser under the name 'token' that uses the symbol token characters to translate a string into a SymbolList. Likewise, there should be a SymbolParser under the name 'name' that uses symbol names to identify symbols. Any other names may also be defined, but the behaviour of that parser is not defined here.

  Parameters:
    `name` - the name of the parser
  Returns:
    a parser for that name
  Throws:
    java.util.NoSuchElementException - if the name is unknown
    BioException - if for any reason the parser could not be built