X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fphylogeny%2Fdata%2FAnnotation.java;h=99f969151e922d149dd8fb2746f9f274edd989a0;hb=5c4e24e304f57058fa1c3a3f1256a573b37d89f6;hp=4e9eb08e9b6fedc3652177c75748afb5110f7098;hpb=ebabb46561f996b5fcd59bd202defd7b189ea5b6;p=jalview.git diff --git a/forester/java/src/org/forester/phylogeny/data/Annotation.java b/forester/java/src/org/forester/phylogeny/data/Annotation.java index 4e9eb08..99f9691 100644 --- a/forester/java/src/org/forester/phylogeny/data/Annotation.java +++ b/forester/java/src/org/forester/phylogeny/data/Annotation.java @@ -21,7 +21,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.phylogeny.data; @@ -36,32 +36,53 @@ import org.forester.util.ForesterUtil; public class Annotation implements PhylogenyData, MultipleUris, Comparable { + private Confidence _confidence; private String _desc; - private String _type; - private String _source; - private final String _ref; private String _evidence; - private Confidence _confidence; private PropertiesMap _properties; + private final String _ref_source; + private final String _ref_value; + private String _source; + private String _type; private List _uris; + public Annotation() { + _ref_value = ""; + _ref_source = ""; + init(); + } + public Annotation( final String ref ) { if ( ForesterUtil.isEmpty( ref ) ) { throw new IllegalArgumentException( "annotation reference is empty or null" ); } - if ( ( ref.indexOf( ':' ) < 1 ) || ( ref.length() < 3 ) ) { + final String s[] = ref.split( ":" ); + if ( ( s.length != 2 ) || ForesterUtil.isEmpty( s[ 0 ] ) || ForesterUtil.isEmpty( s[ 1 ] ) ) { throw new IllegalArgumentException( "illegal format for annotation reference: [" + ref + "]" ); } - _ref = ref; + _ref_source = s[ 0 ]; + _ref_value = s[ 1 ]; init(); } - public Annotation() { - _ref = ""; + public Annotation( final String ref_source, final String ref_value ) { + if ( ForesterUtil.isEmpty( ref_source ) || ForesterUtil.isEmpty( ref_value ) ) { + throw new IllegalArgumentException( "illegal format for annotation reference" ); + } + _ref_source = ref_source; + _ref_value = ref_value; init(); } @Override + public void addUri( final Uri uri ) { + if ( getUris() == null ) { + setUris( new ArrayList() ); + } + getUris().add( uri ); + } + + @Override public StringBuffer asSimpleText() { return new StringBuffer( !ForesterUtil.isEmpty( getRef() ) ? getRef() : getDesc() ); } @@ -72,17 +93,28 @@ public class Annotation implements PhylogenyData, MultipleUris, Comparable getUris() { + return _uris; } @Override @@ -174,6 +238,11 @@ public class Annotation implements PhylogenyData, MultipleUris, Comparable uris ) { + _uris = uris; + } + + @Override public StringBuffer toNHX() { throw new UnsupportedOperationException(); } @@ -234,54 +303,13 @@ public class Annotation implements PhylogenyData, MultipleUris, Comparable() ); - } - getUris().add( uri ); - } - - @Override - public Uri getUri( final int index ) { - return getUris().get( index ); - } - - @Override - public List getUris() { - return _uris; - } - - @Override - public void setUris( final List uris ) { - _uris = uris; - } - - @Override - public boolean equals( final Object o ) { - if ( this == o ) { - return true; - } - else if ( o == null ) { - return false; - } - else if ( o.getClass() != this.getClass() ) { - throw new IllegalArgumentException( "attempt to check [" + this.getClass() + "] equality to " + o + " [" - + o.getClass() + "]" ); - } - else { - return isEqual( ( Annotation ) o ); - } - } - - @Override - public int compareTo( final Annotation o ) { - if ( equals( o ) ) { - return 0; - } - if ( getRef().equals( o.getRef() ) ) { - return getDesc().compareTo( o.getDesc() ); - } - return getRef().compareTo( o.getRef() ); + private void init() { + _desc = ""; + _type = ""; + _source = ""; + _evidence = ""; + _confidence = null; + _properties = null; + setUris( null ); } }