## org.biojava.bio.symbol
Class SimpleSymbolList

    java.lang.Object
      org.biojava.utils.AbstractChangeable
          org.biojava.bio.symbol.AbstractSymbolList
              org.biojava.bio.symbol.SimpleSymbolList

All Implemented Interfaces:
  Serializable, EventListener, SymbolList, Changeable, ChangeListener

    public class SimpleSymbolList

extends AbstractSymbolList
implements ChangeListener, Serializable

Basic implementation of SymbolList. This is currently backed by a normal Java array.

SimpleSymbolList is now editable. edit() has been implemented in a way that edits are relatively inefficient, but symbolAt() is very efficient.

A new constructor SimpleSymbolList(SymbolParser,String) has been added so you can now simply turn a String into a SymbolList. This is mostly to provide a simple way to create a SymbolList for people just trying to get their feet wet. So here is an example.

`String seqString = "gaattc"; FiniteAlphabet dna = (FiniteAlphabet) AlphabetManager.alphabetForName("DNA"); SymbolParser parser = dna.getParser("token"); SymbolList mySl = new SimpleSymbolList (parser,seqString); System.out.println("Look at my sequence " + mySl.seqString());`

with the right parser you should be able to make a protein sequence from the String "AspAlaValIleAsp"

subList() is implemented such that subLists are views of the original until such time as the underlying SymbolList is edited in a way that would modify the subList, at which point the subList gets its own array of Symbols and does not reflect the edit to the original. When subList() is called on another subList (which is a veiw SimpleSymbolList) the new SimpleSymbolList is a view of the original, not the subList.

Author:
  Thomas Down, David Waring, David Huen (another constructor), George Waldon
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.biojava.bio.symbol.AbstractSymbolList
`AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater`

Nested classes/interfaces inherited from interface org.biojava.utils.ChangeListener
`ChangeListener.AlwaysVetoListener, ChangeListener.ChangeEventRecorder, ChangeListener.LoggingListener`

Field Summary

Fields inherited from interface org.biojava.utils.ChangeListener
`ALWAYS_VETO, LOG_TO_OUT`

Fields inherited from interface org.biojava.bio.symbol.SymbolList
`EDIT, EMPTY_LIST`

Constructor Summary
`SimpleSymbolList(Alphabet alpha)` Construct an empty SimpleSymbolList.
`SimpleSymbolList(Alphabet alpha, List rList)` Construct a SymbolList containing the symbols in the specified list.
`SimpleSymbolList(Symbol[] symbols, int length, Alphabet alphabet)` Construct a SimpleSymbolList given the Symbol array that backs it.
`SimpleSymbolList(SymbolList sl)` Construct a copy of an existing SymbolList.
`SimpleSymbolList(SymbolTokenization parser, String seqString)` Construct a SymbolList from a string.

Method Summary
`void` `addSymbol(Symbol sym)` Add a new Symbol to the end of this list.
`void` `edit(Edit edit)` Apply and edit to the SymbolList as specified by Edit.
`protected void` `finalize()`
`Alphabet` `getAlphabet()` Get the alphabet of this SymbolList.
`Symbol[]` `getSymbolArray()` Return the Java Symbol[] array that backs this object.
`int` `length()` Get the length of this SymbolList.
`void` `postChange(ChangeEvent cev)` Called when a change has just taken place.
`void` `preChange(ChangeEvent cev)` On preChange() we convert the SymolList to a non-veiw version, giving it its own copy of symbols
`SymbolList` `subList(int start, int end)` create a subList of the original, this will be a view until either the original symbolList or the sublist is edited
`Symbol` `symbolAt(int pos)` Find a symbol at a specified offset in the SymbolList.

Methods inherited from class org.biojava.bio.symbol.AbstractSymbolList
`equals, hashCode, iterator, seqString, subStr, toList, toString`

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, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Constructor Detail

### SimpleSymbolList

    public SimpleSymbolList(Alphabet alpha)

  Construct an empty SimpleSymbolList.

  Parameters:
    `alpha` - The alphabet of legal symbols in this list.

### SimpleSymbolList

    public SimpleSymbolList(Alphabet alpha,
                            List rList)
                     throws IllegalSymbolException

  Construct a SymbolList containing the symbols in the specified list.

  Parameters:
    `alpha` - The alphabet of legal symbols for this list.
    `rList` - A Java List of symbols.
  Throws:
    `IllegalSymbolException` - if a Symbol is not in the specified alphabet.
    `ClassCastException` - if rList contains objects which do not implement Symbol.

### SimpleSymbolList

    public SimpleSymbolList(SymbolTokenization parser,
                            String seqString)
                     throws IllegalSymbolException

  Construct a SymbolList from a string.

  Parameters:
    `parser` - A SymbolParser for whatever your string is -- e.g. alphabet.getParser("token").
    `seqString` - A Java List of symbols.
  Throws:
    `IllegalSymbolException` - if a Symbol is not in the specified alphabet.

### SimpleSymbolList

    public SimpleSymbolList(SymbolList sl)

  Construct a copy of an existing SymbolList.

  Parameters:
    `sl` - the list to copy.

### SimpleSymbolList

    public SimpleSymbolList(Symbol[] symbols,
                            int length,
                            Alphabet alphabet)

  Construct a SimpleSymbolList given the Symbol array that backs it. Used primarily with the chunked SymbolList builder but could be used elsewhere too.

Method Detail

### finalize

    protected void finalize()
                     throws Throwable

  Overrides:
    `finalize` in class `Object`
  Throws:
    `Throwable`

### getAlphabet

    public Alphabet getAlphabet()

  Get the alphabet of this SymbolList.

  Specified by:
    `getAlphabet` in interface `SymbolList`
  Returns:
    the alphabet

### length

    public int length()

  Get the length of this SymbolList.

  Specified by:
    `length` in interface `SymbolList`
  Returns:
    the length

### symbolAt

    public Symbol symbolAt(int pos)

  Find a symbol at a specified offset in the SymbolList.

  Specified by:
    `symbolAt` in interface `SymbolList`
  Parameters:
    `pos` - Position in biological coordinates (1..length)
  Returns:
    the Symbol at that index

### subList

    public SymbolList subList(int start,
                              int end)

  create a subList of the original, this will be a view until either the original symbolList or the sublist is edited

  Specified by:
    `subList` in interface `SymbolList`
  Overrides:
    `subList` in class `AbstractSymbolList`
  Parameters:
    `start` - the first symbol of the new SymbolList
    `end` - the last symbol (inclusive) of the new SymbolList

### edit

    public void edit(Edit edit)
              throws IndexOutOfBoundsException,
                     IllegalAlphabetException,
                     ChangeVetoException

  Apply and edit to the SymbolList as specified by Edit.

  edit() is now supported using the ChangeEvent system. SubLists do NOT reflect edits.

  Specified by:
    `edit` in interface `SymbolList`
  Overrides:
    `edit` in class `AbstractSymbolList`
  Parameters:
    `edit` - the Edit to perform
  Throws:
    `IndexOutOfBoundsException` - if the edit does not lie within the SymbolList
    `IllegalAlphabetException` - if the SymbolList to insert has an incompatible alphabet
    `ChangeVetoException` - if either the SymboList does not support the edit, or if the change was vetoed

### preChange

    public void preChange(ChangeEvent cev)
                   throws ChangeVetoException

  On preChange() we convert the SymolList to a non-veiw version, giving it its own copy of symbols

  Specified by:
    `preChange` in interface `ChangeListener`
  Parameters:
    `cev` - An event encapsulating the change which is about to take place.
  Throws:
    `ChangeVetoException` - Description of Exception

### postChange

    public void postChange(ChangeEvent cev)

  Description copied from interface: `ChangeListener`

  Called when a change has just taken place.

  This method is the place to perform any behavior in response to the change event.

  Specified by:
    `postChange` in interface `ChangeListener`
  Parameters:
    `cev` - An event encapsulating the change which has occured.

### addSymbol

    public void addSymbol(Symbol sym)
                   throws IllegalSymbolException,
                          ChangeVetoException

  Add a new Symbol to the end of this list.

  Parameters:
    `sym` - Symbol to add
  Throws:
    `IllegalSymbolException` - if the Symbol is not in this list's alphabet
    `ChangeVetoException`

### getSymbolArray

    public Symbol[] getSymbolArray()

  Return the Java Symbol[] array that backs this object. primarily used to accelerate reconstruction of symbol lists in the packed chunked symbol list implementation.