- return null;
- }
- protected SimpleDocument vorba = null;
-
- /**
- * @return Returns the current VorbaIdFactory for the archive.
- */
- public VorbaIdFactory getVorba() {
- if (vorba==null)
- vorba = new SimpleDocument("simpleclient.VamsasArchive");
- return vorba.getVorba();
- }
-
- /**
- * @param vorba the VorbaIdFactory to use for accessing vamsas objects.
- */
- public void setVorba(VorbaIdFactory Vorba) {
- if (Vorba!=null) {
- if (vorba==null)
- vorba = new SimpleDocument(Vorba);
- else
- vorba.setVorba(Vorba);
- } else
- getVorba();
- }
-
- /**
- * Access and return current vamsas Document, if it exists, or create a new one
- * (without affecting VamsasArchive object state - so is NOT THREAD SAFE)
- * TODO: possibly modify internal state to lock low-level files
- * (like the IClientDocument interface instance constructer would do)
- * @see org.vamsas.simpleclient.VamsasArchive.getOriginalVamsasDocument for additional caveats
- *
- * @return
- * @throws IOException
- * @throws org.exolab.castor.xml.MarshalException
- * @throws org.exolab.castor.xml.ValidationException
- */
- private VamsasDocument _doc=null;
- public VamsasDocument getVamsasDocument() throws IOException,
- org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- if (_doc!=null)
- return _doc;
- _doc = getOriginalVamsasDocument(this, getVorba());
- if (_doc!=null)
- return _doc;
- // Create a new document and return it
- _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS()},
- ProvenanceStuff.newProvenance("org.vamsas.simpleclient.VamsasArchive", "Created new empty document")
- , VersionEntries.latestVersion());
- return _doc;
- }
- /**
- * Access the original vamsas document for a VamsasArchive class, and return it.
- * Users of the VamsasArchive class should use the getVamsasDocument method to retrieve
- * the current document - only use this one if you want the 'backup' version.
- * TODO: catch OutOfMemoryError - they are likely to occur here.
- * NOTE: vamsas.xml datastreams are constructed as 'ALPHA_VERSION' vamsas documents.
- * @param ths
- * @return null if no document exists.
- * @throws IOException
- * @throws org.exolab.castor.xml.MarshalException
- * @throws org.exolab.castor.xml.ValidationException
- */
- public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths) throws IOException,
- org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- return VamsasArchive.getOriginalVamsasDocument(ths, null);
- }
-
- /**
- * Uses VorbaXmlBinder to retrieve the VamsasDocument from the original archive referred to by ths
- * @param ths
- * @param vorba
- * @return
- * @throws IOException
- * @throws org.exolab.castor.xml.MarshalException
- * @throws org.exolab.castor.xml.ValidationException
- */
- public static VamsasDocument getOriginalVamsasDocument(VamsasArchive ths, VorbaIdFactory vorba) throws IOException,
- org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- VamsasArchiveReader oReader = ths.getOriginalArchiveReader();
- if (oReader!=null) {
- ths.setVorba(vorba);
- return ths.vorba.getVamsasDocument(oReader);
- }
- // otherwise - there was no valid original document to read.
- return null;
- }
-
- public void putVamsasDocument(VamsasDocument doc) throws IOException,
- org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- putVamsasDocument(doc, getVorba());
- }
- public void putVamsasDocument(VamsasDocument doc, VorbaIdFactory vorba) throws IOException,
- org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
- VorbaXmlBinder.putVamsasDocument(getDocumentOutputStream(), vorba, doc);