<class name="jalview.datamodel.PDBEntry">
<field name="type"><bind-xml node="attribute"/></field>
<field name="id"><bind-xml node="attribute"/></field>
- <field name="property" collection="hashtable">
+ <field name="props" collection="hashtable">
<bind-xml name="property">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key">
worker.start();
}
- if (pdbentry.getProperty() != null)
+ String method = (String) pdbentry.getProperty("method");
+ if (method != null)
{
- if (pdbentry.getProperty().get("method") != null)
- {
- title.append(" Method: ");
- title.append(pdbentry.getProperty().get("method"));
- }
- if (pdbentry.getProperty().get("chains") != null)
- {
- title.append(" Chain:");
- title.append(pdbentry.getProperty().get("chains"));
- }
+ title.append(" Method: ");
+ title.append(method);
+ }
+ String ch = (String) pdbentry.getProperty("chains");
+ if (ch != null)
+ {
+ title.append(" Chain:");
+ title.append(ch);
}
Desktop.addInternalFrame(this, title.toString(), 400, 400);
}
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
}
if (needtoadd)
{
- // make a note of the access mode and add
- if (pdbentry.getProperty() == null)
- {
- pdbentry.setProperty(new Hashtable());
- }
- pdbentry.getProperty().put("protocol", protocol);
+ pdbentry.setProperty("protocol", protocol);
toaddpdb.addPDBId(pdbentry);
alignPanel.getStructureSelectionManager()
.registerPDBEntry(pdbentry);
if (protocol == null || protocol.trim().length() == 0
|| protocol.equals("null"))
{
- protocol = (String) pdb.getProperty().get("protocol");
+ protocol = (String) pdb.getProperty("protocol");
if (protocol == null)
{
System.err.println("Couldn't work out protocol to open structure: "
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
closeViewer();
}
});
- if (pdbentry.getProperty() == null)
- {
- pdbentry.setProperty(new Hashtable());
- pdbentry.getProperty().put("protocol", protocol);
- }
+ pdbentry.setProperty("protocol", protocol);
+
if (pdbentry.getFile() != null)
{
// import structure data from pdbentry.getFile based on given protocol
import jalview.util.CaseInsensitiveString;
+import java.util.Collections;
+import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Map.Entry;
public class PDBEntry
{
+
+ /**
+ * constant for storing chain code in properties table
+ */
+ private static final String CHAIN_ID = "chain_code";
+
+ Hashtable<String, Object> properties;
+
private String file;
private String type;
}
}
- /**
- * constant for storing chain code in properties table
- */
- private static final String CHAIN_ID = "chain_code";
-
- Hashtable properties;
/*
* (non-Javadoc)
id = entry.id;
if (entry.properties != null)
{
- properties = (Hashtable) entry.properties.clone();
+ properties = (Hashtable<String, Object>) entry.properties.clone();
}
}
- public void setFile(String file)
+ public void setFile(String f)
{
- this.file = file;
+ this.file = f;
}
public String getFile()
return id;
}
- public void setProperty(Hashtable property)
+ public void setProperty(String key, Object value)
{
- this.properties = property;
+ if (this.properties == null)
+ {
+ this.properties = new Hashtable<String, Object>();
+ }
+ properties.put(key, value);
}
- public Hashtable getProperty()
+ public Object getProperty(String key)
{
- return properties;
+ return properties == null ? null : properties.get(key);
+ }
+
+ /**
+ * Returns an enumeration of the keys of this object's properties (or an empty
+ * enumeration if it has no properties)
+ *
+ * @return
+ */
+ public Enumeration<String> getProperties()
+ {
+ if (properties == null)
+ {
+ return Collections.emptyEnumeration();
+ }
+ return properties.keys();
}
/**
: properties.get(CHAIN_ID).toString();
}
+ /**
+ * Sets a non-case-sensitive property for the given chain code. Two PDBEntry
+ * objects which differ only in the case of their chain code are considered
+ * equal. This avoids duplication of objects in lists of PDB ids.
+ *
+ * @param chainCode
+ */
public void setChainCode(String chainCode)
{
- if (properties == null)
+ if (chainCode == null)
{
- if (chainCode == null)
- {
- // nothing to do.
- return;
- }
- properties = new Hashtable();
+ deleteProperty(CHAIN_ID);
}
- if (chainCode == null)
+ else
+ {
+ setProperty(CHAIN_ID, new CaseInsensitiveString(chainCode));
+ }
+ }
+
+ /**
+ * Deletes the property with the given key, and returns the deleted value (or
+ * null)
+ */
+ Object deleteProperty(String key)
+ {
+ Object result = null;
+ if (properties != null)
{
- properties.remove(CHAIN_ID);
- return;
+ result = properties.remove(key);
}
- // update property for non-null chainCode
- properties.put(CHAIN_ID, new CaseInsensitiveString(chainCode));
+ return result;
}
@Override
}
/**
+ * Getter provided for Castor binding only. Application code should call
+ * getProperty() or getProperties() instead.
+ *
+ * @deprecated
+ * @see #getProperty(String)
+ * @see #getProperties()
+ * @see jalview.ws.dbsources.Uniprot#getUniprotEntries
+ * @return
+ */
+ @Deprecated
+ public Hashtable<String, Object> getProps()
+ {
+ return properties;
+ }
+
+ /**
+ * Setter provided for Castor binding only. Application code should call
+ * setProperty() instead.
+ *
+ * @deprecated
+ * @return
+ */
+ @Deprecated
+ public void setProps(Hashtable<String, Object> props)
+ {
+ properties = props;
+ }
+
+ /**
* update entry with details from another entry concerning the same PDB
* ID/file spec.
*
if (getFile() == null)
{
// update file and type of file
- modified |= newEntry.getFile() != null;
+ modified = newEntry.getFile() != null;
setFile(newEntry.getFile());
}
if (newEntry.getType() != null && newEntry.getFile() != null
|| (getChainCode() != null && getChainCode().length() == 0 && newEntry
.getChainCode() != null))
{
- modified |= getChainCode() == null
- || !newEntry.getChainCode().equals(getChainCode());
+ modified |= (getChainCode() == null || !newEntry.getChainCode()
+ .equals(getChainCode()));
setChainCode(newEntry.getChainCode());
}
- if (newEntry.getProperty() != null)
+ if (newEntry.properties != null)
{
- if (properties == null)
- {
- properties = new Hashtable();
- }
- // TODO: getProperty -> Map<String,String>
- for (Object p : newEntry.getProperty().keySet())
+ for (Entry<String, Object> entry : newEntry.properties.entrySet())
{
- if (properties.get(p) == null
- || !properties.get(p).equals(newEntry.getProperty().get(p)))
+ if (!entry.getValue().equals(getProperty(entry.getKey())))
{
modified = true;
}
- properties.put(p, newEntry.getProperty().get(p));
+ setProperty(entry.getKey(), entry.getValue());
}
}
return modified;
}
}
- if (entry.getProperty() != null && !entry.getProperty().isEmpty())
+ Enumeration<String> props = entry.getProperties();
+ if (props.hasMoreElements())
{
PdbentryItem item = new PdbentryItem();
- Hashtable properties = entry.getProperty();
- Enumeration en2 = properties.keys();
- while (en2.hasMoreElements())
+ while (props.hasMoreElements())
{
Property prop = new Property();
- String key = en2.nextElement().toString();
+ String key = props.nextElement();
prop.setName(key);
- prop.setValue(properties.get(key).toString());
+ prop.setValue(entry.getProperty(key).toString());
item.addProperty(prop);
}
pdb.addPdbentryItem(item);
}
if (ids[p].getPdbentryItem() != null)
{
- entry.setProperty(new Hashtable());
for (PdbentryItem item : ids[p].getPdbentryItem())
{
for (Property pr : item.getProperty())
{
- entry.getProperty().put(pr.getName(), pr.getValue());
+ entry.setProperty(pr.getName(), pr.getValue());
}
}
}
import java.awt.Color;
import java.io.IOException;
import java.lang.reflect.Constructor;
-import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
{
}
- @SuppressWarnings("rawtypes")
protected SequenceI postProcessChain(PDBChain chain)
{
SequenceI pdbSequence = chain.sequence;
PDBEntry entry = new PDBEntry();
entry.setId(getId());
entry.setType(getStructureFileType());
- entry.setProperty(new Hashtable());
if (chain.id != null)
{
- entry.setChainCode(String.valueOf(chain.id));
+ entry.setChainCode(chain.id);
}
if (inFile != null)
{
// TODO: give a more informative title when multiple structures are
// displayed.
StringBuilder title = new StringBuilder(64);
- final PDBEntry pdbEntry = getPdbEntry(0);
+ final PDBEntry pdbe = getPdbEntry(0);
title.append(viewerName + " view for " + getSequence()[0][0].getName()
- + ":" + pdbEntry.getId());
+ + ":" + pdbe.getId());
if (verbose)
{
- if (pdbEntry.getProperty() != null)
+ String method = (String) pdbe.getProperty("method");
+ if (method != null)
{
- if (pdbEntry.getProperty().get("method") != null)
- {
- title.append(" Method: ");
- title.append(pdbEntry.getProperty().get("method"));
- }
- if (pdbEntry.getProperty().get("chains") != null)
- {
- title.append(" Chain:");
- title.append(pdbEntry.getProperty().get("chains"));
- }
+ title.append(" Method: ").append(method);
+ }
+ String chain = (String) pdbe.getProperty("chains");
+ if (chain != null)
+ {
+ title.append(" Chain:").append(chain);
}
}
return title.toString();
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
PDBEntry pdbr = new PDBEntry();
pdbr.setId(pdbid);
pdbr.setType(PDBEntry.Type.PDB);
- pdbr.setProperty(new Hashtable());
pdbr.setChainCode(chaincode);
- // pdbr.getProperty().put("CHAIN", chaincode);
seq.addPDBId(pdbr);
}
else
/*
* change string wrapper property to string...
*/
- case1.getProperty().put("chain_code", "a");
+ case1.setProperty("chain_code", "a");
assertFalse(pdbEntry.equals(case1));
assertFalse(case1.equals(pdbEntry));
}
package jalview.ws.dbsources;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import jalview.datamodel.PDBEntry;
PDBEntry xref = xrefs.get(0);
assertEquals("2FSQ", xref.getId());
assertEquals("PDB", xref.getType());
- assertEquals(2, xref.getProperty().size());
- assertEquals("X-ray", xref.getProperty().get("method"));
- assertEquals("1.40", xref.getProperty().get("resolution"));
+ assertEquals("X-ray", xref.getProperty("method"));
+ assertEquals("1.40", xref.getProperty("resolution"));
xref = xrefs.get(1);
assertEquals("2FSR", xref.getId());
assertEquals("PDBsum", xref.getType());
- assertNull(xref.getProperty());
+ assertFalse(xref.getProperties().hasMoreElements());
}
/**