+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package jalview.io.vamsas;
import jalview.bin.Cache;
/**
* Holds all the common machinery for binding objects to vamsas objects
+ *
* @author JimP
- *
+ *
*/
public class DatastoreItem
{
Hashtable vobj2jv;
IdentityHashMap jv2vobj;
+
/**
* @return the Vobject bound to Jalview datamodel object
*/
{
if (jv2vobj.containsKey(jvobj))
{
- return cdoc.getObject( (VorbaId) jv2vobj.get(jvobj));
+ return cdoc.getObject((VorbaId) jv2vobj.get(jvobj));
}
if (Cache.log.isDebugEnabled())
{
- Cache.log.debug("Returning null VorbaID binding for jalview object "+jvobj);
+ Cache.log.debug("Returning null VorbaID binding for jalview object "
+ + jvobj);
}
return null;
}
/**
- *
+ *
* @param vobj
* @return Jalview datamodel object bound to the vamsas document object
*/
protected Object getvObj2jv(uk.ac.vamsas.client.Vobject vobj)
{
- if (vobj2jv==null)
+ if (vobj2jv == null)
return null;
VorbaId id = vobj.getVorbaId();
if (id == null)
{
id = cdoc.registerObject(vobj);
Cache.log
- .debug("Registering new object and returning null for getvObj2jv");
+ .debug("Registering new object and returning null for getvObj2jv");
return null;
}
if (vobj2jv.containsKey(vobj.getVorbaId()))
if (id == null)
{
id = cdoc.registerObject(vobj);
- if (id == null || vobj.getVorbaId() == null || cdoc.getObject(id)!=vobj)
+ if (id == null || vobj.getVorbaId() == null
+ || cdoc.getObject(id) != vobj)
{
- Cache.log.error("Failed to get id for " +
- (vobj.isRegisterable() ? "registerable" :
- "unregisterable") + " object " + vobj);
+ Cache.log.error("Failed to get id for "
+ + (vobj.isRegisterable() ? "registerable"
+ : "unregisterable") + " object " + vobj);
}
}
- if (vobj2jv.containsKey(vobj.getVorbaId()) &&
- ! ( (VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
+ if (vobj2jv.containsKey(vobj.getVorbaId())
+ && !((VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
{
- Cache.log.debug("Warning? Overwriting existing vamsas id binding for " +
- vobj.getVorbaId(),
- new Exception("Overwriting vamsas id binding."));
+ Cache.log.debug(
+ "Warning? Overwriting existing vamsas id binding for "
+ + vobj.getVorbaId(), new Exception(
+ "Overwriting vamsas id binding."));
}
- else if (jv2vobj.containsKey(jvobj) &&
- ! ( (VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
+ else if (jv2vobj.containsKey(jvobj)
+ && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
{
Cache.log.debug(
- "Warning? Overwriting existing jalview object binding for " + jvobj,
- new Exception("Overwriting jalview object binding."));
+ "Warning? Overwriting existing jalview object binding for "
+ + jvobj, new Exception(
+ "Overwriting jalview object binding."));
}
- /* Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id " +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+" already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to bindjvvobj"));
- }*/
+ /*
+ * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
+ * +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+"
+ * already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to
+ * bindjvvobj")); }
+ */
// we just update the hash's regardless!
- Cache.log.debug("Binding "+vobj.getVorbaId()+" to "+jvobj);
+ Cache.log.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
vobj2jv.put(vobj.getVorbaId(), jvobj);
// JBPNote - better implementing a hybrid invertible hash.
jv2vobj.put(jvobj, vobj.getVorbaId());
}
- public DatastoreItem() {
+ public DatastoreItem()
+ {
super();
}
+
public DatastoreItem(VamsasAppDatastore datastore)
{
this();
initDatastoreItem(datastore);
// TODO Auto-generated constructor stub
}
+
VamsasAppDatastore datastore = null;
+
public void initDatastoreItem(VamsasAppDatastore ds)
{
datastore = ds;
- initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(), ds.getVamsasObjectBinding(), ds.getJvObjectBinding());
+ initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(), ds
+ .getVamsasObjectBinding(), ds.getJvObjectBinding());
}
- public void initDatastoreItem(Entry provEntry, IClientDocument cdoc, Hashtable vobj2jv, IdentityHashMap jv2vobj)
+
+ public void initDatastoreItem(Entry provEntry, IClientDocument cdoc,
+ Hashtable vobj2jv, IdentityHashMap jv2vobj)
{
this.provEntry = provEntry;
this.cdoc = cdoc;
protected boolean isModifiable(String modifiable)
{
- return modifiable==null; // TODO: USE VAMSAS LIBRARY OBJECT LOCK METHODS)
+ return modifiable == null; // TODO: USE VAMSAS LIBRARY OBJECT LOCK METHODS)
}
protected Vector getjv2vObjs(Vector alsq)
}
return vObjs;
}
+
// utility functions
/**
* get start<end range of segment, adjusting for inclusivity flag and
* polarity.
- *
+ *
* @param visSeg
- * @param ensureDirection when true - always ensure start is less than end.
- * @return int[] { start, end, direction} where direction==1 for range running from end to start.
+ * @param ensureDirection
+ * when true - always ensure start is less than end.
+ * @return int[] { start, end, direction} where direction==1 for range running
+ * from end to start.
*/
public int[] getSegRange(Seg visSeg, boolean ensureDirection)
{
start = t;
}
return new int[]
- {
- start, end, pol < 0 ? 1 : 0};
+ { start, end, pol < 0 ? 1 : 0 };
}
+
/**
* provenance bits
*/
- protected jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
+ protected jalview.datamodel.Provenance getJalviewProvenance(
+ Provenance prov)
{
// TODO: fix App and Action entries and check use of provenance in jalview.
jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
for (int i = 0; i < prov.getEntryCount(); i++)
{
- jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i).getAction(),
- prov.getEntry(i).getDate(),
- prov.getEntry(i).getId());
+ jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i)
+ .getAction(), prov.getEntry(i).getDate(), prov.getEntry(i)
+ .getId());
}
return jprov;
}
/**
- *
+ *
* @return default initial provenance list for a Jalview created vamsas
* object.
*/