X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fxdb%2Fgenbank%2FGenBankLocations.java;fp=src%2Fjalview%2Fio%2Fxdb%2Fgenbank%2FGenBankLocations.java;h=ae3e47b1fb465286e1d7ad73e0827e4dfed8bf53;hb=2d63cfb4d8f84de5f40670bb301ee8a22db321ff;hp=0000000000000000000000000000000000000000;hpb=be8b596f15d36db1a9aec20efd993a6aa44a863a;p=jalview.git diff --git a/src/jalview/io/xdb/genbank/GenBankLocations.java b/src/jalview/io/xdb/genbank/GenBankLocations.java new file mode 100644 index 0000000..ae3e47b --- /dev/null +++ b/src/jalview/io/xdb/genbank/GenBankLocations.java @@ -0,0 +1,98 @@ +package jalview.io.xdb.genbank; + +/** + * + * @author Dieval Guizelini + */ +public class GenBankLocations extends GenBankLocation { + public static final int NONE = 1; // default + public static final int COMPLEMENT = 2; + public static final int JOIN = 3; + public static final int ORDER = 4; // conj com ordem desconhecida + private int operator = NONE; + private java.util.List units; + + public GenBankLocations() { + units = new java.util.ArrayList(); + } + + @Override + public void setComplement(boolean complement){ + super.setComplement(complement); + this.operator = COMPLEMENT; + if (units != null) { + for (GenBankLocation o : units) { + o.setComplement(complement); + } + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (getOperator() == COMPLEMENT) { + sb.append("complement("); + } else if (getOperator() == JOIN) { + sb.append("join("); + } else if (getOperator() == ORDER) { + sb.append("order("); + } + if (units.size() > 0) { + sb.append(units.get(0).toString()); + for (int i = 1; i < units.size(); i++) { + sb.append(","); + sb.append(units.get(i).toString()); + } + } + if (getOperator() != NONE) { + sb.append(")"); + } + return sb.toString(); + } + + /** + * @return the units + */ + public java.util.List getUnits() { + return units; + } + + /** + * @param units the units to set + */ + public void setUnits(java.util.List units) { + this.units = units; + } + + @Override + public int getMinor() { + if( units.size() > 0 ) { + return units.get(0).getMinor(); + } + return 0; + } + + @Override + public int getMajor() { + int ind = units.size(); + if( ind > 0 ) { + return units.get(ind-1).getMajor(); + } + return 0; + } + + /** + * @return the operator + */ + public int getOperator() { + return operator; + } + + /** + * @param operator the operator to set + */ + public void setOperator(int operator) { + this.operator = operator; + } + +}