+ /**
+ *
+ * @return null or a string for associated chain IDs
+ */
+ public String getChainCode()
+ {
+ return (properties == null || properties.get(CHAIN_ID) == null) ? null
+ : properties.get(CHAIN_ID).toString();
+ }
+
+ public void setChainCode(String 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
+ public String toString()
+ {
+ return id;
+ }
+
+ /**
+ * update entry with details from another entry concerning the same PDB
+ * ID/file spec.
+ *
+ * @param newEntry
+ * @return true if modifications were made
+ */
+ public boolean updateFrom(PDBEntry newEntry)
+ {
+ boolean modified = false;
+
+ if (getFile() == null)
+ {
+ // update file and type of file
+ modified |= newEntry.getFile() != null;
+ setFile(newEntry.getFile());
+ }
+ if (newEntry.getType() != null && newEntry.getFile() != null
+ && newEntry.getFile().equals(getFile()))
+ {
+ setType(newEntry.getType());
+ }
+ if (getChainCode() == null
+ || (getChainCode() != null && getChainCode().length() == 0 && newEntry
+ .getChainCode() != null))
+ {
+ modified |= getChainCode() == null
+ || !newEntry.getChainCode().equals(getChainCode());
+ setChainCode(newEntry.getChainCode());
+ }
+ if (newEntry.getProperty() != null)
+ {
+ if (properties == null)
+ {
+ properties = new Hashtable();
+ }
+ // TODO: getProperty -> Map<String,String>
+ for (Object p : newEntry.getProperty().keySet())
+ {
+ if (properties.get(p) == null
+ || !properties.get(p).equals(newEntry.getProperty().get(p)))
+ {
+ modified = true;
+ }
+ properties.put(p, newEntry.getProperty().get(p));
+ }
+ }
+ return modified;
+ }