X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FDBRefEntry.java;h=b6c31929a6c3d7b326891731a7e0484556a949a8;hb=3d1147ffae5fbc5bdb7c80caa9655df656b8e67b;hp=8bbb5f7b58a100f0fbe5ba31b317d351a36c8a8c;hpb=385e63c78d289d4beae9c1ad2b187c0ea311ffbc;p=jalview.git diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 8bbb5f7..b6c3192 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -32,32 +32,62 @@ public class DBRefEntry { this(source, version, accessionId, null); } + /** + * + * @param source canonical source (uppercase only) + * @param version (source dependent version string) + * @param accessionId (source dependent accession number string) + * @param map (mapping from local sequence numbering to source accession numbering) + */ public DBRefEntry(String source, String version, String accessionId, Mapping map) { - this.source = source; + this.source = source.toUpperCase(); this.version = version; this.accessionId = accessionId; this.map = map; } public DBRefEntry(DBRefEntry entry) { - this(new String(entry.source), new String(entry.version), new String(entry.accessionId), new Mapping(entry.map)); + this((entry.source==null ? "" : new String(entry.source)), + (entry.version==null ? "" : new String(entry.version)), + (entry.accessionId==null ? "" : new String(entry.accessionId)), + (entry.map==null ? null : new Mapping(entry.map))); } public boolean equals(DBRefEntry entry) { if (entry==this) return true; if (entry==null) return false; - if ((source!=null && entry.source!=null && source.equals(entry.source)) - && - (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId)) - && - (version!=null && entry.version!=null && version.equals(entry.version)) - && + if (equalRef(entry) + && ((map==null && entry.map==null) || (map!=null && entry.map!=null && map.equals(entry.map)))) { return true; } return false; } + /** + * test for similar DBRef attributes, except for the map object. + * @param entry + * @return true if source, accession and version are equal with those of entry + */ + public boolean equalRef(DBRefEntry entry) + { + if (entry==null) + { + return false; + } + if (entry==this) + return true; + if ((source!=null && entry.source!=null && source.equalsIgnoreCase(entry.source)) + && + (accessionId!=null && entry.accessionId!=null && accessionId.equalsIgnoreCase(entry.accessionId)) + && + (version!=null && entry.version!=null && version.equalsIgnoreCase(entry.version)) + ) + { + return true; + } + return false; + } public String getSource() { return source; @@ -104,7 +134,6 @@ public void setMap(Mapping map) { } public boolean hasMap() { - // TODO Auto-generated method stub return map!=null; } /**