private String id;
- private String chainCode;
-
public enum Type
{
- PDB, MMCIF, FILE
+ PDB, MMCIF, FILE;
+ /**
+ * case insensitive matching for Type enum
+ *
+ * @param value
+ * @return
+ */
+ public static Type getType(String value)
+ {
+ for (Type t : Type.values())
+ {
+ if (t.toString().equalsIgnoreCase(value))
+ {
+ return t;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * case insensitive equivalence for strings resolving to PDBEntry type
+ *
+ * @param t
+ * @return
+ */
+ public boolean matches(String t)
+ {
+ return (this.toString().equalsIgnoreCase(t));
+ }
}
+ public final class ChainId
+ {
+ String chainId;
+
+ public ChainId(String chainId)
+ {
+ this.chainId = chainId;
+ }
+
+ @Override
+ public String toString()
+ {
+ return chainId;
+ }
+
+ @Override
+ public boolean equals(Object o){
+ if (o==null)
+ {
+ return false;
+ }
+ return chainId.equalsIgnoreCase(o.toString());
+ }
+ }
+
+ /**
+ * constant for storing chain code in properties table
+ */
+ private static final String CHAIN_ID = "chain_code";
+
Hashtable properties;
/*
.equals(type)))
&& (id == o.id || (id != null && o.id != null && o.id
.equalsIgnoreCase(id)))
- && (chainCode == o.chainCode || (chainCode != null
- && o.chainCode != null && o.chainCode
- .equalsIgnoreCase(chainCode)))
&& (properties == o.properties || (properties != null
&& o.properties != null && properties
.equals(o.properties)));
String filePath)
{
this.id = pdbId;
- this.chainCode = chain;
this.type = type == null ? null : type.toString();
this.file = filePath;
+ setChainCode(chain);
}
/**
file = entry.file;
type = entry.type;
id = entry.id;
- chainCode = entry.chainCode;
if (entry.properties != null)
{
properties = (Hashtable) entry.properties.clone();
return properties;
}
+ /**
+ *
+ * @return null or a string for associated chain IDs
+ */
public String getChainCode()
{
- return chainCode;
+ return (properties == null || properties.get(CHAIN_ID) == null) ? null
+ : properties.get(CHAIN_ID).toString();
}
public void setChainCode(String chainCode)
{
- this.chainCode = chainCode;
+ if (properties == null)
+ {
+ if (chainCode == null)
+ {
+ // nothing to do.
+ return;
+ }
+ properties = new Hashtable();
+ }
+ if (chainCode == null)
+ {
+ properties.remove(CHAIN_ID);
+ return;
+ }
+ // update property for non-null chainCode
+ properties.put(CHAIN_ID, new ChainId(chainCode));
}
@Override