jbil.sequence
Class Sequence

java.lang.Object
  extended by jbil.sequence.Sequence
Direct Known Subclasses:
ByteArraySequence, SymbolArraySequence

public abstract class Sequence
extends java.lang.Object

Abstract class representing a sequence of symbols from a fixed alphabet. A sequence can be associated to a name.

Author:
Paulo G. S. da Fonseca

Constructor Summary
Sequence()
           
 
Method Summary
abstract  void append(Sequence sequence)
          Appends a sequence to this sequence.
abstract  void append(Symbol symbol)
          Appends a symbol to this sequence.
abstract  Sequence clone()
           
abstract  void delete(int beginIndex, int endIndex)
          Deletes a subsequence of this sequence.
 boolean endsWith(Sequence subSequence)
          Checks if this sequence ends with a given suffix.
abstract  Alphabet getAlphabet()
           
 java.lang.String getName()
           
 int indexAt(int index)
          Gets the position in the base alphabet of the symbol at a given position in the sequence.
abstract  void insert(int index, Sequence sequence)
          Inserts a sequence at a given position in this sequence.
abstract  void insert(int index, Symbol symbol)
          Inserts a new symbol at a given position in this sequence.
abstract  int length()
           
 boolean occursAt(Sequence subSequence, int beginIndex)
          Checks if a sequence occurs at a specified position of this sequence.
abstract  void prepend(Sequence sequence)
          Prepends a sequence to this sequence.
abstract  void prepend(Symbol symbol)
          Prepends a symbol to this sequence.
 void setName(java.lang.String name)
          Sets the name of the sequence.
abstract  void setSymbolAt(int index, Symbol symbol)
          Sets the symbol at a given position in this sequence.
 boolean startsWith(Sequence subSequence)
          Checks if this sequence begins with a given prefix.
abstract  Sequence subSequence(int beginIndex)
          Gets a new sequence that is a suffix of this sequence.
abstract  Sequence subSequence(int beginIndex, int endIndex)
          Gets a new sequence that is a subsequence of this sequence.
abstract  Symbol symbolAt(int index)
          Gets the symbol at a given position in the sequence.
 java.lang.String toString()
           
abstract  java.lang.String toString(int beginIndex, int endIndex)
          Returns the srting representation of a subsequence of this sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sequence

public Sequence()
Method Detail

getName

public java.lang.String getName()
Returns:
The name of the sequence.

setName

public void setName(java.lang.String name)
Sets the name of the sequence.


getAlphabet

public abstract Alphabet getAlphabet()
Returns:
The base alphabet.

clone

public abstract Sequence clone()
Overrides:
clone in class java.lang.Object
Returns:
A clone of this sequence.

length

public abstract int length()
Returns:
The length of this sequence.

symbolAt

public abstract Symbol symbolAt(int index)
Gets the symbol at a given position in the sequence.

Parameters:
index - A position in the sequence.
Returns:
The symbol at the given position.

indexAt

public int indexAt(int index)
Gets the position in the base alphabet of the symbol at a given position in the sequence.

Parameters:
index - A position in the sequence.
Returns:
The position in the base alphabet of the symbol at the given position.

setSymbolAt

public abstract void setSymbolAt(int index,
                                 Symbol symbol)
Sets the symbol at a given position in this sequence.

Parameters:
index - The position to be set.
symbol - The new symbol.

subSequence

public abstract Sequence subSequence(int beginIndex)
Gets a new sequence that is a suffix of this sequence.

Parameters:
beginIndex - The start position of the suffix.
Returns:
The suffix starting at the given position.

subSequence

public abstract Sequence subSequence(int beginIndex,
                                     int endIndex)
Gets a new sequence that is a subsequence of this sequence.

Parameters:
beginIndex - The start position of the subsequence.
endIndex - The end position of the subsequence.
Returns:
The subsequence starting at beginIndex and ending at endIndex-1.

append

public abstract void append(Symbol symbol)
Appends a symbol to this sequence.

Parameters:
symbol - The symbol to be appended.

append

public abstract void append(Sequence sequence)
Appends a sequence to this sequence.

Parameters:
sequence - The sequence to be appended.

prepend

public abstract void prepend(Symbol symbol)
Prepends a symbol to this sequence.

Parameters:
symbol - The symbol to be prepended.

prepend

public abstract void prepend(Sequence sequence)
Prepends a sequence to this sequence.

Parameters:
sequence - The sequence to be prepended.

insert

public abstract void insert(int index,
                            Symbol symbol)
Inserts a new symbol at a given position in this sequence.

Parameters:
index - The position at which the symbol is inserted.
symbol - The symbol to be inserted.

insert

public abstract void insert(int index,
                            Sequence sequence)
Inserts a sequence at a given position in this sequence.

Parameters:
index - The position at which the sequence is inserted.
sequence - The sequence to be inserted.

delete

public abstract void delete(int beginIndex,
                            int endIndex)
Deletes a subsequence of this sequence.

Parameters:
beginIndex - The start position of the subsequence to be deleted.
endIndex - The end position (not inclusive) of the subsequence to be deleted.

occursAt

public boolean occursAt(Sequence subSequence,
                        int beginIndex)
Checks if a sequence occurs at a specified position of this sequence.

Parameters:
subSequence - The subsequence.
beginIndex - The start position of the match.
Returns:
True if the subsequence occurs at the specified position, or false, otherwise.

startsWith

public boolean startsWith(Sequence subSequence)
Checks if this sequence begins with a given prefix.

Parameters:
subSequence - The prefix.
Returns:
True if this sequence begins with the given prefix, or false, otherwise.

endsWith

public boolean endsWith(Sequence subSequence)
Checks if this sequence ends with a given suffix.

Parameters:
subSequence - The suffix.
Returns:
True if this sequence ends with the given suffix, or false, otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public abstract java.lang.String toString(int beginIndex,
                                          int endIndex)
Returns the srting representation of a subsequence of this sequence.

Parameters:
beginIndex - The start position of the subsequence.
endIndex - The end position of the subsequence.
Returns:
The string representation of the subsequence starting at beginIndex and ending at endIndex-1.