Package org.biojavax.bio
Class SimpleBioEntry
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojavax.bio.SimpleBioEntry
-
- All Implemented Interfaces:
Comparable
,Annotatable
,Changeable
,BioEntry
,RankedCrossRefable
,RichAnnotatable
- Direct Known Subclasses:
ThinRichSequence
public class SimpleBioEntry extends AbstractChangeable implements BioEntry
Reference implementation of a BioEntry object which has no features or sequence. Equality is the combination of namespace, name, accession and version.- Since:
- 1.5
- Author:
- Richard Holland, Mark Schreiber, George Waldon
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
-
-
Field Summary
-
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
-
Fields inherited from interface org.biojavax.bio.BioEntry
COMMENT, DESCRIPTION, DIVISION, IDENTIFIER, RANKEDCROSSREF, RANKEDDOCREF, RELATIONS, SEQVERSION, TAXON
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleBioEntry()
SimpleBioEntry(Namespace ns, String name, String accession, int version)
Creates a new bioentry representing the sequence in the given namespace with the given name, accession and version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComment(Comment comment)
Adds a comment instance to this bioentry.void
addRankedCrossRef(RankedCrossRef crossref)
Adds a ranked cross reference to the existing set.void
addRankedDocRef(RankedDocRef docref)
Adds a ranked docref instance to this bioentry.void
addRelationship(BioEntryRelationship relation)
Adds a relation instance to this bioentry.int
compareTo(Object o)
Bioentries are ordered first by namespace, then name, accession, and finally version.boolean
equals(Object obj)
Two bioentries are equal if they share the same namespace, name, accession and version.String
getAccession()
Returns the accession of this bioentry.Annotation
getAnnotation()
Should return the associated annotation object.Set<Comment>
getComments()
Returns a set of all comments associated with this bioentry.String
getDescription()
Returns a description of this sequence.String
getDivision()
Returns the division of this bioentry.Integer
getId()
Gets the Hibernate ID.String
getIdentifier()
Returns the identifier of this bioentry.String
getName()
Returns the name of this bioentry.Namespace
getNamespace()
Returns the namespace of this bioentry.Set<Note>
getNoteSet()
Returns the set of notes associated with this object.Set<RankedCrossRef>
getRankedCrossRefs()
Returns the set of all ranked cross references associated with an object.Set<RankedDocRef>
getRankedDocRefs()
Returns a set of all bioentrydocrefs associated with this bioentry.Set<BioEntryRelationship>
getRelationships()
Returns a set of all relationships associated with this bioentry.RichAnnotation
getRichAnnotation()
Return the associated annotation object.NCBITaxon
getTaxon()
Gets the taxon associated with this bioentry.int
getVersion()
Gets the version of this bioentry.int
hashCode()
void
removeComment(Comment comment)
Removes a comment instance from this bioentry.void
removeRankedCrossRef(RankedCrossRef crossref)
Removes a ranked cross reference from the existing set.void
removeRankedDocRef(RankedDocRef docref)
Removes a ranked docref instance from this bioentry.void
removeRelationship(BioEntryRelationship relation)
Removes a relation instance from this bioentry.void
setDescription(String description)
Sets the description for this bioentry.void
setDivision(String division)
Sets the division of this bioentry.void
setId(Integer id)
Sets the Hibernate ID.void
setIdentifier(String identifier)
Sets the identifier of this bioentry.void
setNoteSet(Set<Note> notes)
Clears the notes associated with this object and replaces them with the contents of this set.void
setRankedCrossRefs(Set<RankedCrossRef> rankedcrossrefs)
Sets the ranked cross references associated with an object.void
setTaxon(NCBITaxon taxon)
Sets the taxon for this bioentry.String
toString()
Form: namespace:name/accession.version-
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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
SimpleBioEntry
public SimpleBioEntry(Namespace ns, String name, String accession, int version)
Creates a new bioentry representing the sequence in the given namespace with the given name, accession and version. These properties are all immutable and non-nullable.- Parameters:
ns
- The namespace for this new bioentry (not null).name
- The name for this new bioentry (not null).accession
- The accession for this new bioentry (not null).version
- The version for this new bioentry.
-
SimpleBioEntry
protected SimpleBioEntry()
-
-
Method Detail
-
getRankedCrossRefs
public Set<RankedCrossRef> getRankedCrossRefs()
Returns the set of all ranked cross references associated with an object. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getRankedCrossRefs
in interfaceRankedCrossRefable
- Returns:
- a set of RankedCrossRef objects.
-
setTaxon
public void setTaxon(NCBITaxon taxon) throws ChangeVetoException
Sets the taxon for this bioentry. It may be null, in which case the taxon is unset.- Specified by:
setTaxon
in interfaceBioEntry
- Parameters:
taxon
- New value of property taxon.- Throws:
ChangeVetoException
- in case of objections.
-
getAnnotation
public Annotation getAnnotation()
Should return the associated annotation object.- Specified by:
getAnnotation
in interfaceAnnotatable
- Returns:
- an Annotation object, never null
-
getRichAnnotation
public RichAnnotation getRichAnnotation()
Return the associated annotation object.- Specified by:
getRichAnnotation
in interfaceRichAnnotatable
- Returns:
- a RichAnnotation object, never null
-
getNoteSet
public Set<Note> getNoteSet()
Returns the set of notes associated with this object. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getNoteSet
in interfaceRichAnnotatable
- Returns:
- set a set of Note objects.
- See Also:
Note
-
setNoteSet
public void setNoteSet(Set<Note> notes) throws ChangeVetoException
Clears the notes associated with this object and replaces them with the contents of this set. Would normally delegate call to internal RichAnnotation instance. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
setNoteSet
in interfaceRichAnnotatable
- Parameters:
notes
- the set of Note objects to replace the existing ones with.- Throws:
ChangeVetoException
- if the set is null or contains any objects that are not Note objects.- See Also:
Note
-
getComments
public Set<Comment> getComments()
Returns a set of all comments associated with this bioentry. This set is not mutable. If no comments are associated, you will get back an empty set. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getComments
in interfaceBioEntry
- Returns:
- a set of Comment objects.
- See Also:
Comment
-
getRankedDocRefs
public Set<RankedDocRef> getRankedDocRefs()
Returns a set of all bioentrydocrefs associated with this bioentry. This set is not mutable. If no docrefs are associated, you will get back an empty set. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getRankedDocRefs
in interfaceBioEntry
- Returns:
- a set of RankedDocRef objects.
- See Also:
RankedDocRef
-
getRelationships
public Set<BioEntryRelationship> getRelationships()
Returns a set of all relationships associated with this bioentry. This set is not mutable. If no relationships are associated, you will get back an empty set. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getRelationships
in interfaceBioEntry
- Returns:
- a set of BioEntryRelationship objects.
- See Also:
BioEntryRelationship
-
setIdentifier
public void setIdentifier(String identifier) throws ChangeVetoException
Sets the identifier of this bioentry. Null is allowable.- Specified by:
setIdentifier
in interfaceBioEntry
- Parameters:
identifier
- New value of property identifier.- Throws:
ChangeVetoException
- in case of objections.
-
setDivision
public void setDivision(String division) throws ChangeVetoException
Sets the division of this bioentry. Null is allowable.- Specified by:
setDivision
in interfaceBioEntry
- Parameters:
division
- New value of property division.- Throws:
ChangeVetoException
- in case of objections.
-
setDescription
public void setDescription(String description) throws ChangeVetoException
Sets the description for this bioentry.- Specified by:
setDescription
in interfaceBioEntry
- Parameters:
description
- New value of property description.- Throws:
ChangeVetoException
- in case of objections.
-
getAccession
public String getAccession()
Returns the accession of this bioentry. The accession is supposed to be an immutable property set by the constructor.- Specified by:
getAccession
in interfaceBioEntry
- Returns:
- Value of property accession.
-
getDescription
public String getDescription()
Returns a description of this sequence.- Specified by:
getDescription
in interfaceBioEntry
- Returns:
- Value of property description.
-
getDivision
public String getDivision()
Returns the division of this bioentry. Division relates to a division of the parent namespace.- Specified by:
getDivision
in interfaceBioEntry
- Returns:
- Value of property division.
-
getIdentifier
public String getIdentifier()
Returns the identifier of this bioentry.- Specified by:
getIdentifier
in interfaceBioEntry
- Returns:
- Value of property identifier.
-
getName
public String getName()
Returns the name of this bioentry. The name is supposed to be an immutable property set by the constructor.
-
getNamespace
public Namespace getNamespace()
Returns the namespace of this bioentry. The namespace is supposed to be an immutable property set by the constructor.- Specified by:
getNamespace
in interfaceBioEntry
- Returns:
- the namespace of this bioentry.
-
getVersion
public int getVersion()
Gets the version of this bioentry. Bioentries with no versions return 0. The version is supposed to be immutable and set only by the constructor.- Specified by:
getVersion
in interfaceBioEntry
- Returns:
- Value of property version.
-
equals
public boolean equals(Object obj)
Two bioentries are equal if they share the same namespace, name, accession and version.
-
compareTo
public int compareTo(Object o)
Bioentries are ordered first by namespace, then name, accession, and finally version.- Specified by:
compareTo
in interfaceComparable
-
addRankedCrossRef
public void addRankedCrossRef(RankedCrossRef crossref) throws ChangeVetoException
Adds a ranked cross reference to the existing set. If already present, this call is ignored. Null values are not acceptable.- Specified by:
addRankedCrossRef
in interfaceRankedCrossRefable
- Parameters:
crossref
- the ranked cross reference to add.- Throws:
ChangeVetoException
- if the parameter is null.
-
removeRankedCrossRef
public void removeRankedCrossRef(RankedCrossRef crossref) throws ChangeVetoException
Removes a ranked cross reference from the existing set. If not present, this call is ignored. Null values are not acceptable.- Specified by:
removeRankedCrossRef
in interfaceRankedCrossRefable
- Parameters:
crossref
- the ranked cross reference to remove.- Throws:
ChangeVetoException
- if the parameter is null.
-
addRankedDocRef
public void addRankedDocRef(RankedDocRef docref) throws ChangeVetoException
Adds a ranked docref instance to this bioentry. Must not be null.- Specified by:
addRankedDocRef
in interfaceBioEntry
- Parameters:
docref
- the item to add.- Throws:
ChangeVetoException
- if it doesn't want to add it.
-
removeRankedDocRef
public void removeRankedDocRef(RankedDocRef docref) throws ChangeVetoException
Removes a ranked docref instance from this bioentry. If it was not found, nothing happens.- Specified by:
removeRankedDocRef
in interfaceBioEntry
- Parameters:
docref
- the item to remove.- Throws:
ChangeVetoException
- if it doesn't want to remove it.
-
addComment
public void addComment(Comment comment) throws ChangeVetoException
Adds a comment instance to this bioentry. Must not be null.- Specified by:
addComment
in interfaceBioEntry
- Parameters:
comment
- the item to add.- Throws:
ChangeVetoException
- if it doesn't want to add it.
-
removeComment
public void removeComment(Comment comment) throws ChangeVetoException
Removes a comment instance from this bioentry. If it wasn't present, it nothing will happen.- Specified by:
removeComment
in interfaceBioEntry
- Parameters:
comment
- the item to remove.- Throws:
ChangeVetoException
- if it doesn't want to remove it.
-
addRelationship
public void addRelationship(BioEntryRelationship relation) throws ChangeVetoException
Adds a relation instance to this bioentry. It must not be null.- Specified by:
addRelationship
in interfaceBioEntry
- Parameters:
relation
- the item to add.- Throws:
ChangeVetoException
- if it doesn't want to add it.
-
removeRelationship
public void removeRelationship(BioEntryRelationship relation) throws ChangeVetoException
Removes a relation instance from this bioentry. If it wasn't present, nothing will happen.- Specified by:
removeRelationship
in interfaceBioEntry
- Parameters:
relation
- the item to remove.- Throws:
ChangeVetoException
- if it doesn't want to remove it.
-
setRankedCrossRefs
public void setRankedCrossRefs(Set<RankedCrossRef> rankedcrossrefs)
Description copied from interface:RankedCrossRefable
Sets the ranked cross references associated with an object. Null will throw an exception but the empty set is fine.- Specified by:
setRankedCrossRefs
in interfaceRankedCrossRefable
- Parameters:
rankedcrossrefs
- a set of RankedCrossRef objects.
-
getId
public Integer getId()
Gets the Hibernate ID. Should be used with caution.- Returns:
- the Hibernate ID, if using Hibernate.
-
-