uk.ac.vamsas.client
Class VorbaXmlBinder
java.lang.Object
uk.ac.vamsas.client.VorbaXmlBinder
- All Implemented Interfaces:
- org.exolab.castor.xml.UnmarshalListener
- public class VorbaXmlBinder
- extends java.lang.Object
- implements org.exolab.castor.xml.UnmarshalListener
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 add automatically computed
values for required fields in objects, so as to avoid validation exceptions
when marshalling new objects into the vamsas document.
Constructor Summary |
VorbaXmlBinder(IVorbaIdFactory vorbafactory2,
java.util.Vector unrefedObj,
java.util.Hashtable objrefs2,
java.util.Hashtable oldobjhashes,
java.util.Vector updatedObj)
|
Method Summary |
void |
attributesProcessed(java.lang.Object object)
|
void |
fieldAdded(java.lang.String fieldName,
java.lang.Object parent,
java.lang.Object child)
|
static java.lang.Object[] |
getVamsasObjects(java.io.Reader instream,
VorbaIdFactory factory,
Vobject root)
Unmarshals a vamsasDocument Vobject from a stream, registers unregistered
objects, records existing VorbaIds, and completes the
uk.ac.vamsas.client.Vobject housekeeping fields. |
void |
initialized(java.lang.Object object)
|
static void |
putVamsasDocument(java.io.PrintWriter outstream,
VorbaIdFactory vorba,
VamsasDocument doc)
writes the VamsasDocument to the given stream. |
void |
unmarshalled(java.lang.Object newobj)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
VorbaXmlBinder
public VorbaXmlBinder(IVorbaIdFactory vorbafactory2,
java.util.Vector unrefedObj,
java.util.Hashtable objrefs2,
java.util.Hashtable oldobjhashes,
java.util.Vector updatedObj)
attributesProcessed
public void attributesProcessed(java.lang.Object object)
- Specified by:
attributesProcessed
in interface org.exolab.castor.xml.UnmarshalListener
fieldAdded
public void fieldAdded(java.lang.String fieldName,
java.lang.Object parent,
java.lang.Object child)
- Specified by:
fieldAdded
in interface org.exolab.castor.xml.UnmarshalListener
initialized
public void initialized(java.lang.Object object)
- Specified by:
initialized
in interface org.exolab.castor.xml.UnmarshalListener
unmarshalled
public void unmarshalled(java.lang.Object newobj)
- Specified by:
unmarshalled
in interface org.exolab.castor.xml.UnmarshalListener
putVamsasDocument
public static void putVamsasDocument(java.io.PrintWriter outstream,
VorbaIdFactory vorba,
VamsasDocument doc)
throws java.io.IOException,
org.exolab.castor.xml.MarshalException,
org.exolab.castor.xml.ValidationException
- writes the VamsasDocument to the given stream. TODO: ensure that (at least)
default provenance entries are written for objects.
- Parameters:
outstream
- vorba
- valid VorbaIdFactory to construct any missing IDsdoc
-
- Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
getVamsasObjects
public static java.lang.Object[] getVamsasObjects(java.io.Reader instream,
VorbaIdFactory factory,
Vobject root)
- Unmarshals a vamsasDocument Vobject from a stream, registers unregistered
objects, records existing VorbaIds, and completes the
uk.ac.vamsas.client.Vobject housekeeping fields. For a valid unmarshalling,
the array of returned objects also includes a sync
parameter which is true if new VorbaIds were created. If sync is false,
then the caller should ensure that the vamsasDocument is written back to
disk to propagate the new VorbaIds. TODO: ensure that provenance is correct
for newly registered objects as getVamsasObjects but will detect updated
objects based on differing hash values obtained from the VorbaIdFactory's
VorbaId, Vobject.get__last_Hash() pairs (if any)
- Parameters:
instream
- - the XML input streamfactory
- - the SimpleClient's properly configured VorbaId factory to make
new references.root
- the root element's uk.ac.vamsas.objects.core Vobject.
- Returns:
- null or {(Object) VamsasDocument Vobject, (Object) Hashtable of
Vobject references, (Object) Boolean(sync), (Object) Vector of
updated objects in document }