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 protectedSimpleBioEntry()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 voidaddComment(Comment comment)Adds a comment instance to this bioentry.voidaddRankedCrossRef(RankedCrossRef crossref)Adds a ranked cross reference to the existing set.voidaddRankedDocRef(RankedDocRef docref)Adds a ranked docref instance to this bioentry.voidaddRelationship(BioEntryRelationship relation)Adds a relation instance to this bioentry.intcompareTo(Object o)Bioentries are ordered first by namespace, then name, accession, and finally version.booleanequals(Object obj)Two bioentries are equal if they share the same namespace, name, accession and version.StringgetAccession()Returns the accession of this bioentry.AnnotationgetAnnotation()Should return the associated annotation object.Set<Comment>getComments()Returns a set of all comments associated with this bioentry.StringgetDescription()Returns a description of this sequence.StringgetDivision()Returns the division of this bioentry.IntegergetId()Gets the Hibernate ID.StringgetIdentifier()Returns the identifier of this bioentry.StringgetName()Returns the name of this bioentry.NamespacegetNamespace()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.RichAnnotationgetRichAnnotation()Return the associated annotation object.NCBITaxongetTaxon()Gets the taxon associated with this bioentry.intgetVersion()Gets the version of this bioentry.inthashCode()voidremoveComment(Comment comment)Removes a comment instance from this bioentry.voidremoveRankedCrossRef(RankedCrossRef crossref)Removes a ranked cross reference from the existing set.voidremoveRankedDocRef(RankedDocRef docref)Removes a ranked docref instance from this bioentry.voidremoveRelationship(BioEntryRelationship relation)Removes a relation instance from this bioentry.voidsetDescription(String description)Sets the description for this bioentry.voidsetDivision(String division)Sets the division of this bioentry.voidsetId(Integer id)Sets the Hibernate ID.voidsetIdentifier(String identifier)Sets the identifier of this bioentry.voidsetNoteSet(Set<Note> notes)Clears the notes associated with this object and replaces them with the contents of this set.voidsetRankedCrossRefs(Set<RankedCrossRef> rankedcrossrefs)Sets the ranked cross references associated with an object.voidsetTaxon(NCBITaxon taxon)Sets the taxon for this bioentry.StringtoString()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:
getRankedCrossRefsin 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:
setTaxonin 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:
getAnnotationin interfaceAnnotatable- Returns:
- an Annotation object, never null
-
getRichAnnotation
public RichAnnotation getRichAnnotation()
Return the associated annotation object.- Specified by:
getRichAnnotationin 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:
getNoteSetin 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:
setNoteSetin 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:
getCommentsin 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:
getRankedDocRefsin 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:
getRelationshipsin 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:
setIdentifierin 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:
setDivisionin 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:
setDescriptionin 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:
getAccessionin interfaceBioEntry- Returns:
- Value of property accession.
-
getDescription
public String getDescription()
Returns a description of this sequence.- Specified by:
getDescriptionin 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:
getDivisionin interfaceBioEntry- Returns:
- Value of property division.
-
getIdentifier
public String getIdentifier()
Returns the identifier of this bioentry.- Specified by:
getIdentifierin 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:
getNamespacein 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:
getVersionin 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:
compareToin 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:
addRankedCrossRefin 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:
removeRankedCrossRefin 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:
addRankedDocRefin 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:
removeRankedDocRefin 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:
addCommentin 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:
removeCommentin 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:
addRelationshipin 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:
removeRelationshipin 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:RankedCrossRefableSets the ranked cross references associated with an object. Null will throw an exception but the empty set is fine.- Specified by:
setRankedCrossRefsin 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.
-
-