[Biojava-dev] SimpleFeature simple question

Matthew Pocock matthew_pocock@yahoo.co.uk
Fri, 8 Nov 2002 11:14:54 +0000 (GMT)


Hi Paul,

This is a bug not a feature I think. I'm not sure. Do
we state anywhere in the docs that the annotation is
or is not coppied? There are cases (e.g. if you pass
in Annotation.EMPTY_ANNOTATION) where you /may/ want
to replace this with a SimpleAnnotation instance.

I would sudgest changing the line

this.annotation = new
SimpleAnnotation(template.annotation);

to:

this.annotation = (template.annotation ==
Annotation.EMPTY_ANNOTATION) ?
  new SimpleAnnotation() :
  template.annotation;

This will break code where people assume that
annotations are coppied. People, comments?

Matthew

 --- Paul.Seed@geneprot.com wrote: > Hello -
> 
> I have a small question about the behaviour of
> SimpleFeature - I'm sure
> there's a good reason for it, but it's not
> immediately obvious to me why
> the constructor creates a new SimpleAnnotation based
> on the Template
> annotation:
> 
>         this.loc = template.location;
>         this.type = template.type;
>         this.source = template.source;
>         this.annotation = new
> SimpleAnnotation(template.annotation);
> 
> ... rather than simply using the annotation from the
> template directly:
> 
>         this.annotation = template.annotation;
> 
> This behaviour caught me out when I created a
> feature (using the default
> feature realizer) based on a template containing my
> own Annotation
> implementation.  When I later accessed the feature's
> annotation, I was
> surprised to find that it was a SimpleAnnotation
> rather than my own
> implementation class.  I can avoid the problem by
> using a custom
> "MySimpleFeature" that takes its Annotation directly
> from the Template, but
> I'd like to increase my knowledge of BioJava by
> understanding what this
> workaround might break!
> 
> Thanks, best regards
> 
> 
> - Paul Seed.
> 
> Bioinformatician
> GeneProt Inc. (Geneva Branch)
> Tel. +41 (0)22 719 88 36
> Fax. +41 (0)22 719 88 69
> 
> 
> _______________________________________________
> biojava-dev mailing list
> biojava-dev@biojava.org
> http://biojava.org/mailman/listinfo/biojava-dev 

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com