git://source.jalview.org
/
vamsas.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bugfixed org.vamsas.test.simpleclient.ArchiveClient and made VorbaId mechanism more...
[vamsas.git]
/
src
/
org
/
vamsas
/
client
/
VorbaXmlBinder.java
diff --git
a/src/org/vamsas/client/VorbaXmlBinder.java
b/src/org/vamsas/client/VorbaXmlBinder.java
index
c172de3
..
0f4feb1
100644
(file)
--- a/
src/org/vamsas/client/VorbaXmlBinder.java
+++ b/
src/org/vamsas/client/VorbaXmlBinder.java
@@
-24,8
+24,8
@@
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.vamsas.objects.core.VamsasDocument;
/**
import org.exolab.castor.xml.ValidationException;
import org.vamsas.objects.core.VamsasDocument;
/**
- * Implements the Vamsas object ID machinery for translating
- * between non-volatile XML IDs and object references. Use the
+ * Implements the Vamsas Vobject ID machinery for translating
+ * between non-volatile XML IDs and Vobject references. Use the
* marshalling and unmarshalling methods in this class in order
* to avoid validation exceptions when marshalling new objects
* into the vamsas document.
* marshalling and unmarshalling methods in this class in order
* to avoid validation exceptions when marshalling new objects
* into the vamsas document.
@@
-58,6
+58,12
@@
public class VorbaXmlBinder implements UnmarshalListener {
* java.lang.Object, java.lang.Object)
*/
public void fieldAdded(String fieldName, Object parent, Object child) {
* java.lang.Object, java.lang.Object)
*/
public void fieldAdded(String fieldName, Object parent, Object child) {
+ if (parent instanceof Vobject && child instanceof Vobject) {
+ if (((Vobject) child).V_parent==null) {
+ // System.err.println("Setting parent of "+fieldName);
+ ((Vobject) child).setV_parent((Vobject) parent);
+ }
+ }
}
/*
}
/*
@@
-70,20
+76,20
@@
public class VorbaXmlBinder implements UnmarshalListener {
/*
* Check if the object has an 'id' field - if it does, copy the value into
/*
* Check if the object has an 'id' field - if it does, copy the value into
- * the VorbaId field of object, and add the object to the VorbaId hash.
+ * the VorbaId field of Vobject, and add the Vobject to the VorbaId hash.
*
* @see org.exolab.castor.xml.UnmarshalListener#unmarshalled(java.lang.Object)
*/
public void unmarshalled(Object newobj) {
*
* @see org.exolab.castor.xml.UnmarshalListener#unmarshalled(java.lang.Object)
*/
public void unmarshalled(Object newobj) {
- if (newobj instanceof object) {
- object nobj = (object) newobj;
+ if (newobj instanceof Vobject) {
+ Vobject nobj = (Vobject) newobj;
nobj.set__stored_in_document(true);
Field fd = null;
try {
if (nobj.isRegisterable()) {
// look for the id field (should be an NCName string)
nobj.__vorba = vorbafactory;
nobj.set__stored_in_document(true);
Field fd = null;
try {
if (nobj.isRegisterable()) {
// look for the id field (should be an NCName string)
nobj.__vorba = vorbafactory;
- fd = nobj.getClass().getField("id");
+ fd = nobj.getClass().getDeclaredField("_id");
String idstring;
if (fd.get(nobj) != null) {
idstring = (String) fd.get(nobj);
String idstring;
if (fd.get(nobj) != null) {
idstring = (String) fd.get(nobj);
@@
-140,7
+146,7
@@
public class VorbaXmlBinder implements UnmarshalListener {
sync=false; // document is out of sync - ids have been created.
java.util.Iterator newobj = unrefed.listIterator();
while (newobj.hasNext()) {
sync=false; // document is out of sync - ids have been created.
java.util.Iterator newobj = unrefed.listIterator();
while (newobj.hasNext()) {
- object o = (object) newobj.next();
+ Vobject o = (Vobject) newobj.next();
// forces registration and id field update.
VorbaId id = o.getVorbaId();
if (!objrefs.containsKey(id)) {
// forces registration and id field update.
VorbaId id = o.getVorbaId();
if (!objrefs.containsKey(id)) {
@@
-153,9
+159,9
@@
public class VorbaXmlBinder implements UnmarshalListener {
return sync;
}
/**
return sync;
}
/**
- * Unmarshals a vamsasDocument object from a stream, registers
+ * Unmarshals a vamsasDocument Vobject from a stream, registers
* unregistered objects, records existing VorbaIds, and completes
* unregistered objects, records existing VorbaIds, and completes
- * the org.vamsas.client.object housekeeping fields.
+ * the org.vamsas.client.Vobject housekeeping fields.
* For a valid unmarshalling, the array of returned objects also includes
* a <return>sync</return> parameter which is true if new VorbaIds
* were created. If sync is false, then the caller should ensure that the
* For a valid unmarshalling, the array of returned objects also includes
* a <return>sync</return> parameter which is true if new VorbaIds
* were created. If sync is false, then the caller should ensure that the
@@
-163,11
+169,11
@@
public class VorbaXmlBinder implements UnmarshalListener {
* TODO: ensure that provenance is correct for newly registered objects
* @param instream - the XML input stream
* @param factory - the SimpleClient's properly configured VorbaId factory to make new references.
* TODO: ensure that provenance is correct for newly registered objects
* @param instream - the XML input stream
* @param factory - the SimpleClient's properly configured VorbaId factory to make new references.
- * @param root the root element's org.vamsas.objects.core object.
- * @return null or {(Object) VamsasDocument object, (Object) Hashtable of object references, (Object) Boolean(sync) }
+ * @param root the root element's org.vamsas.objects.core Vobject.
+ * @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of Vobject references, (Object) Boolean(sync) }
*/
public static Object[] getVamsasObjects(Reader instream,
*/
public static Object[] getVamsasObjects(Reader instream,
- IVorbaIdFactory factory, object root) {
+ IVorbaIdFactory factory, Vobject root) {
Unmarshaller unmarshaller = new Unmarshaller(root);
unmarshaller.setIDResolver(new IDResolver() {
public Object resolve(String id) {
Unmarshaller unmarshaller = new Unmarshaller(root);
unmarshaller.setIDResolver(new IDResolver() {
public Object resolve(String id) {
@@
-187,7
+193,7
@@
public class VorbaXmlBinder implements UnmarshalListener {
while (instream.ready()) {
Object obj = unmarshaller.unmarshal(instream);
boolean sync=ensure_references(unrefed, objrefs);
while (instream.ready()) {
Object obj = unmarshaller.unmarshal(instream);
boolean sync=ensure_references(unrefed, objrefs);
- if (!(obj instanceof object))
+ if (!(obj instanceof Vobject))
return null;
return new Object[] { obj, objrefs, new Boolean(sync)};
}
return null;
return new Object[] { obj, objrefs, new Boolean(sync)};
}