T
- the token type of the underlying and the viewed modelpublic abstract class DelegatedAlignmentModelView<T> extends AbstractBasicAlignmentModelView<T> implements AlignmentModelView<T,T>
AlignmentModelView
that delegates all methods to the underlying model
and uses the same token type as the underlying model. Inherited classes can overwrite single
delegated methods to change the behavior.
Note that getChangeListeners()
also delegates to the underlying model and therefore
modifying this list, actually modifies the listener list of the underlying model.
This class is marked as abstract, since it does not behave different then the underlying model, if no method is overwritten or added in inherited classes.
Constructor and Description |
---|
DelegatedAlignmentModelView(AlignmentModel<T> underlyingModel) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addSequence(java.lang.String sequenceName)
Adds a new empty sequence to the underlying data source and generates an ID for it.
|
java.lang.String |
addSequence(java.lang.String sequenceName,
java.lang.String sequenceID)
Adds a new empty sequence to the underlying data source assigning the specified ID to it.
|
void |
appendToken(java.lang.String sequenceID,
T token)
Appends a token at the end of the sequence.
|
void |
appendTokens(java.lang.String sequenceID,
java.util.Collection<? extends T> tokens)
Appends a sequence of tokens starting at the end of the current sequence.
|
boolean |
containsSequence(java.lang.String sequenceID)
Checks if a sequence associated with the specified unique identifier is contained in this model.
|
java.util.Set<AlignmentModelChangeListener> |
getChangeListeners()
Returns all change listeners currently attached to this object.
|
java.lang.String |
getID()
Some implementations may specify string identifying an alignment, which is then returned
by this method.
|
java.lang.String |
getLabel()
Returns a string labeling this alignment.
|
int |
getMaxSequenceLength()
Returns the length of the longest sequence in the alignment which is equivalent to the length of
the alignment.
|
int |
getSequenceCount()
Returns the number of sequences in the underlying data source.
|
int |
getSequenceLength(java.lang.String sequenceID)
Returns the length of the specified sequence.
|
T |
getTokenAt(java.lang.String sequenceID,
int index)
Returns the token at the specified position.
|
TokenSet<T> |
getTokenSet()
Returns the token set which is supported by the implementation.
|
AlignmentModelWriteType |
getWriteType()
Returns a value that specifies if whole sequences or single tokens can be edited in the underlying
data source.
|
void |
insertTokenAt(java.lang.String sequenceID,
int index,
T token)
Inserts a token at the specified position.
|
void |
insertTokensAt(java.lang.String sequenceID,
int beginIndex,
java.util.Collection<? extends T> tokens)
Inserts a sequence of tokens starting at the specified position.
|
boolean |
isSequencesReadOnly()
Checks of whole sequences can be changed in the underlying data source
|
boolean |
isTokensReadOnly()
Checks of tokens can be changed in the underlying data source
|
boolean |
removeSequence(java.lang.String sequenceID)
Removes the specified sequence from the underlying data source.
|
void |
removeTokenAt(java.lang.String sequenceID,
int index)
Removes the token at the specified position from the underlying data source.
|
void |
removeTokensAt(java.lang.String sequenceID,
int beginIndex,
int endIndex)
Removes the token inside the specified interval from the underlying data source.
|
java.lang.String |
renameSequence(java.lang.String sequenceID,
java.lang.String newSequenceName)
Renames a sequence in the underlying data source.
|
java.util.Iterator<java.lang.String> |
sequenceIDIterator()
Returns an iterator over unique IDs of all sequences contained in the underlying data source
in the order they are stored in this model.
|
java.util.Set<java.lang.String> |
sequenceIDsByName(java.lang.String sequenceName)
Returns the set of unique sequence IDs associated with the specified name.
|
java.lang.String |
sequenceNameByID(java.lang.String sequenceID)
Returns the sequence name (that would be visible to the application user) associated with the
specified unique ID.
|
void |
setID(java.lang.String id)
Allows to specify a new ID for this alignment.
|
void |
setLabel(java.lang.String label)
Allows to specify a new label for this alignment.
|
void |
setTokenAt(java.lang.String sequenceID,
int index,
T token)
Replaces the token at the specified position by the passed token.
|
void |
setTokensAt(java.lang.String sequenceID,
int beginIndex,
java.util.Collection<? extends T> tokens)
Replaces a sequence of tokens starting at the specified position.
|
void |
setTokenSet(TokenSet<T> set)
Replaces the current token set with the specified one.
|
getUnderlyingModel, setUnderlyingModel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getUnderlyingModel
public DelegatedAlignmentModelView(AlignmentModel<T> underlyingModel)
public java.lang.String getID()
AlignmentModel
getID
in interface AlignmentModel<T>
null
if none is assignedpublic void setID(java.lang.String id)
AlignmentModel
setID
in interface AlignmentModel<T>
id
- the new IDpublic java.lang.String getLabel()
AlignmentModel
getLabel
in interface AlignmentModel<T>
public void setLabel(java.lang.String label) throws java.lang.UnsupportedOperationException
AlignmentModel
setLabel
in interface AlignmentModel<T>
label
- the new labeljava.lang.UnsupportedOperationException
- if this implementation does not allow to change labelspublic TokenSet<T> getTokenSet()
AlignmentModel
getTokenSet
in interface AlignmentModel<T>
public void setTokenSet(TokenSet<T> set) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
AlignmentModel
setTokenSet
in interface AlignmentModel<T>
set
- the new token set to be usedjava.lang.UnsupportedOperationException
- if this implementation does not support changing token sets during runtimejava.lang.IllegalArgumentException
- if the specified token set is not a valid replacement for the previous one (in some
does way does not fulfill the needs of the implementation)public int getSequenceLength(java.lang.String sequenceID)
AlignmentModel
getSequenceLength
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignment-1
if no sequence with the specified name existspublic int getMaxSequenceLength()
AlignmentModel
Note that this value represents the number of compounds of the specified data type. If e.g. a DNA data source is viewed as amino acid data this method would still return the number of nucleotides in the longest sequence.
getMaxSequenceLength
in interface AlignmentModel<T>
0
if there are not sequences contained
in the underlying data sourcepublic AlignmentModelWriteType getWriteType()
AlignmentModel
getWriteType
in interface AlignmentModel<T>
public boolean isTokensReadOnly()
AlignmentModel
isTokensReadOnly
in interface AlignmentModel<T>
true
if token can be written or removed, false
otherwisepublic boolean isSequencesReadOnly()
AlignmentModel
isSequencesReadOnly
in interface AlignmentModel<T>
true
if sequences can be written, renamed or removed, false
otherwisepublic boolean containsSequence(java.lang.String sequenceID)
AlignmentModel
containsSequence
in interface AlignmentModel<T>
sequenceID
- the ID of the sequence to checked ontrue
if an according sequence was found, false
otherwisepublic java.util.Set<java.lang.String> sequenceIDsByName(java.lang.String sequenceName)
AlignmentModel
sequenceIDsByName
in interface AlignmentModel<T>
sequenceName
- the name of the sequence that would be visible to the application userpublic java.lang.String sequenceNameByID(java.lang.String sequenceID)
AlignmentModel
sequenceNameByID
in interface AlignmentModel<T>
sequenceID
- the unique unmodifiable ID the sequence is identified bynull
if no sequence with this ID is contained in this modelpublic java.lang.String addSequence(java.lang.String sequenceName) throws AlignmentSourceNotWritableException
AlignmentModel
addSequence
in interface AlignmentModel<T>
sequenceName
- the name of the new sequenceAlignmentSourceNotWritableException
- if the underlying data source is not writable for sequencespublic java.lang.String addSequence(java.lang.String sequenceName, java.lang.String sequenceID) throws AlignmentSourceNotWritableException, java.lang.IllegalArgumentException
AlignmentModel
addSequence
in interface AlignmentModel<T>
sequenceName
- the name of the new sequencesequenceID
- the ID the new sequence shall havesequenceID
)AlignmentSourceNotWritableException
- if the underlying data source is not writable for sequencesjava.lang.IllegalArgumentException
- if a sequence with the specified ID is already present in this modelpublic boolean removeSequence(java.lang.String sequenceID) throws AlignmentSourceNotWritableException
AlignmentModel
removeSequence
in interface AlignmentModel<T>
sequenceID
- the unique ID of the sequence to be removedtrue
if an sequence with the specified ID was removed, false
if no sequence with the specified ID was contained in this modelAlignmentSourceNotWritableException
- if the underlying data source is not writable for sequencespublic java.lang.String renameSequence(java.lang.String sequenceID, java.lang.String newSequenceName) throws AlignmentSourceNotWritableException, SequenceNotFoundException
AlignmentModel
renameSequence
in interface AlignmentModel<T>
sequenceID
- the ID of the sequence to be renamednewSequenceName
- the new name the sequence shall haveAlignmentSourceNotWritableException
- if the underlying data source is not writable for sequencesSequenceNotFoundException
- if a sequence with the specified ID is not present the underlying
data sourcepublic java.util.Iterator<java.lang.String> sequenceIDIterator()
AlignmentModel
sequenceIDIterator
in interface AlignmentModel<T>
public int getSequenceCount()
AlignmentModel
getSequenceCount
in interface AlignmentModel<T>
public java.util.Set<AlignmentModelChangeListener> getChangeListeners()
AlignmentModel
This method returns the same object in every call. Therefore changes made to different references always affect all references.
getChangeListeners
in interface AlignmentModel<T>
public T getTokenAt(java.lang.String sequenceID, int index)
AlignmentModel
getTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedindex
- the index of the element contained in the specified sequence (The first element has the index 0.)public void setTokenAt(java.lang.String sequenceID, int index, T token) throws AlignmentSourceNotWritableException
AlignmentModel
setTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedindex
- the index of the element to be replaced (The first element has the index 0.)token
- the new token for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void setTokensAt(java.lang.String sequenceID, int beginIndex, java.util.Collection<? extends T> tokens) throws AlignmentSourceNotWritableException
AlignmentModel
setTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedbeginIndex
- the index of the first element to be replaced
(The first element in the sequence has the index 0.)tokens
- the new tokens for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokensAlignmentModelUtils.charSequenceToTokenList(CharSequence, TokenSet)
public void appendToken(java.lang.String sequenceID, T token) throws AlignmentSourceNotWritableException
AlignmentModel
appendToken
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmenttoken
- the token to be insertedAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void appendTokens(java.lang.String sequenceID, java.util.Collection<? extends T> tokens) throws AlignmentSourceNotWritableException
AlignmentModel
appendTokens
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedtokens
- the new tokens for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokensAlignmentModelUtils.charSequenceToTokenList(CharSequence, TokenSet)
public void insertTokenAt(java.lang.String sequenceID, int index, T token) throws AlignmentSourceNotWritableException
AlignmentModel
insertTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentindex
- the new index the inserted element will have
(0 <= elementIndex < sequenceLength
)token
- the token to be insertedAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void insertTokensAt(java.lang.String sequenceID, int beginIndex, java.util.Collection<? extends T> tokens) throws AlignmentSourceNotWritableException
AlignmentModel
tokens
.insertTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence where the token is containedbeginIndex
- the index of the first element to be replaced
(The first element in the sequence has the index 0.)tokens
- the new tokens for the specified positionAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokensAlignmentModelUtils.charSequenceToTokenList(CharSequence, TokenSet)
public void removeTokenAt(java.lang.String sequenceID, int index) throws AlignmentSourceNotWritableException
AlignmentModel
removeTokenAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentindex
- the index of the element to be removed (The first element has the index 0.)AlignmentSourceNotWritableException
- if the underlying data source is not writable for tokenspublic void removeTokensAt(java.lang.String sequenceID, int beginIndex, int endIndex) throws AlignmentSourceNotWritableException
AlignmentModel
beginIndex
and extends to the
token at index endIndex - 1). Thus the length of the subsequence is {@code endIndex - beginIndex}.removeTokensAt
in interface AlignmentModel<T>
sequenceID
- the identifier the sequence in the alignmentbeginIndex
- the beginning index, inclusiveendIndex
- the ending index, exclusiveAlignmentSourceNotWritableException
- if the underlying data source is not writable for tokens