uk.ac.man.bioinf.sequence
Class AbstractEditableSequence

java.lang.Object
  |
  +--uk.ac.man.bioinf.sequence.AbstractSequence
        |
        +--uk.ac.man.bioinf.sequence.AbstractMutableSequence
              |
              +--uk.ac.man.bioinf.sequence.AbstractEditableSequence
All Implemented Interfaces:
EditableSequence, Identifiable, MutableSequence, Sequence, SequenceEventProvider
Direct Known Subclasses:
DefaultEditableSequence

public abstract class AbstractEditableSequence
extends AbstractMutableSequence
implements EditableSequence

AbstractEditableSequence.java This class provides trivial implementations of all of those methods which can be defined in terms of the others of the EditableSequence interface, and also ensures that the event handling occurs correctly Created: Fri Mar 3 12:11:49 2000

Version:
$Id: AbstractEditableSequence.java,v 1.2 2001/04/11 17:04:43 lord Exp $
Author:
Phillip Lord

Constructor Summary
AbstractEditableSequence(SequenceType type)
           
 
Method Summary
 Element deleteElementAt(int index)
          Delete the element at index.
 Element[] deleteElementAt(int index, int length)
          Delete the elements starting at index for the specified length
protected abstract  Element deleteElementAtQuietly(int index)
          Do the actual deletion but dont do any event signalling.
 void insertElementAt(Element[] elem, int index)
          Provides a trivial implementation of this method by calling multiple single insert methods.
 void insertElementAt(Element elem, int index)
          Insert the element at the specified index.
protected abstract  void insertElementAtQuietly(Element elem, int index)
           
 Element[] setElementAt(Element[] elem, int index)
          Provides a simple implementation of this method by iterating through the element array, and calling the super class method.
 Element setElementAt(Element elem, int index)
          Sets the value of the element at the specified index.
protected abstract  Element setElementAtQuietly(Element elem, int index)
           
 
Methods inherited from class uk.ac.man.bioinf.sequence.AbstractMutableSequence
addSequenceListener, addVetoableSequenceListener, fireSequenceEvent, fireVetoableSequenceEvent, hasListeners, removeSequenceListener, removeVetoableSequenceListener
 
Methods inherited from class uk.ac.man.bioinf.sequence.AbstractSequence
checkRange, checkSequenceType, checkSequenceType, getElementAtAsChar, getSequenceAsChars, getSequenceIndexException, getSequenceType, getSequenceTypeException, getSubSequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.man.bioinf.sequence.Sequence
getElementAt, getElementAtAsChar, getLength, getSequenceAsChars, getSequenceAsElements, getSequenceType, getSubSequence
 
Methods inherited from interface uk.ac.man.bioinf.sequence.identifier.Identifiable
getIdentifier
 
Methods inherited from interface uk.ac.man.bioinf.sequence.event.SequenceEventProvider
addSequenceListener, addVetoableSequenceListener, removeSequenceListener, removeVetoableSequenceListener
 

Constructor Detail

AbstractEditableSequence

public AbstractEditableSequence(SequenceType type)
Method Detail

setElementAtQuietly

protected abstract Element setElementAtQuietly(Element elem,
                                               int index)

setElementAt

public Element setElementAt(Element elem,
                            int index)
                     throws SequenceVetoException
Description copied from interface: EditableSequence
Sets the value of the element at the specified index.

Specified by:
setElementAt in interface EditableSequence
Parameters:
elem -
index -
Returns:
the old value
Throws:
SequenceVetoException - if some listener doesnt like this

setElementAt

public Element[] setElementAt(Element[] elem,
                              int index)
                       throws SequenceVetoException
Provides a simple implementation of this method by iterating through the element array, and calling the super class method. Subclasses may override this to provide a more efficient implementation

Specified by:
setElementAt in interface EditableSequence
Parameters:
elem - the elements to set
index - the index at which to start
SequenceVetoException

insertElementAtQuietly

protected abstract void insertElementAtQuietly(Element elem,
                                               int index)

insertElementAt

public void insertElementAt(Element elem,
                            int index)
                     throws SequenceVetoException
Description copied from interface: EditableSequence
Insert the element at the specified index. After insertion getElementAt( index ) will return element, and the sequence will be longer by one

Specified by:
insertElementAt in interface EditableSequence
Parameters:
elem - the element to insert
index - the index at which to insert
SequenceVetoException

insertElementAt

public void insertElementAt(Element[] elem,
                            int index)
                     throws SequenceVetoException
Provides a trivial implementation of this method by calling multiple single insert methods. Subclasses will almost definately find it more efficient to over ride this method!

Specified by:
insertElementAt in interface EditableSequence
Parameters:
elem -
index -
Throws:
SequenceVetoException

deleteElementAtQuietly

protected abstract Element deleteElementAtQuietly(int index)
Do the actual deletion but dont do any event signalling. This enables all the deletions to use this method without causing multiple events for deletions longer than one in length

Parameters:
index - the element to delete
Returns:
the element just deleted

deleteElementAt

public Element deleteElementAt(int index)
                        throws SequenceVetoException
Description copied from interface: EditableSequence
Delete the element at index.

Specified by:
deleteElementAt in interface EditableSequence
Parameters:
index - the index to delete
Returns:
the element which has just been deleted
SequenceVetoException

deleteElementAt

public Element[] deleteElementAt(int index,
                                 int length)
                          throws SequenceVetoException
Description copied from interface: EditableSequence
Delete the elements starting at index for the specified length

Specified by:
deleteElementAt in interface EditableSequence
Parameters:
index - the index to start at
length - the length to delete
Returns:
the elements just deleted
SequenceVetoException