de.jstacs.data.alphabets
Class GenericComplementableDiscreteAlphabet

java.lang.Object
  extended by de.jstacs.data.alphabets.Alphabet
      extended by de.jstacs.data.alphabets.DiscreteAlphabet
          extended by de.jstacs.data.alphabets.ComplementableDiscreteAlphabet
              extended by de.jstacs.data.alphabets.GenericComplementableDiscreteAlphabet
All Implemented Interfaces:
InstantiableFromParameterSet, Storable, Comparable<Alphabet>

public class GenericComplementableDiscreteAlphabet
extends ComplementableDiscreteAlphabet

This class implements an generic complementable discrete alphabet. The complement is determined in the constructor, where the user has to specify for each symbol the index of the complement symbol.

Author:
Jens Keilwagen

Nested Class Summary
static class GenericComplementableDiscreteAlphabet.GenericComplementableDiscreteAlphabetParameterSet
          This class is used as container for the parameters of a GenericComplementableDiscreteAlphabet.
 
Nested classes/interfaces inherited from class de.jstacs.data.alphabets.DiscreteAlphabet
DiscreteAlphabet.DiscreteAlphabetParameterSet
 
Nested classes/interfaces inherited from class de.jstacs.data.alphabets.Alphabet
Alphabet.AlphabetParameterSet<T extends Alphabet>
 
Field Summary
 
Fields inherited from class de.jstacs.data.alphabets.DiscreteAlphabet
alphabet, caseInsensitive, parameters
 
Constructor Summary
GenericComplementableDiscreteAlphabet(boolean caseInsensitive, String[] alphabet, int[] revComp)
          The main constructor.
GenericComplementableDiscreteAlphabet(GenericComplementableDiscreteAlphabet.GenericComplementableDiscreteAlphabetParameterSet parameters)
          This constructor creates a GenericComplementableDiscreteAlphabet from a parameter set.
GenericComplementableDiscreteAlphabet(StringBuffer representation)
          The standard constructor for the interface Storable.
 
Method Summary
 int getComplementaryCode(int code)
          This method returns the code of the symbol that is the complement of the symbol encoded by code.
 Alphabet.AlphabetParameterSet getCurrentParameterSet()
          Returns the InstanceParameterSet that has been used to instantiate the current instance of the implementing class.
 
Methods inherited from class de.jstacs.data.alphabets.DiscreteAlphabet
compareTo, getCode, getMaximalSymbolLength, getMin, getSymbolAt, ignoresCase, isEncodedSymbol, isSymbol, length, toString, toXML
 
Methods inherited from class de.jstacs.data.alphabets.Alphabet
checkConsistency
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericComplementableDiscreteAlphabet

public GenericComplementableDiscreteAlphabet(StringBuffer representation)
                                      throws NonParsableException
The standard constructor for the interface Storable. Creates a new GenericComplementableDiscreteAlphabet out of its XML representation.

Parameters:
representation - the XML representation as StringBuffer
Throws:
NonParsableException - if the GenericComplementableDiscreteAlphabet could not be reconstructed out of the XML representation (the StringBuffer representation could not be parsed)
See Also:
Storable

GenericComplementableDiscreteAlphabet

public GenericComplementableDiscreteAlphabet(GenericComplementableDiscreteAlphabet.GenericComplementableDiscreteAlphabetParameterSet parameters)
                                      throws IllegalArgumentException,
                                             DoubleSymbolException
This constructor creates a GenericComplementableDiscreteAlphabet from a parameter set.

Parameters:
parameters - the set of parameters needed to create a GenericComplementableDiscreteAlphabet
Throws:
IllegalArgumentException - if space or tab will be used as symbols
DoubleSymbolException - if one of the symbols occurred more than once

GenericComplementableDiscreteAlphabet

public GenericComplementableDiscreteAlphabet(boolean caseInsensitive,
                                             String[] alphabet,
                                             int[] revComp)
                                      throws DoubleSymbolException,
                                             IllegalArgumentException
The main constructor.

Parameters:
alphabet - the array of symbols
caseInsensitive - indicates if there will be no difference between lowercase and uppercase letters/symbols in the alphabet (no case sensitivity)
revComp - the array is used to provide the complementarity, revComp[i] contains the index of the complement of the i-th symbol
Throws:
IllegalArgumentException - if space or tab will be used as symbols
DoubleSymbolException - if one of the symbols occurred more than once
Method Detail

getComplementaryCode

public int getComplementaryCode(int code)
Description copied from class: ComplementableDiscreteAlphabet
This method returns the code of the symbol that is the complement of the symbol encoded by code.

Specified by:
getComplementaryCode in class ComplementableDiscreteAlphabet
Parameters:
code - the encoded symbol
Returns:
the code of the complement

getCurrentParameterSet

public Alphabet.AlphabetParameterSet getCurrentParameterSet()
                                                     throws Exception
Description copied from interface: InstantiableFromParameterSet
Returns the InstanceParameterSet that has been used to instantiate the current instance of the implementing class. If the current instance was not created using an InstanceParameterSet, an equivalent InstanceParameterSet should be returned, so that an instance created using this InstanceParameterSet would be in principle equal to the current instance.

Specified by:
getCurrentParameterSet in interface InstantiableFromParameterSet
Overrides:
getCurrentParameterSet in class DiscreteAlphabet
Returns:
the current InstanceParameterSet
Throws:
Exception - if the InstanceParameterSet could not be returned