X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;fp=src%2Fjalview%2Fdatamodel%2FSequence.java;h=0652fb5fa0951b268c3a6a5720c2dc6afdf8bc97;hb=0b2e0f52baa343973a6c9b1e652ff584ce418fa0;hp=69d6da255c4facc7965454f74e5eaf5d7a3885b0;hpb=e34a708f67ff7496cb76c66a3d7b6f8e47518c02;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 69d6da2..0652fb5 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -879,22 +879,30 @@ public class Sequence implements SequenceI return datasetSequence; } + /** + * Returns a new array containing this sequence's annotations, or null. + */ public AlignmentAnnotation[] getAnnotation() { - if (annotation == null) - { - return null; - } - - AlignmentAnnotation[] ret = new AlignmentAnnotation[annotation.size()]; - for (int r = 0; r < ret.length; r++) - { - ret[r] = annotation.elementAt(r); - } + return annotation == null ? null : annotation + .toArray(new AlignmentAnnotation[annotation.size()]); + } - return ret; + /** + * Returns true if this sequence has the given annotation (by object + * identity). + */ + @Override + public boolean hasAnnotation(AlignmentAnnotation ann) + { + return annotation == null ? false : annotation.contains(ann); } + /** + * Add the given annotation, if not already added, and set its sequence ref to + * be this sequence. Does nothing if this sequence's annotations already + * include this annotation (by identical object reference). + */ public void addAlignmentAnnotation(AlignmentAnnotation annotation) { if (this.annotation == null)