import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
-import uk.ac.vamsas.client.utils.ChecksummedReader;
import uk.ac.vamsas.objects.core.VamsasDocument;
/**
* Implements the Vamsas Vobject ID machinery for translating
private final Hashtable oldobjhashes;
private final Hashtable objrefs;
private final Vector updatedobjs; // not yet used elswhere ?
- private final ChecksummedReader inStream;
- public VorbaXmlBinder(IVorbaIdFactory vorbafactory, Vector obj, Hashtable objrefs, Hashtable oldobjhashes, Vector updatedobjs) {
- this(vorbafactory, obj, objrefs, oldobjhashes, updatedobjs, null);
-
- }
-
- public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj, ChecksummedReader ckedInstream) {
- this.inStream = ckedInstream;
+ public VorbaXmlBinder(IVorbaIdFactory vorbafactory2, Vector unrefedObj, Hashtable objrefs2, Hashtable oldobjhashes, Vector updatedObj) {
this.vorbafactory = vorbafactory2;
this.obj = unrefedObj;
this.objrefs = objrefs2;
public void initialized(Object object) {
if (object instanceof Vobject) {
Vobject nobj = (Vobject) object;
- if (nobj.isRegisterable() && nobj.___id_field!=null && inStream!=null)
- nobj.__setInitHash(inStream.getChecksum()); // record start tag position
}
}
nobj.set__stored_in_document(true);
try {
if (nobj.isRegisterable() && nobj.___id_field!=null) {
- if (inStream!=null)
- nobj.__setFinalHash(inStream.getChecksum()); // compute LHash as difference between end and start tag positions
VorbaId nobj_id=null;
// look for the id field (should be an NCName string)
nobj.__vorba = vorbafactory;
// TODO: add to list of objects without a valid vorbaId
obj.add(nobj);
}
- nobj.doHash(); // TODO: DECIDE IF WE NEED TO DO THIS STILL: THIS DOESNT WORK! updates detected by comparing with last hash when marshalling
-
+ nobj.doHash(); // updates detected by comparing with last hash when marshalling
// check to see if new object was present in old object hash
if (nobj_id!=null) {
if (oldobjhashes.containsKey(nobj_id)) {
if (oldhash.isUpdated(nobj)) {
// mark the object as updated in this document read.
nobj.set__updated_since_last_read(true);
- oldobjhashes.put(nobj_id, new Vobjhash(nobj));
updatedobjs.addElement(nobj);
}
} else {
final VorbaIdFactory vorbafactory = factory;
final Vector unrefedObj = new Vector();
final Vector updatedObj = new Vector();
- ChecksummedReader ckedInstream = new ChecksummedReader(instream);
- unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes,updatedObj, ckedInstream));
+ unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs, oobjhashes,updatedObj));
// Call the unmarshaller.
try {
while (instream.ready()) {
// TODO: mark objects in oobjhash prior to unmarshalling, to detect when objects have been lost through an update.
//tohere
- Object obj = unmarshaller.unmarshal(ckedInstream);
+ Object obj = unmarshaller.unmarshal(instream);
boolean sync=ensure_references(unrefedObj, objrefs);
if (!(obj instanceof Vobject))
return null;