X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=0652fb5fa0951b268c3a6a5720c2dc6afdf8bc97;hb=b5d61763044c1d72f06ce0e50da2171422a3774b;hp=69d6da255c4facc7965454f74e5eaf5d7a3885b0;hpb=03496bf88fc1bec3ce628ac79ce69440ce244007;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)