From e15b38a5b95e0aa5b11707728abb539c073fe27c Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 14 Dec 2006 17:42:54 +0000 Subject: [PATCH] backtrack git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@264 be28352e-c001-0410-b1a7-c7978e42abec --- src/org/vamsas/client/ClientDocument.java | 52 + src/org/vamsas/client/ClientHandle.java | 97 ++ src/org/vamsas/client/Events.java | 92 ++ src/org/vamsas/client/IClient.java | 142 +++ src/org/vamsas/client/IClientAppdata.java | 61 ++ src/org/vamsas/client/IClientDocument.java | 99 ++ src/org/vamsas/client/IClientFactory.java | 56 + src/org/vamsas/client/IObjectUpdate.java | 26 + src/org/vamsas/client/IVorbaIdFactory.java | 37 + src/org/vamsas/client/Iapp.java | 12 + .../vamsas/client/InvalidSessionUrnException.java | 38 + .../vamsas/client/NoDefaultSessionException.java | 46 + src/org/vamsas/client/SessionHandle.java | 38 + src/org/vamsas/client/SessionUrn.java | 40 + src/org/vamsas/client/UserHandle.java | 50 + src/org/vamsas/client/Vobject.java | 464 +++++++++ src/org/vamsas/client/Vobjhash.java | 25 + src/org/vamsas/client/VorbaId.java | 73 ++ src/org/vamsas/client/VorbaIdFactory.java | 84 ++ src/org/vamsas/client/VorbaXmlBinder.java | 241 +++++ src/org/vamsas/client/picking/PickEndPoint.java | 101 ++ src/org/vamsas/client/picking/PickManager.java | 147 +++ src/org/vamsas/client/picking/PickServer.java | 83 ++ src/org/vamsas/client/picking/TestApp.java | 33 + .../client/simpleclient/AppDataInputStream.java | 53 + .../client/simpleclient/AppDataOutputStream.java | 86 ++ src/org/vamsas/client/simpleclient/ArchiveUrn.java | 34 + .../vamsas/client/simpleclient/ClientDocument.java | 510 +++++++++ .../vamsas/client/simpleclient/ClientsFile.java | 295 ++++++ .../client/simpleclient/EventGeneratorThread.java | 277 +++++ src/org/vamsas/client/simpleclient/FileLock.java | 205 ++++ .../vamsas/client/simpleclient/FileWatcher.java | 168 +++ src/org/vamsas/client/simpleclient/IdFactory.java | 159 +++ src/org/vamsas/client/simpleclient/ListFile.java | 25 + src/org/vamsas/client/simpleclient/Lock.java | 96 ++ .../vamsas/client/simpleclient/LockFactory.java | 52 + .../client/simpleclient/LockTimeoutException.java | 29 + .../simpleclient/LockedFileOutputStream.java | 159 +++ src/org/vamsas/client/simpleclient/NativeLock.java | 173 ++++ .../vamsas/client/simpleclient/SessionFile.java | 215 ++++ .../client/simpleclient/SessionFlagFile.java | 85 ++ src/org/vamsas/client/simpleclient/SessionUrn.java | 40 + .../vamsas/client/simpleclient/SessionsFile.java | 342 ++++++ .../vamsas/client/simpleclient/SimpleClient.java | 416 ++++++++ .../client/simpleclient/SimpleClientAppdata.java | 543 ++++++++++ .../client/simpleclient/SimpleClientFactory.java | 262 +++++ .../client/simpleclient/SimpleDocBinding.java | 138 +++ .../vamsas/client/simpleclient/SimpleDocument.java | 28 + .../vamsas/client/simpleclient/VamsasArchive.java | 809 +++++++++++++++ .../client/simpleclient/VamsasArchiveReader.java | 313 ++++++ src/org/vamsas/client/simpleclient/VamsasFile.java | 100 ++ .../vamsas/client/simpleclient/VamsasSession.java | 312 ++++++ src/org/vamsas/objects/core/.castor.cdr | 3 + src/org/vamsas/objects/core/Alignment.java | 979 ++++++++++++++++++ .../vamsas/objects/core/AlignmentAnnotation.java | 249 +++++ .../core/AlignmentAnnotationDescriptor.java | 255 +++++ .../vamsas/objects/core/AlignmentDescriptor.java | 503 +++++++++ src/org/vamsas/objects/core/AlignmentSequence.java | 385 +++++++ .../objects/core/AlignmentSequenceAnnotation.java | 256 +++++ .../AlignmentSequenceAnnotationDescriptor.java | 255 +++++ .../objects/core/AlignmentSequenceDescriptor.java | 282 +++++ src/org/vamsas/objects/core/AnnotationElement.java | 673 ++++++++++++ .../objects/core/AnnotationElementDescriptor.java | 405 ++++++++ src/org/vamsas/objects/core/AppData.java | 239 +++++ src/org/vamsas/objects/core/AppDataDescriptor.java | 250 +++++ src/org/vamsas/objects/core/ApplicationData.java | 572 ++++++++++ .../objects/core/ApplicationDataDescriptor.java | 359 +++++++ src/org/vamsas/objects/core/Attachment.java | 330 ++++++ .../vamsas/objects/core/AttachmentDescriptor.java | 325 ++++++ src/org/vamsas/objects/core/Common.java | 141 +++ src/org/vamsas/objects/core/CommonDescriptor.java | 167 +++ src/org/vamsas/objects/core/DataSet.java | 850 +++++++++++++++ .../vamsas/objects/core/DataSetAnnotations.java | 217 ++++ .../objects/core/DataSetAnnotationsDescriptor.java | 249 +++++ src/org/vamsas/objects/core/DataSetDescriptor.java | 385 +++++++ src/org/vamsas/objects/core/DbRef.java | 806 +++++++++++++++ src/org/vamsas/objects/core/DbRefDescriptor.java | 430 ++++++++ src/org/vamsas/objects/core/Entry.java | 803 ++++++++++++++ src/org/vamsas/objects/core/EntryDescriptor.java | 471 +++++++++ src/org/vamsas/objects/core/Glyph.java | 233 +++++ src/org/vamsas/objects/core/GlyphDescriptor.java | 244 +++++ src/org/vamsas/objects/core/Input.java | 219 ++++ src/org/vamsas/objects/core/InputDescriptor.java | 247 +++++ src/org/vamsas/objects/core/Instance.java | 179 ++++ .../vamsas/objects/core/InstanceDescriptor.java | 213 ++++ src/org/vamsas/objects/core/Link.java | 217 ++++ src/org/vamsas/objects/core/LinkDescriptor.java | 240 +++++ src/org/vamsas/objects/core/LockFile.java | 182 ++++ .../vamsas/objects/core/LockFileDescriptor.java | 207 ++++ src/org/vamsas/objects/core/Map.java | 151 +++ src/org/vamsas/objects/core/MapDescriptor.java | 167 +++ src/org/vamsas/objects/core/MapList.java | 404 ++++++++ src/org/vamsas/objects/core/MapListDescriptor.java | 339 ++++++ src/org/vamsas/objects/core/Mapping.java | 186 ++++ src/org/vamsas/objects/core/MappingDescriptor.java | 210 ++++ src/org/vamsas/objects/core/Newick.java | 288 ++++++ src/org/vamsas/objects/core/NewickDescriptor.java | 315 ++++++ src/org/vamsas/objects/core/Param.java | 261 +++++ src/org/vamsas/objects/core/ParamDescriptor.java | 285 +++++ src/org/vamsas/objects/core/Pos.java | 204 ++++ src/org/vamsas/objects/core/PosDescriptor.java | 213 ++++ src/org/vamsas/objects/core/Property.java | 261 +++++ .../vamsas/objects/core/PropertyDescriptor.java | 285 +++++ src/org/vamsas/objects/core/Provenance.java | 306 ++++++ .../vamsas/objects/core/ProvenanceDescriptor.java | 210 ++++ src/org/vamsas/objects/core/RangeAnnotation.java | 1093 ++++++++++++++++++++ .../objects/core/RangeAnnotationDescriptor.java | 578 +++++++++++ src/org/vamsas/objects/core/RangeType.java | 452 ++++++++ .../vamsas/objects/core/RangeTypeDescriptor.java | 246 +++++ src/org/vamsas/objects/core/Score.java | 240 +++++ src/org/vamsas/objects/core/ScoreDescriptor.java | 249 +++++ src/org/vamsas/objects/core/Seg.java | 331 ++++++ src/org/vamsas/objects/core/SegDescriptor.java | 297 ++++++ src/org/vamsas/objects/core/Sequence.java | 387 +++++++ .../vamsas/objects/core/SequenceDescriptor.java | 285 +++++ src/org/vamsas/objects/core/SequenceType.java | 677 ++++++++++++ .../objects/core/SequenceTypeDescriptor.java | 446 ++++++++ src/org/vamsas/objects/core/Tree.java | 600 +++++++++++ src/org/vamsas/objects/core/TreeDescriptor.java | 390 +++++++ src/org/vamsas/objects/core/User.java | 212 ++++ src/org/vamsas/objects/core/UserDescriptor.java | 252 +++++ src/org/vamsas/objects/core/VAMSAS.java | 535 ++++++++++ src/org/vamsas/objects/core/VAMSASDescriptor.java | 315 ++++++ src/org/vamsas/objects/core/VamsasDocument.java | 725 +++++++++++++ .../objects/core/VamsasDocumentDescriptor.java | 388 +++++++ src/org/vamsas/objects/utils/AppDataReference.java | 160 +++ src/org/vamsas/objects/utils/DocumentStuff.java | 34 + src/org/vamsas/objects/utils/Format.java | 612 +++++++++++ src/org/vamsas/objects/utils/GlyphDictionary.java | 23 + src/org/vamsas/objects/utils/ProvenanceStuff.java | 45 + src/org/vamsas/objects/utils/Seq.java | 131 +++ src/org/vamsas/objects/utils/SeqAln.java | 238 +++++ src/org/vamsas/objects/utils/SeqSet.java | 138 +++ src/org/vamsas/objects/utils/SymbolDictionary.java | 19 + .../objects/utils/document/VersionEntries.java | 49 + src/org/vamsas/test/ExampleApplication.java | 160 +++ src/org/vamsas/test/objects/Core.java | 81 ++ .../vamsas/test/simpleclient/ArchiveClient.java | 292 ++++++ .../vamsas/test/simpleclient/ArchiveReader.java | 50 + .../vamsas/test/simpleclient/ArchiveReports.java | 186 ++++ .../test/simpleclient/ArchiveStreamReader.java | 52 + .../vamsas/test/simpleclient/ArchiveWatcher.java | 105 ++ .../vamsas/test/simpleclient/ArchiveWriter.java | 180 ++++ src/org/vamsas/test/simpleclient/ClientDoc.java | 355 +++++++ .../vamsas/test/simpleclient/ClientsFileTest.java | 310 ++++++ .../vamsas/test/simpleclient/CommandProcessor.java | 65 ++ .../vamsas/test/simpleclient/VamsasArchive.java | 205 ++++ .../test/simpleclient/simpleapp/VamsasClient.java | 186 ++++ .../simpleclient/simpleapp/VamsasDatastore.java | 333 ++++++ 149 files changed, 37873 insertions(+) create mode 100644 src/org/vamsas/client/ClientDocument.java create mode 100644 src/org/vamsas/client/ClientHandle.java create mode 100644 src/org/vamsas/client/Events.java create mode 100644 src/org/vamsas/client/IClient.java create mode 100644 src/org/vamsas/client/IClientAppdata.java create mode 100644 src/org/vamsas/client/IClientDocument.java create mode 100644 src/org/vamsas/client/IClientFactory.java create mode 100644 src/org/vamsas/client/IObjectUpdate.java create mode 100644 src/org/vamsas/client/IVorbaIdFactory.java create mode 100644 src/org/vamsas/client/Iapp.java create mode 100644 src/org/vamsas/client/InvalidSessionUrnException.java create mode 100644 src/org/vamsas/client/NoDefaultSessionException.java create mode 100644 src/org/vamsas/client/SessionHandle.java create mode 100644 src/org/vamsas/client/SessionUrn.java create mode 100644 src/org/vamsas/client/UserHandle.java create mode 100644 src/org/vamsas/client/Vobject.java create mode 100644 src/org/vamsas/client/Vobjhash.java create mode 100644 src/org/vamsas/client/VorbaId.java create mode 100644 src/org/vamsas/client/VorbaIdFactory.java create mode 100644 src/org/vamsas/client/VorbaXmlBinder.java create mode 100644 src/org/vamsas/client/picking/PickEndPoint.java create mode 100644 src/org/vamsas/client/picking/PickManager.java create mode 100644 src/org/vamsas/client/picking/PickServer.java create mode 100644 src/org/vamsas/client/picking/TestApp.java create mode 100644 src/org/vamsas/client/simpleclient/AppDataInputStream.java create mode 100644 src/org/vamsas/client/simpleclient/AppDataOutputStream.java create mode 100644 src/org/vamsas/client/simpleclient/ArchiveUrn.java create mode 100644 src/org/vamsas/client/simpleclient/ClientDocument.java create mode 100644 src/org/vamsas/client/simpleclient/ClientsFile.java create mode 100644 src/org/vamsas/client/simpleclient/EventGeneratorThread.java create mode 100644 src/org/vamsas/client/simpleclient/FileLock.java create mode 100644 src/org/vamsas/client/simpleclient/FileWatcher.java create mode 100644 src/org/vamsas/client/simpleclient/IdFactory.java create mode 100644 src/org/vamsas/client/simpleclient/ListFile.java create mode 100644 src/org/vamsas/client/simpleclient/Lock.java create mode 100644 src/org/vamsas/client/simpleclient/LockFactory.java create mode 100644 src/org/vamsas/client/simpleclient/LockTimeoutException.java create mode 100644 src/org/vamsas/client/simpleclient/LockedFileOutputStream.java create mode 100644 src/org/vamsas/client/simpleclient/NativeLock.java create mode 100644 src/org/vamsas/client/simpleclient/SessionFile.java create mode 100644 src/org/vamsas/client/simpleclient/SessionFlagFile.java create mode 100644 src/org/vamsas/client/simpleclient/SessionUrn.java create mode 100644 src/org/vamsas/client/simpleclient/SessionsFile.java create mode 100644 src/org/vamsas/client/simpleclient/SimpleClient.java create mode 100644 src/org/vamsas/client/simpleclient/SimpleClientAppdata.java create mode 100644 src/org/vamsas/client/simpleclient/SimpleClientFactory.java create mode 100644 src/org/vamsas/client/simpleclient/SimpleDocBinding.java create mode 100644 src/org/vamsas/client/simpleclient/SimpleDocument.java create mode 100644 src/org/vamsas/client/simpleclient/VamsasArchive.java create mode 100644 src/org/vamsas/client/simpleclient/VamsasArchiveReader.java create mode 100644 src/org/vamsas/client/simpleclient/VamsasFile.java create mode 100644 src/org/vamsas/client/simpleclient/VamsasSession.java create mode 100644 src/org/vamsas/objects/core/.castor.cdr create mode 100644 src/org/vamsas/objects/core/Alignment.java create mode 100644 src/org/vamsas/objects/core/AlignmentAnnotation.java create mode 100644 src/org/vamsas/objects/core/AlignmentAnnotationDescriptor.java create mode 100644 src/org/vamsas/objects/core/AlignmentDescriptor.java create mode 100644 src/org/vamsas/objects/core/AlignmentSequence.java create mode 100644 src/org/vamsas/objects/core/AlignmentSequenceAnnotation.java create mode 100644 src/org/vamsas/objects/core/AlignmentSequenceAnnotationDescriptor.java create mode 100644 src/org/vamsas/objects/core/AlignmentSequenceDescriptor.java create mode 100644 src/org/vamsas/objects/core/AnnotationElement.java create mode 100644 src/org/vamsas/objects/core/AnnotationElementDescriptor.java create mode 100644 src/org/vamsas/objects/core/AppData.java create mode 100644 src/org/vamsas/objects/core/AppDataDescriptor.java create mode 100644 src/org/vamsas/objects/core/ApplicationData.java create mode 100644 src/org/vamsas/objects/core/ApplicationDataDescriptor.java create mode 100644 src/org/vamsas/objects/core/Attachment.java create mode 100644 src/org/vamsas/objects/core/AttachmentDescriptor.java create mode 100644 src/org/vamsas/objects/core/Common.java create mode 100644 src/org/vamsas/objects/core/CommonDescriptor.java create mode 100644 src/org/vamsas/objects/core/DataSet.java create mode 100644 src/org/vamsas/objects/core/DataSetAnnotations.java create mode 100644 src/org/vamsas/objects/core/DataSetAnnotationsDescriptor.java create mode 100644 src/org/vamsas/objects/core/DataSetDescriptor.java create mode 100644 src/org/vamsas/objects/core/DbRef.java create mode 100644 src/org/vamsas/objects/core/DbRefDescriptor.java create mode 100644 src/org/vamsas/objects/core/Entry.java create mode 100644 src/org/vamsas/objects/core/EntryDescriptor.java create mode 100644 src/org/vamsas/objects/core/Glyph.java create mode 100644 src/org/vamsas/objects/core/GlyphDescriptor.java create mode 100644 src/org/vamsas/objects/core/Input.java create mode 100644 src/org/vamsas/objects/core/InputDescriptor.java create mode 100644 src/org/vamsas/objects/core/Instance.java create mode 100644 src/org/vamsas/objects/core/InstanceDescriptor.java create mode 100644 src/org/vamsas/objects/core/Link.java create mode 100644 src/org/vamsas/objects/core/LinkDescriptor.java create mode 100644 src/org/vamsas/objects/core/LockFile.java create mode 100644 src/org/vamsas/objects/core/LockFileDescriptor.java create mode 100644 src/org/vamsas/objects/core/Map.java create mode 100644 src/org/vamsas/objects/core/MapDescriptor.java create mode 100644 src/org/vamsas/objects/core/MapList.java create mode 100644 src/org/vamsas/objects/core/MapListDescriptor.java create mode 100644 src/org/vamsas/objects/core/Mapping.java create mode 100644 src/org/vamsas/objects/core/MappingDescriptor.java create mode 100644 src/org/vamsas/objects/core/Newick.java create mode 100644 src/org/vamsas/objects/core/NewickDescriptor.java create mode 100644 src/org/vamsas/objects/core/Param.java create mode 100644 src/org/vamsas/objects/core/ParamDescriptor.java create mode 100644 src/org/vamsas/objects/core/Pos.java create mode 100644 src/org/vamsas/objects/core/PosDescriptor.java create mode 100644 src/org/vamsas/objects/core/Property.java create mode 100644 src/org/vamsas/objects/core/PropertyDescriptor.java create mode 100644 src/org/vamsas/objects/core/Provenance.java create mode 100644 src/org/vamsas/objects/core/ProvenanceDescriptor.java create mode 100644 src/org/vamsas/objects/core/RangeAnnotation.java create mode 100644 src/org/vamsas/objects/core/RangeAnnotationDescriptor.java create mode 100644 src/org/vamsas/objects/core/RangeType.java create mode 100644 src/org/vamsas/objects/core/RangeTypeDescriptor.java create mode 100644 src/org/vamsas/objects/core/Score.java create mode 100644 src/org/vamsas/objects/core/ScoreDescriptor.java create mode 100644 src/org/vamsas/objects/core/Seg.java create mode 100644 src/org/vamsas/objects/core/SegDescriptor.java create mode 100644 src/org/vamsas/objects/core/Sequence.java create mode 100644 src/org/vamsas/objects/core/SequenceDescriptor.java create mode 100644 src/org/vamsas/objects/core/SequenceType.java create mode 100644 src/org/vamsas/objects/core/SequenceTypeDescriptor.java create mode 100644 src/org/vamsas/objects/core/Tree.java create mode 100644 src/org/vamsas/objects/core/TreeDescriptor.java create mode 100644 src/org/vamsas/objects/core/User.java create mode 100644 src/org/vamsas/objects/core/UserDescriptor.java create mode 100644 src/org/vamsas/objects/core/VAMSAS.java create mode 100644 src/org/vamsas/objects/core/VAMSASDescriptor.java create mode 100644 src/org/vamsas/objects/core/VamsasDocument.java create mode 100644 src/org/vamsas/objects/core/VamsasDocumentDescriptor.java create mode 100644 src/org/vamsas/objects/utils/AppDataReference.java create mode 100644 src/org/vamsas/objects/utils/DocumentStuff.java create mode 100644 src/org/vamsas/objects/utils/Format.java create mode 100644 src/org/vamsas/objects/utils/GlyphDictionary.java create mode 100644 src/org/vamsas/objects/utils/ProvenanceStuff.java create mode 100644 src/org/vamsas/objects/utils/Seq.java create mode 100644 src/org/vamsas/objects/utils/SeqAln.java create mode 100644 src/org/vamsas/objects/utils/SeqSet.java create mode 100644 src/org/vamsas/objects/utils/SymbolDictionary.java create mode 100644 src/org/vamsas/objects/utils/document/VersionEntries.java create mode 100644 src/org/vamsas/test/ExampleApplication.java create mode 100644 src/org/vamsas/test/objects/Core.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveClient.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveReader.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveReports.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveStreamReader.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveWatcher.java create mode 100644 src/org/vamsas/test/simpleclient/ArchiveWriter.java create mode 100644 src/org/vamsas/test/simpleclient/ClientDoc.java create mode 100644 src/org/vamsas/test/simpleclient/ClientsFileTest.java create mode 100644 src/org/vamsas/test/simpleclient/CommandProcessor.java create mode 100644 src/org/vamsas/test/simpleclient/VamsasArchive.java create mode 100644 src/org/vamsas/test/simpleclient/simpleapp/VamsasClient.java create mode 100644 src/org/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java diff --git a/src/org/vamsas/client/ClientDocument.java b/src/org/vamsas/client/ClientDocument.java new file mode 100644 index 0000000..3866a90 --- /dev/null +++ b/src/org/vamsas/client/ClientDocument.java @@ -0,0 +1,52 @@ +/* + * + */ +package org.vamsas.client; + +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.objects.core.VAMSAS; + +/** + * skeleton abstract class to allow client implementations + * access to vamsas.client.Vobject registry mechanism. + */ +public abstract class ClientDocument implements IClientDocument { + static Log log = LogFactory.getLog(ClientDocument.class); + + /** + * collection of org.vamsas.client.Vobject references + */ + protected Hashtable vamsasObjects; + protected IVorbaIdFactory vorbafactory; + + protected ClientDocument(Hashtable objects, IVorbaIdFactory factory) { + vamsasObjects = objects; + vorbafactory = factory; + } + + /** + * @see IClientHandle.registerObject(Vobject unregistered) + */ + protected VorbaId _registerObject(Vobject unregistered) { + // be ultra safe here because the user may be trying to mix different factories + if (unregistered.__vorba==null) + unregistered.__vorba = vorbafactory; + else + if (unregistered.__vorba!=vorbafactory) { + // LATER: decide if this is allowed - it isn't for the moment. + log.error("Attempt to overwrite info in a registered vorba Vobject (under a different IVorbaIdFactory) ! - Implementation fix needed."); + return null; + } else { + // probably didn't need to call registerObject. + log.debug("Redundant call to registerObject"); + } + // TODO: add default provenance. + // TODO: decide if we need to do call __ensure_instance_ids here + // TODO: check if __ensure_instance_ids works correctly with new 'visit flag' mechanism + unregistered.__ensure_instance_ids(); // call cascade method here : + return unregistered.getVorbaId(); + } +} diff --git a/src/org/vamsas/client/ClientHandle.java b/src/org/vamsas/client/ClientHandle.java new file mode 100644 index 0000000..76666f9 --- /dev/null +++ b/src/org/vamsas/client/ClientHandle.java @@ -0,0 +1,97 @@ +/* + */ +package org.vamsas.client; + +import java.io.Serializable; + +/** + * Uniquely describes a vamsas client application. + * @author jimp + */ +public class ClientHandle implements Serializable { + static final long serialVersionUID = 0; + /** + * @param clientName + * @param version + */ + public ClientHandle(String clientName, String version) { + super(); + this.clientName = clientName; + this.version = version; + this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: decide on application handle ornthing (used to prefix new ids made by a particular application) + } + /** + * (non-unique) human readable vamsas client name + */ + String clientName; + + /** + * the unambiguous client identifier + * This may be rewritten by the Vorba object if + * other clients with the same name, version + * and user are involved in a session. + * + */ + String clientUrn; + + /** + * version modifier to tag application space + */ + String version; + + /** + * @return Returns the clientUrn. + */ + public String getClientUrn() { + return clientUrn; + } + + /** + * May become protected - should only be set by a Vorba object. + * @param clientUrn + * The clientUrn to set. + */ + public void setClientUrn(String clientUrn) { + this.clientUrn = clientUrn; + } + + /** + * @return Returns the version. + */ + public String getVersion() { + return version; + } + + /** + * @param version + * The version to set. + */ + public void setVersion(String version) { + this.version = version; + } + + + /** + * @return Returns the clientName. + */ + public String getClientName() { + return clientName; + } + + /** + * @param clientName + * The clientName to set. + */ + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public boolean equals(Object that) { + if (that instanceof ClientHandle) + return this.equals((ClientHandle) that); + return false; + } + public boolean equals(ClientHandle that) { + return (clientName.equals(that.clientName) && version.equals(that.version) && clientUrn.equals(that.clientUrn)); + } +} diff --git a/src/org/vamsas/client/Events.java b/src/org/vamsas/client/Events.java new file mode 100644 index 0000000..4a91f5a --- /dev/null +++ b/src/org/vamsas/client/Events.java @@ -0,0 +1,92 @@ +package org.vamsas.client; + +/** + * Enumerates the event types generated during the lifecycle of a Vamsas + * session. + * See the excel spreadsheet in VamsasClient/docs/VamsasSessionEventAnalysis.xls for + * some more information about when these are generated and how they should be + * handled. + * + */ + +public class Events { + /** + * Generated when a client has finished updating the document. + * Client which has completed an update should + * not receive the event. + * NewValue: org.vamsas.client.IClient for session. + */ + public static final String DOCUMENT_UPDATE = "org.vamsas.client.events.documentUpdateEvent"; + + /** + * Generated when a new vamsas document is created (perhaps from some existing + * Vamsas data) so an application may do its own data space initialization. + * Raised for a new application connecting to a vamsas document + * NewValue: org.vamsas.client.IClient for session. + * LATER: DOCUMENT_CREATE event may be redundant + */ + public static final String DOCUMENT_CREATE = "org.vamsas.client.events.documentCreateEvent"; + + /** + * Generated when a new vamsas client is attached to a session (Handle is + * passed) Note: the newly created client does not receive the event. + */ + public static final String CLIENT_CREATION = "org.vamsas.client.events.clientCreateEvent"; + + /** + * Generated when a vamsas client leaves a session (Handle is passed to all + * others). + */ + public static final String CLIENT_FINALIZATION = "org.vamsas.client.events.clientFinalizationEvent"; + + /** + * Generated prior to session Shutdown, after the last participating vamsas + * client has finalized. + * Probably only useful to IClientFactory implementations. + * NewValue: + */ + public static final String SESSION_SHUTDOWN = "org.vamsas.client.events.SessionShutdownEvent"; + + /** + * Generated for all clients when any client calls IClient.storeDocument() to + * allow them to store any updates before an offline copy of the session is + * created. + * Any client that handles this should call the + * IClient.getDocument(), update and then IClient.updateDocument in the same + * handler thread (the lock on the document is held until the handler exits). + * EventName: + * NewValue: org.vamsas.client.IClient for session. + */ + public static final String DOCUMENT_FINALIZEAPPDATA = "org.vamsas.client.events.DocumentFinalizeAppData"; + + /** + * Generated by Vorba stub for the sole remaining client instance in a session, + * when it makes a call to finalizeClient(). + * It is only raised if the session has been modified since the + * last call to storeDocument() by any application. + * LATER: copies of a document should be on a per-user basis for multi-user sessions. + * Sequence is as follows : 1. All other vamsas clients have + * called finalizeClient() 2. Final living client monitors closures, and + * realises that it is last. 3. Final client generates event to prompt + * associated application to inquire if the user wishes to save the document + * for future reference. + * * Any call to finalizeClient in a thread other than the registered + * EventListener will block until the RequestToClose handler has exited. + * NewValue: org.vamsas.client.IClient for session. + */ + public static final String DOCUMENT_REQUESTTOCLOSE = "org.vamas.client.DocumentRequestToCloseEvent"; + + public static java.util.Vector EventList = initList(); + + private static java.util.Vector initList() { + java.util.Vector vec = new java.util.Vector(); + vec.add((Object) DOCUMENT_UPDATE); + vec.add((Object) DOCUMENT_CREATE); + vec.add((Object) CLIENT_CREATION); + vec.add((Object) CLIENT_FINALIZATION); + vec.add((Object) SESSION_SHUTDOWN); + vec.add((Object) DOCUMENT_REQUESTTOCLOSE); + vec.add((Object) DOCUMENT_FINALIZEAPPDATA); + return vec; + } +} diff --git a/src/org/vamsas/client/IClient.java b/src/org/vamsas/client/IClient.java new file mode 100644 index 0000000..aaf855f --- /dev/null +++ b/src/org/vamsas/client/IClient.java @@ -0,0 +1,142 @@ +/** + * org.vamsas.client.IClient + * + */ +package org.vamsas.client; + +import java.beans.PropertyChangeListener; +import java.io.IOException; + +/** + * Defines the methods availabable to a vamsas + * application for interacting with its Vorba agent + * created by an IClientFactory instance for a particular session, + * user, and application handle. + * (it's VORBA, not CORBA!) + * LATER: add exceptions for timeouts raised when there are problems accessing session data (because another application is hogging it). + * LATER: think about situations when two applications both want a ClientDocument at the same time - can one have read-only access (and be told that another is about to update) + */ + +public interface IClient { + + /** + * Self-documenting/describing info for the application to present + * to the user. + * LATER: formalise this for describing VAMSAS system, a particular + * Vorba client agent, and a particular session. + * @return string like VamsasClient v.1.1.1 (GPL) and whatever + */ + public String getAbout(); + + /** + * convenience method to get the SessionUrn as a string (for passing directly to a text box...). + * @return current SessionUrn + */ + public String getSessionUrn(); + /** + * Returns a valid URN for other applications to connect to + * the vamsas session. + * @return session handle for this session. + */ + public SessionHandle getSessionHandle(); + /** + * Included for applications with several ClientHandle + * identities. + * @return ClientHandle used to interact with + * other Vamsas applications. + */ + public ClientHandle getClientHandle(); + /** + * + * @return UserHandle used when interacting + * with other Vamsas applications. + */ + public UserHandle getUserHandle(); + /** + * Method called by client application on exit. + * Vorba will inform other clients if they exist. + * If this is the last application in the session + * then the session will be closed. + * Note: The application should be ready to handle + * 'RequestToCloseDocument' events from the Vorba + * agent in the latter case and so prompt the user + * to save the session locally. + * LATER: pick a better name ? + */ + public void finalizeClient(); + /** + * register handler for updates for the current session + */ + public void addDocumentUpdateHandler(PropertyChangeListener evt); + /** + * get vamsas document with + * user and app specific data + * IClientDocuments are not thread-safe. + * TODO: New exception for failed document lock. + * @throws IOException if lock is not obtainable for the document in the session + */ + public IClientDocument getClientDocument() throws IOException; + /** + * Queue new Vorba objects for storage and propagation + * to other clients (via Event.DOCUMENT_UPDATE based + * notification of document change) + * New objects without provenance information will be + * given a default entry using the IClient's application, + * user (and session) handles + * Validity of IClientDocument object instances after this call is implementation dependent + * TODO: consider refactoring to remove the redundant IClientDocument parameter for this method + */ + public void updateDocument(IClientDocument newdoc); + /** + * Any application may call storeDocument to + * save a local copy of the current vamsas document + * including all application specific entries. + * + * @param location to write zip file + */ + public void storeDocument(java.io.File location); + /** + * Any application may call importDocument to merge a stored + * vamsasDocument into the current session. + * Note: use a IClientFactory's implementation to make sessions out of vamsas documnts + * LATER: VAMSAS: The IClient implementation will handle all ID 'relocations' + * @param location + */ + public void importDocument(java.io.File location); + /** + * Add a listener to a particular event chain. + * See org.vamsas.client.Events for allowed + * values for EventChain. + * The EventChain value is passed as the + * propertyName in the java.bean.PropertyChangeEvent + * LATER: extend class to form own vamsas Event/Listener model. + * @param EventChain Name of event. Blank/null registers handler for all events. + * @param evt - event handler function. + */ + public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt); + /** + * Sets the update handler that will be called when any updates occur to objects of type rootObject. + * @param rootObject + * @param handler + */ + public void setUpdateHandler(IObjectUpdate handler); + public IObjectUpdate getUpdateHandler(Class rootObject); + public void removeUpdateHandler(Class rootObject); + public IObjectUpdate[] getUpdateHandlers(); + /** + * client application calls this to force the + * Vorba client to check for updates immediately. + * + */ + public void pollUpdate(); + + /** + * Client application calls this after any pre-session initialization + * (registering of Handlers, etc) + * Exceptions are raised for any failures. Any stateful calls to the session prior to + * this will result in an implicit call to joinSession - if that results in an exception + * then the VamsasClient should raise an Error. + * LATER: create VAMSAS exception hierarchy (in a language agnostic manner) + */ + public void joinSession() throws Exception; +} diff --git a/src/org/vamsas/client/IClientAppdata.java b/src/org/vamsas/client/IClientAppdata.java new file mode 100644 index 0000000..965a783 --- /dev/null +++ b/src/org/vamsas/client/IClientAppdata.java @@ -0,0 +1,61 @@ +/** + * + */ +package org.vamsas.client; + +import java.io.DataInput; +import java.io.DataOutput; + +/** + * Object for accessing Client and User specific data + * in an IClientDocument instance. + * + */ +public interface IClientAppdata { + /** + * @return true if Client's non-user specific application data is non-zero length. + */ + boolean hasClientAppdata(); + /** + * @return true if User's Client Application data is non-zero length + */ + boolean hasUserAppdata(); + /** + * + * @return byte array containing the Client's non-user specific application data + */ + byte[] getClientAppdata(); + /** + * + * @return byte array containing the Client's user specific application data + */ + byte[] getUserAppdata(); + /** + * set the non-User-specific application data + * @param data - the new non-user-specific data + */ + void setClientAppdata(byte[] data); + /** + * set the User-specific application data + * @param data - the new user-specific data + */ + void setUserAppdata(byte[] data); + /** + * @return non-user specific data output stream + */ + DataOutput getClientOutputStream(); + /** + * @return non-user specific data input stream + */ + DataInput getClientInputStream(); + /** + * + * @return user specific data output stream + */ + DataOutput getUserOutputStream(); + /** + * + * @return user specific data input stream + */ + DataInput getUserInputStream(); +} diff --git a/src/org/vamsas/client/IClientDocument.java b/src/org/vamsas/client/IClientDocument.java new file mode 100644 index 0000000..8db697f --- /dev/null +++ b/src/org/vamsas/client/IClientDocument.java @@ -0,0 +1,99 @@ +/* + * Created on 13-Sep-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.client; + +import org.vamsas.objects.core.VAMSAS; + + +/** + * Defines the API for the Vamsas XML Document + * as accessed by a Vamsas SimpleClient Application. + * An instance of this interface is valid for a + * particular set of user, session and application + * handles. + * + * It initially represents a snapshot of the + * XML document at a particular time - queriable by + * reference or by retrieval of root objects. + * It provides methods to make new Vobject references, + * These are guaranteed to be unique amongst existing + * objects in the document, all other references created + * by this Vobject's instance and all other references + * constructed by any other vamsas agents in the session. + * TODO: LATER: finegrained access control for public/private user access + * Finegrained access control: Since a clientDocument is created for a particular + * UserHandle, there is scope for fine grain data access + * control based on user identity. + * A user may also want to make private notes, not + * available to other people using the same application + * in the same session. + * TODO: LATER: implement a more sophisticated query interface for quickly identifying new data in a vamsas document and manipulating existing objects + * @author jimp + */ +public interface IClientDocument { + + /** + * Get a single Vobject. + * @param id + * @return Vobject referred to by id or null if it doesn't exist. + */ + Vobject getObject(VorbaId id); + /** + * Get a list of objects. + * @param ids + * @return array of objects using a vector of VorbaId ids. + */ + Vobject[] getObjects(VorbaId[] ids); + /** + * Returns all root objects in document. All objects inherit + * from org.vamsas.client.Vobject and have valid VorbaIds and provenance entries. + * @return array of root Vamsas element objects. + */ + VAMSAS[] getVamsasRoots(); + /** + * set the VAMSAS roots in the document + * TODO: decide if objects are verified for provenance and VorbaIds by this call or when document is stored + * TODO: decide if this call should throw InvalidVamsasObject exceptions. + * TODO: decide how this call deals with applications that 'forget' to include all VAMSAS roots (this is where reference counting/garbage collection happens) + * @param roots + */ + void setVamsasRoots(VAMSAS[] roots); + /** + * Adds a new VAMSAS root entry + * TODO: decide on same InvalidVamsasObject exceptions. + * TODO: decide if a 'removeVamsasRoot' method is really needed. + * @param newroot + */ + void addVamsasRoot(VAMSAS newroot); + /** + * Returns an Vobject with a valid VorbaId, and provenance element. + * The VorbaId is so the application may refer to it in + * its own dataspace. + * + * Note: An Vobject with valid VorbaId will not be reregistered. + * Advice: Calling this method for a high-level Vobject + * (such as org.vamsas.objects.core.VAMSAS) will + * register all its component objects too. + * + * @param unregistered unregistered vamsas Vobject + * @return VorbaId registered for vamsas Vobject + */ + VorbaId registerObject(Vobject unregistered); + /** + * Returns an array of objects, each with a valid VorbaId + * (and completed provenance entry). + * Note: An Vobject with valid VorbaId will not be reregistered. + * @param unregistered array of unregistered objects. + * @return array of VorbaIds for the registered objects + */ + VorbaId[] registerObjects(Vobject[] unregistered); + /** + * Get instance of Client and User specific vamsas document data access interface. + * @return Interface to Client and user specific application data + */ + IClientAppdata getClientAppdata(); +} \ No newline at end of file diff --git a/src/org/vamsas/client/IClientFactory.java b/src/org/vamsas/client/IClientFactory.java new file mode 100644 index 0000000..f9a50b4 --- /dev/null +++ b/src/org/vamsas/client/IClientFactory.java @@ -0,0 +1,56 @@ +/* + * Created on 13-Sep-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.client; + +/** + * Defines methods for instantiating Vorba client application agents + * @author jimp + * + * (it's VORBA, not CORBA!) + */ + +public interface IClientFactory { + + /** + * Create a new Vorba Session + * @param applicationHandle is the application's VAMSAS handle string + * @throws NoDefaultSessionException if more than one session exists that the client may connect to + */ + IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException; + /** + * returns new Vorba for a given session. + * @param applicationHandle + * @param sessionUrn session to connect to (or null to create a new session) + * @return + */ + IClient getIClient(ClientHandle applicationHandle, String sessionUrn); + /** + * returns new vorba for a given session acting as a particular identity + * @param applicationHandle + * @param userId + * @param sessionUrn session to connect to (or null to create a new session) + * @return + */ + IClient getIClient(ClientHandle applicationHandle, UserHandle userId, String sessionUrn); + /** + * New session for application and specific user + * @param applicationHandle + * @param userId + * @return + * @throws NoDefaultSessionException if more than one session exists that the client may connect to + */ + IClient getIClient(ClientHandle applicationHandle, UserHandle userId) throws NoDefaultSessionException; + + /** + * enumerate the active sessions this IClientFactory instance knows about. + * Can be used by caller to pick a session on catching a NoDefaultSessionException. + * LATER: Define interface for discovering more information about a session (so it can be presented to a user in a meaningful way) + * @return possibly empty array of sessionUrn strings + */ + public String[] getCurrentSessions(); + +} diff --git a/src/org/vamsas/client/IObjectUpdate.java b/src/org/vamsas/client/IObjectUpdate.java new file mode 100644 index 0000000..cda754d --- /dev/null +++ b/src/org/vamsas/client/IObjectUpdate.java @@ -0,0 +1,26 @@ +package org.vamsas.client; + +/** + * Methods implemented by a Vamsas Application's Object Update handler + * @author vamsas + * Introduced November 2006 Vamsas Meeting + * TODO: verify this is sufficient for the per-object update event mechanism + */ +public interface IObjectUpdate { + /** + * Called by the library to find out which vamsas document object this update handler is interested in + * @return class that extends org.vamsas.Vobject + */ + Class getRootVobject(); + /** + * Called to test if this handler is to be called for updates to any Vobjects below the Root Vobject in the vamsas document. + * @return false means IObjectUpdate.update(updated, cdoc) will only be called with instances of type getRootVobject(). + */ + boolean handlesSubtreeUpdates(); + /** + * Method called by Vamsas Client Library for all updated objects that the handler is registered for. + * @param updated + * @param cdoc + */ + void update(org.vamsas.client.Vobject updated, org.vamsas.client.IClientDocument cdoc); +} diff --git a/src/org/vamsas/client/IVorbaIdFactory.java b/src/org/vamsas/client/IVorbaIdFactory.java new file mode 100644 index 0000000..ea25e8e --- /dev/null +++ b/src/org/vamsas/client/IVorbaIdFactory.java @@ -0,0 +1,37 @@ +/* + * Created on 14-Sep-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.client; + +/** + * @author jimp + * middleware interface for generating new VorbaId objects + * for a particular vamsas client based on the current + * session, user and client handle. Generally implemented + * by instances of the vamsas library api only. + */ +public interface IVorbaIdFactory { + /** + * construct a new id appropriate for this client in the vamsas session. + * @param vobject TODO + * + * @return valid VorbaId for session, or null if VorbaIdFactory not configured + * correctly. + */ + public abstract VorbaId makeVorbaId(Vobject vobject); + + public abstract SessionHandle getSessionHandle(); + + public abstract ClientHandle getClientHandle(); + + public abstract UserHandle getUserHandle(); + /** + * called when an object is touched by the vamsas library prior to writing + * to record last hash for the object's VorbaId + * @param vobject + */ + public abstract void updateHashValue(Vobject vobject); +} \ No newline at end of file diff --git a/src/org/vamsas/client/Iapp.java b/src/org/vamsas/client/Iapp.java new file mode 100644 index 0000000..381e22b --- /dev/null +++ b/src/org/vamsas/client/Iapp.java @@ -0,0 +1,12 @@ +/** + * org.vamsas.client.Iapp + */ +package org.vamsas.client; +public interface Iapp { + /** + * Define core callback functionality that a fully + * fledged vamsas application Vobject must implement + * TODO: define some Application Callbacks and create use cases for them + */ + +}; diff --git a/src/org/vamsas/client/InvalidSessionUrnException.java b/src/org/vamsas/client/InvalidSessionUrnException.java new file mode 100644 index 0000000..d1863a8 --- /dev/null +++ b/src/org/vamsas/client/InvalidSessionUrnException.java @@ -0,0 +1,38 @@ +package org.vamsas.client; + +public class InvalidSessionUrnException extends Exception { + + /** + * + */ + public InvalidSessionUrnException() { + super("Invalid Vamsas Session URN."); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public InvalidSessionUrnException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + + /** + * @param message + */ + public InvalidSessionUrnException(String message) { + super("Invalid Vamsas Session URN: "+message); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public InvalidSessionUrnException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/org/vamsas/client/NoDefaultSessionException.java b/src/org/vamsas/client/NoDefaultSessionException.java new file mode 100644 index 0000000..bfee0e6 --- /dev/null +++ b/src/org/vamsas/client/NoDefaultSessionException.java @@ -0,0 +1,46 @@ +/** + * + */ +package org.vamsas.client; + +/** + * @author jimp + * Raised if an IClient instance is requested without + * specifying a particular vamsas session handle + * when more than one candidate session exists. + */ +public class NoDefaultSessionException extends Exception { + + /** + * + */ + public NoDefaultSessionException() { + super("No Default Session Defined"); + } + + /** + * @param message + */ + public NoDefaultSessionException(String message) { + super(message); + // TODO Auto-generated constructor stub + } + + /** + * @param cause + */ + public NoDefaultSessionException(Throwable cause) { + super(cause); + // TODO Auto-generated constructor stub + } + + /** + * @param message + * @param cause + */ + public NoDefaultSessionException(String message, Throwable cause) { + super(message, cause); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/org/vamsas/client/SessionHandle.java b/src/org/vamsas/client/SessionHandle.java new file mode 100644 index 0000000..736fee3 --- /dev/null +++ b/src/org/vamsas/client/SessionHandle.java @@ -0,0 +1,38 @@ +/* + * Created on 12-Sep-2005 + * + */ +package org.vamsas.client; + +/** + * Uniquely locates a particular VAMSAS session. + * @author jimp + * + */ +public class SessionHandle { + + /** + * @param sessionUrn + */ + public SessionHandle(String sessionUrn) { + super(); + SessionUrn = sessionUrn; + } + /** + * @return Returns the sessionUrn. + */ + public String getSessionUrn() { + return SessionUrn; + } + /** + * @param sessionUrn The sessionUrn to set. + */ + public void setSessionUrn(String sessionUrn) { + SessionUrn = sessionUrn; + } + /** + * The path to the vamsas session file. + */ + String SessionUrn; + +} diff --git a/src/org/vamsas/client/SessionUrn.java b/src/org/vamsas/client/SessionUrn.java new file mode 100644 index 0000000..4eff113 --- /dev/null +++ b/src/org/vamsas/client/SessionUrn.java @@ -0,0 +1,40 @@ +/** + * + */ +package org.vamsas.client; + +import java.net.URI; +import java.util.Hashtable; +import java.util.Vector; + +/** + * @author jimp + * base class for vamsas session/document types + * uses java.net.URI internally for construction of URN + */ +public abstract class SessionUrn { + protected URI urn; + /** + * The types of URI protocols we understand + */ + protected static final Hashtable TYPES=new Hashtable(); + + /** + * construct urn for a locally stored session file + * @param type + * @param url + */ + protected SessionUrn(String type, java.net.URL url) { + if (!TYPES.containsKey(type.toLowerCase())) + throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'"); + try { + urn = URI.create(type+"://"+url.getPath()); + } catch (Exception e) { + // TODO: something better than throwing an error should be done here. + throw new Error(e); + } + } + public String getSessionUrn() { + return urn.toString(); + } +} diff --git a/src/org/vamsas/client/UserHandle.java b/src/org/vamsas/client/UserHandle.java new file mode 100644 index 0000000..8bfe16c --- /dev/null +++ b/src/org/vamsas/client/UserHandle.java @@ -0,0 +1,50 @@ +/* + * Created on 12-Sep-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.client; + +/** + * Unique user identifier for a vamsas session. + * Used to write user provenance information, and + * track view/access control in multiuser sessions. + * @author jimp + */ +public class UserHandle { + /** + * @param fullName + * @param organization + */ + public UserHandle(String fullName, String organization) { + this.fullName = fullName; + Organization = organization; + } + String fullName; + String Organization; + /** + * @return Returns the fullName. + */ + public String getFullName() { + return fullName; + } + /** + * @param fullName The fullName to set. + */ + public void setFullName(String fullname) { + fullName = fullname; + } + /** + * @return Returns the organization. + */ + public String getOrganization() { + return Organization; + } + /** + * @param organization The organization to set. + */ + public void setOrganization(String organization) { + Organization = organization; + } +} diff --git a/src/org/vamsas/client/Vobject.java b/src/org/vamsas/client/Vobject.java new file mode 100644 index 0000000..d7bd6eb --- /dev/null +++ b/src/org/vamsas/client/Vobject.java @@ -0,0 +1,464 @@ +/** + * + */ +package org.vamsas.client; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Iterator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.mapping.FieldDescriptor; +import org.exolab.castor.mapping.FieldHandler; +import org.exolab.castor.xml.util.XMLClassDescriptorImpl; +import org.vamsas.test.simpleclient.VamsasArchive; + +/** + * Base class for all Vamsas objects extracted from an IClientDocument. An + * Vobject maybe registered or unregistered. + * + * @author jimp + * + */ +public abstract class Vobject { + static Log log = LogFactory.getLog(Vobject.class); + + /** + * true if Vobject was stored in a vamsas Document or has been retrieved from it + */ + protected boolean __stored_in_document = false; + /** + * true if Vobject was updated since the vamsas library last read a Vobj with the same VorbaId from a document. + */ + protected boolean __updated_since_last_read = false; + /** + * memory of the last doHash() value computed for the Vobject + * @see doHash() + */ + protected int __last_hash = 0; + /** + * set by testInstanceForIdField() if Vobject should have a VorbaId + */ + protected boolean registerable = false; + protected boolean __visited = false; + /** + * reference to containing object for this Vobject. + */ + protected Vobject V_parent=null; + /** + * unique id for all vamsas objects allows unambiguous referencing to any + * Vobject in the vamsas document + */ + protected VorbaId vorbaId = null; + + /** + * the source of unique VorbaIds. + */ + protected IVorbaIdFactory __vorba = null; + + /* (non-Javadoc) + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + V_parent=null; + __vorba=null; + vorbaId=null; + super.finalize(); + } + + /** + * + */ + protected Vobject() { + super(); + testInstanceForIdField(); + } + java.lang.reflect.Field ___id_field=null; // set to ease pain of reflection + /** + * set the isRegisterable flag based on the presence of a 'private String _id' field in + * the reflected class instance. + */ + private void testInstanceForIdField() { + // TODO: decide if 'id' is an appropriate reserved attribute name for the VorbaId + // look for the id field in all castor classes (should be an NCName string) + + Class thisclass=this.getClass(); + setRegisterable(false); + while (!thisclass.equals(Vobject.class)) { + try { + java.lang.reflect.Field fd = thisclass.getDeclaredField("_id"); + if (String.class.isAssignableFrom(fd.getType())) { + ___id_field=fd; + this.setRegisterable(true); + break; + } + } catch (SecurityException e) { + log.error("Unexpected Security Exception whilst finding id fields to set!",e); + } catch (NoSuchFieldException e) { + thisclass=thisclass.getSuperclass(); + } + } + } + // boolean __testedInstance=false; + /** + * update the Vobject instance's _id field, based on the contents of the + * VorbaId. Only call this if you mean to do it! + */ + protected void setInstanceIdField() { + /*if (!registerable && !__testedInstance) { + testInstanceForIdField(); + __testedInstance=true; + }*/ + if (registerable) { + if (__vorba != null) + try { + Method fd = this.getClass().getMethod("setId", new Class[] { String.class }); + fd.invoke((Object) this, new Object[] {new String(this.getVorbaId().id)}); + log.debug(this.getClass().getName()+" called setInstanceIdField!"); + } catch (InvocationTargetException e) { + log.error("SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e); + } + catch (IllegalAccessException e) { + log.error("SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'setId' method!\nCannot set ID from the vorbaId Vobject.", e); + } catch (SecurityException e) { + log.error("Security access violation for "+this.getClass().toString(),e); + } catch (NoSuchMethodException e) { + log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)"); + this.setRegisterable(false); + } + } else { + System.err.println("Client error. Trying to setInstanceIdField on a " + + this.getClass().toString() + " (which cannot be given a vorbaId)"); + } + } + + protected String __getInstanceIdField() { + /*if (!registerable && !__testedInstance) { + testInstanceForIdField(); + __testedInstance=true; + }*/ + if (registerable) { + if (__vorba != null) + try { + Method fd = this.getClass().getMethod("getId", (Class[]) null); + Object idstring = fd.invoke((Object) this, (Object[]) null); + log.debug(this.getClass().getName()+" called getInstanceIdField!"); + if (idstring!=null && idstring instanceof String) { + if (((String) idstring).length()>0) + return (String) idstring; + } + } catch (InvocationTargetException e) { + log.error("SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e); + } + catch (IllegalAccessException e) { + log.error("SourceGeneration of " + + this.getClass().toString() + + "\n has resulted in an inaccessible 'getId' method!\nCannot set ID from the vorbaId Vobject.", e); + } catch (SecurityException e) { + log.error("Security access violation for "+this.getClass().toString(),e); + } catch (NoSuchMethodException e) { + log.warn(this.getClass().toString()+" was erroneously marked as a Vorba Vobject class (Implementation error?)"); + this.setRegisterable(false); + } + } else { + System.err.println("Client error. Trying to getInstanceIdField on a " + + this.getClass().toString() + " (which cannot be given a vorbaId)"); + } + return null; + } + + /** + * calculate a hash for the Vobject with all housekeeping fields at standard + * values. (isRegisterable is an immutable attribute property) + * TODO: decide if __stored_in_document should be included in the hash or not. + * @return true if new hash different to last hash + */ + synchronized protected boolean doHash() { + long __old_hash = __last_hash; + __last_hash = 0; + Vobject _V_parent=V_parent; + V_parent=null; + VorbaId thisid = vorbaId; + IVorbaIdFactory factory = __vorba; + boolean stored = __stored_in_document; + boolean updated = __updated_since_last_read; + boolean visited = __visited; + java.lang.reflect.Field idfield = ___id_field; + ___id_field=null; + __updated_since_last_read=false; + vorbaId = null; + __vorba = null; + __visited=false; + // compute hash + __last_hash = this.hashCode(); + // reset houseskeeping variables + ___id_field=idfield; + vorbaId = thisid; + __vorba = factory; + __stored_in_document = stored; + __updated_since_last_read=updated; + V_parent=_V_parent; + __visited=visited; + return (__old_hash==0) || (__old_hash == __last_hash); + } + + /** + * TODO: combine two versions of the same collection Vobject to resolve + * asynchronous updates to the same vamsas Vobject Merges two vamsas objects, + * one of which is a later version of the earlier (ie they have the same + * vorbaId but one is a later version recently read from the vamsasDocument + * collection. + * + * @return + */ + protected boolean merge(Vobject laterCopy) { + log.warn(this.getClass().getName()+".merge() not implemented."); + return true; + } + + /** + * + * @return true if Vobject is registered + */ + public boolean isRegistered() { + return (registerable) ? (vorbaId != null) : false; + } + + /** + * Method to get fixed reference for the Vobject in the vamsas document. + * + * @returns null if Vobject is neither registered or not associated with a + * properly instantiated VorbaIdFactory. + */ + public VorbaId getVorbaId() { + if (registerable && vorbaId == null) { + if (this.__stored_in_document) { + if (__vorba!=null) + vorbaId=org.vamsas.client.VorbaId.newId(this.__getInstanceIdField()); + } + // Try to use the associated factory. + if (__vorba != null) + if ((vorbaId = __vorba.makeVorbaId(this)) == null) + return null; // Factory not valid. + else { + this.setInstanceIdField(); + return vorbaId; + } + } + return vorbaId; + } + + /** + * used by the IClient implementation to generate unique Id based on client + * applications current namespace. + */ + protected void setVorbaId(VorbaId newid) { + vorbaId = newid; + } + + /** + * @return true if Vobject is present in Vamsas Document. + */ + public boolean is__stored_in_document() { + return __stored_in_document; + } + + /** + * @return true if this object has been updated in the currently stored document since the last time a Vobject with the same ID was read from a Vamsas Document + */ + public boolean is__updated_since_last_read() { + return __updated_since_last_read; + } + + /** + * Set internal flag to indicate this object was updated since the last document read + * @param __updated_since_last_read the __updated_since_last_read to set + */ + protected void set__updated_since_last_read(boolean __updated_since_last_read) { + this.__updated_since_last_read = __updated_since_last_read; + } + + /** + * for use by Vorba agent to reflect state of vamsas Vobject to client + * application. + * Setting stored_in_document on a registerable Vobject without a + * vorbaId will mean is will *never* get a vorbaId and + * horrible things will happen. + * @param __stored_in_document true if Vobject has been marshalled into current document. + */ + protected void set__stored_in_document(boolean __stored_in_document) { + this.__stored_in_document = __stored_in_document; + } + + /** + * __last_hash is the hash value computed when the Vobject was last checked + * against a IClientDocument generated by the Vobject's parent IClient + * instance. + * + * @return Returns the __last_hash. + */ + public int get__last_hash() { + return __last_hash; + } + + /** + * @return true if Vobject can have a vorbaId + */ + public boolean isRegisterable() { + return registerable; + } + + /** + * Called by __testInstanceForidField and the post-unmarshalling handler + * to indicate if Vobject will have a vorbaId. + * @param registerable + */ + protected void setRegisterable(boolean registerable) { + this.registerable = registerable; + } + /** + * ensure's internal id field corresponds to vorbaId and + * cascade through all fields referring to an instance of Vobject + * calling the same method on them. + * TODO: LATER: properly apply castors own field mechanisms to get at accessors + * TODO: FIX CYCLIC __ensure+instance_ids + * Implementation note for the todo: + * this works like a depth-first search over all vamsas objects in an vamsasDocument. + * __visited is the visited flag, any Vobj who's flag is of a different parity + * to the visited argument will be recursed on. + * note - the doHash() function used to be used as the 'visited' flag - + * this *is not* a valid heuristic, although it will work "most of the time". + * TODO: LATER? Add another method for setDefaultProvenanceField (in the spirit of setInstanceIdField) using the info from the __vorba.getClient/User/Session methods + */ + protected void __ensure_instance_ids() { + __ensure_instance_ids(!__visited); + } + protected void __ensure_instance_ids(boolean visited) { + if (__vorba==null) + throw new Error("Improperly intialised org.vamsas.client.Vobject - no VorbaFactory given."); + log.debug("doing "+this.getClass()+".__ensure_instance_ids()"); + if (!__stored_in_document && registerable) + setInstanceIdField(); + if (__visited==visited) + return; + __visited=visited; + __vorba.updateHashValue(this); + + Class descriptor = null; + XMLClassDescriptorImpl descimpl = null; + try { + // castor descriptor resolver magic + descriptor = this.getClass().getClassLoader().loadClass(this.getClass().getName()+"Descriptor"); + descimpl = (XMLClassDescriptorImpl) descriptor.getConstructor((Class[])null).newInstance((Object[])null); + } catch (Exception e) { + log.fatal("Source Generation Error!: Couldn't resolve descriptor for " + +this.getClass().getName() + +" was 'generate descriptors' set for castorbuilder.properties?"); + return; + } + FieldDescriptor fields[] = descimpl.getFields(); + for (int i=0,j=fields.length; i 0) { + nobj.setVorbaId(VorbaId.newId(idstring)); + if (objrefs.containsKey(nobj_id=nobj.getVorbaId()) && !objrefs.get(nobj.getVorbaId()).equals(nobj)) { + System.err.println("Serious problem : duplicate id '"+idstring+"' found! expect badness."); + // TODO: HANDLE duplicate XML ids correctly + } + objrefs.put(nobj_id, nobj); + } else { + // add to list of objects without a valid vorbaId + obj.add(nobj); + } + } else { + // TODO: add to list of objects without a valid vorbaId + obj.add(nobj); + } + + nobj.doHash(); + // check to see if new object was present in old object hash + if (oldobjhashes.containsKey(nobj.getVorbaId())) { + Vobjhash oldhash = (Vobjhash) oldobjhashes.get(nobj.getVorbaId()); + 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); + } + } + } + } catch (Exception e) { + return; + }; + + } + } + + /** + * writes the VamsasDocument to the given stream. + * TODO: ensure that (at least) default provenance entries are written for objects. + * @param outstream + * @param vorba valid VorbaIdFactory to construct any missing IDs + * @param doc + * @throws IOException + * @throws MarshalException + * @throws ValidationException + */ + public static void putVamsasDocument(PrintWriter outstream, VorbaIdFactory vorba, VamsasDocument doc) + throws IOException, MarshalException, ValidationException { + // Ensure references + if (vorba==null) + throw new Error("Null VorbaIdFactory Parameter"); + if (doc.__vorba==null) + doc.__vorba = vorba; + doc.__ensure_instance_ids(); // this may take a while. Do we allow for cyclic references ? + doc.marshal(outstream); + + } + /** + * creates new VorbaId references where necessary for newly unmarshalled objects + * @param unrefed + * @param objrefs + * @return false if any new object references were made + */ + private static boolean ensure_references(Vector unrefed, Hashtable objrefs) { + boolean sync=true; + if (unrefed.size()>0) { + sync=false; // document is out of sync - ids have been created. + java.util.Iterator newobj = unrefed.listIterator(); + while (newobj.hasNext()) { + Vobject o = (Vobject) newobj.next(); + // forces registration and id field update. + VorbaId id = o.getVorbaId(); + if (!objrefs.containsKey(id)) { + objrefs.put(id, o); + } else { + if (!objrefs.get(id).equals(o)) + throw new Error("Serious! Duplicate reference made by vorbaIdFactory!"); + } + } + } + return sync; + } + /** + * Unmarshals a vamsasDocument Vobject from a stream, registers + * unregistered objects, records existing VorbaIds, and completes + * the org.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) + * @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 Vobject. + * @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of Vobject references, (Object) Boolean(sync), (Object) Vector of updated objects in document } + */ + public static Object[] getVamsasObjects(Reader instream, + VorbaIdFactory factory, Vobject root) { + Unmarshaller unmarshaller = new Unmarshaller(root); + unmarshaller.setIDResolver(new IDResolver() { + public Object resolve(String id) { + VorbaXmlBinder.log.warn("Warning - id " + id + + " is not found in the Vamsas XML!"); + return null; + } + }); + final Hashtable objrefs = new Hashtable(); + if (factory.extanthashv==null) + factory.extanthashv=new Hashtable(); + final Hashtable oobjhashes=factory.extanthashv; + final VorbaIdFactory vorbafactory = factory; + final Vector unrefedObj = new Vector(); + final Vector updatedObj = new Vector(); + 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(instream); + boolean sync=ensure_references(unrefedObj, objrefs); + if (!(obj instanceof Vobject)) + return null; + vorbafactory.setNewIdHash(objrefs); // update the Document IO Handler's set of vorbaId<>Object bindings. + return new Object[] { obj, objrefs, new Boolean(sync),updatedObj}; + } + } catch (MarshalException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ValidationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/src/org/vamsas/client/picking/PickEndPoint.java b/src/org/vamsas/client/picking/PickEndPoint.java new file mode 100644 index 0000000..7a464f1 --- /dev/null +++ b/src/org/vamsas/client/picking/PickEndPoint.java @@ -0,0 +1,101 @@ +package org.vamsas.client.picking; + +import java.io.*; +import java.net.*; + +class PickEndPoint extends Thread +{ + private Socket socket; + private int rPort; + private BufferedWriter os; + private BufferedReader in; + + private PickManager manager; + + PickEndPoint(PickManager manager, Socket s) + { + this.manager = manager; + socket = s; + } + + boolean openConnection() + { + try + { + // Create the socket if it doesn't already exist + if (socket == null) + socket = new Socket(InetAddress.getLocalHost(), PickServer.PORT); + + rPort = socket.getPort(); + socket.setKeepAlive(true); + + // Open the streams for reading/writing + os = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); + in = new BufferedReader(new InputStreamReader(socket.getInputStream())); + + // Start the thread to listen for incoming messages + System.out.println("CLIENT: connection successful to port " + + socket.getPort() + " via port " + socket.getLocalPort()); + start(); + + return true; + } + catch (Exception e) + { + System.out.println("CLIENT: connection failed: " + e); + return false; + } + } + + void send(String str) + { + try + { + System.out.println("CLIENT: send " + str + " to " + rPort); + os.write(str); + + // We use a newline to terminate the message + os.newLine(); + os.flush(); + } + catch (Exception e) + { + System.out.println("CLIENT: failed to send"); + + // TODO: terminate the connection on a failed send or retry? + terminate(); + } + } + + // void receive() (threaded) + public void run() + { + try + { + while (true) + { + String str = in.readLine(); + System.out.println("CLIENT: recv " + str + " from " + rPort); + + manager.handleMessage(this, str); + } + } + catch (Exception e) + { + // Means the other end of the connection has (probably died) so we need + // terminate this endpoint (if this is server side) + System.out.println("CLIENT: read failed: " + e); + + terminate(); + } + } + + private void terminate() + { + try { socket.close(); } + catch (IOException e) {} + + System.out.println("CLIENT: closing connection to port " + socket.getPort()); + manager.removeEndPoint(this); + } +} \ No newline at end of file diff --git a/src/org/vamsas/client/picking/PickManager.java b/src/org/vamsas/client/picking/PickManager.java new file mode 100644 index 0000000..c313e25 --- /dev/null +++ b/src/org/vamsas/client/picking/PickManager.java @@ -0,0 +1,147 @@ +package org.vamsas.client.picking; + +import java.net.*; +import java.util.*; +import java.util.logging.*; + +/** + * Manager class that maintains a list of connected clients in addition to + * attempting to run a server to listen for client connections. If the server + * initialization fails, then an attempt to connect (as a client) to another JVM + * that is already a server happens instead. + */ +public class PickManager +{ + private static Logger logger = Logger.getLogger("org.vamsas.client.picking"); + + // Maintains a list of client communication objects - each object represents + // a way of talking to either: + // the server - if this is client side (and in which case, the list will only contain one element + // the other clients - if this is server side + private LinkedList clients; + + private PickServer server; + + /** + * Constructs a new PickManager. This method will return immediately, while + * a looping thread runs that attempts to run the server or connect to an + * existing server. + */ + public PickManager() + { + server = new PickServer(this); + clients = new LinkedList(); + + new InitializeThread().start(); + } + + /** + * Attempts to establish a connection between two client endpoints. This + * method is called in two ways: 1) by the server when it receives a remote + * request (in which case the socket will already be established) and 2) by + * a client that is attempting to connect *to* the server. + * @param socket a socket endpoint for the connection + * @return true if the connection is successfully, false otherwise + */ + boolean addEndPoint(Socket socket) + { + PickEndPoint client = new PickEndPoint(this, socket); + + if (client.openConnection()) + { + clients.add(client); + logger.fine("List now contains " + clients.size() + " client(s)"); + return true; + } + + return false; + } + + /** + * Sends a message to other clients. + * @param str the message to send + */ + public void sendMessage(String str) + { + forwardMessage(null, str); + } + + /** + * Forwards (or sends) a message. When the server (client A) receives a + * message from client B, it must also forward it to clients C and D (etc), + * but mustn't forward it *back* to client B. + * @param origin the client endpoint that received the message (will be null + * if the message originates from this instance + * @param str the message to send + */ + private void forwardMessage(PickEndPoint origin, String str) + { + ListIterator itor = clients.listIterator(); + while (itor.hasNext()) + { + PickEndPoint client = (PickEndPoint) itor.next(); + + if (client != origin) + client.send(str); + } + } + + /** + * Handles a received message. If the manager is running in server mode, + * then it must ensure the message is also forwarded to the other clients. + * @param origin the client endpoint that received the message + * @str the message that was received + */ + void handleMessage(PickEndPoint origin, String str) + { + if (server.isServer()) + forwardMessage(origin, str); + + // TODO: pass message to VAMSAS API + } + + /** + * Removes a client connection from the list when its connection is no + * longer valid. + * @param client the client endpoint to remove + */ + void removeEndPoint(PickEndPoint client) + { + clients.remove(client); + logger.fine("List now contains " + clients.size() + " client(s)"); + + // If there's no endpoints left, then we've lost all connections and + // need to reinitialize + if (clients.size() == 0) + new InitializeThread().start(); + } + + /** + * Thread extension class to handle the actual initialization + */ + private class InitializeThread extends Thread + { + public void run() + { + logger.fine("Initializing connection..."); + boolean connected = false; + + // Loop until we can get a connection (one way or the other) + while (!connected) + { + // Sleep for a rnd time so we don't end up with all the VAMSAS + // apps trying to initialize servers at the same time + try { Thread.sleep((int)Math.random()); } + catch (InterruptedException e) {} + + // Attempt to open the server port... + if (server.isServer() || server.createServer()) + connected = true; + + // If it fails, then attempt to make a client connection... + else if (addEndPoint(null)) + connected = true; + } + } + } +} \ No newline at end of file diff --git a/src/org/vamsas/client/picking/PickServer.java b/src/org/vamsas/client/picking/PickServer.java new file mode 100644 index 0000000..abef55e --- /dev/null +++ b/src/org/vamsas/client/picking/PickServer.java @@ -0,0 +1,83 @@ +package org.vamsas.client.picking; + +import java.io.*; +import java.net.*; +import java.util.logging.*; + +/** + * Server class that listens for incoming connections on a predefined port. + */ +class PickServer extends Thread +{ + private static Logger logger = Logger.getLogger("org.vamsas.client.picking"); + + // The port number we'll listen on + static final int PORT = 53782; + + private ServerSocket serverSocket; + // Set to true once the server is established + private boolean isServer = false; + + private PickManager manager; + + /** + * Constructs a new instance of the server (but doesn't start it). + * @param manager a reference to the pick manager that owns this server + */ + PickServer(PickManager manager) + { + this.manager = manager; + } + + /** + * Returns true if this server instance is running. + * Return true if this server instance is running + */ + boolean isServer() + { return isServer; } + + /** + * Attempts to create the server by opening a server socket on the port. + * @return true if the server was created; false otherwise + */ + boolean createServer() + { + try + { + serverSocket = new ServerSocket(PORT); + start(); + + return isServer = true; + } + catch (IOException e) + { + logger.info("SERVER: " + e); + return false; + } + } + + /** + * Thread listening method - loops indefinitely listening for connections. + * When one is received, the socket object is passed to the manager so it + * can make a full client connection for further comms. + */ + public void run() + { + logger.fine("SERVER: listening on " + PORT + " - SERVER"); + + // Loop forever, accepting connectons from other clients + // TODO: add in the ability to terminate the server if a VAMSAS session + // is ended + while (true) + { + try + { + Socket socket = serverSocket.accept(); + logger.fine("SERVER: connection detected"); + + manager.addEndPoint(socket); + } + catch (IOException e) {} + } + } +} \ No newline at end of file diff --git a/src/org/vamsas/client/picking/TestApp.java b/src/org/vamsas/client/picking/TestApp.java new file mode 100644 index 0000000..96924b5 --- /dev/null +++ b/src/org/vamsas/client/picking/TestApp.java @@ -0,0 +1,33 @@ +package org.vamsas.client.picking; + +import java.util.logging.*; + +public class TestApp +{ + private static Logger logger = Logger.getLogger("org.vamsas.client.picking"); + + public static void main(String[] args) + throws Exception + { +// logger.setLevel(Level.INFO); + + TestApp app = new TestApp(); + + PickManager manager = new PickManager(); + + // Send 5 test messages... +// for (int i = 0; i < 5; i++) + while (true) + { + try { Thread.sleep((int) (Math.random()*20000)); } + catch (InterruptedException e) {} + + int rnd = (int) (Math.random()*100); + manager.sendMessage("" + rnd); + } + } + + public TestApp() + { + } +} \ No newline at end of file diff --git a/src/org/vamsas/client/simpleclient/AppDataInputStream.java b/src/org/vamsas/client/simpleclient/AppDataInputStream.java new file mode 100644 index 0000000..0785ed6 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/AppDataInputStream.java @@ -0,0 +1,53 @@ +/** + * + */ +package org.vamsas.client.simpleclient; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.jar.JarInputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp + * LATER: this may not be a necessary or useful class to return from IClientAppdata get*InputStream() methods + */ +public class AppDataInputStream extends DataInputStream implements DataInput { + private Log log = LogFactory.getLog(AppDataInputStream.class); + private boolean isOpen = false; + /** + * Wrapper for writing to/from AppData Entries in a Vamsas Document. + */ + public AppDataInputStream(InputStream inputstream) { + super(inputstream); + isOpen=true; + } + + /* (non-Javadoc) + * @see java.io.FilterInputStream#close() + */ + public void close() throws IOException { + if (!isOpen) { + log.debug("close() called on closed AppDataInputStream."); + // throw new IOException("Attempt to close an already closed AppDataInputStream"); + } else { + isOpen=false; + } + } + + /** + * Will return zero if stream has been closed. + * @see java.io.FilterInputStream#available() + */ + public int available() throws IOException { + if (isOpen) + return super.available(); + else + return 0; + } + +} diff --git a/src/org/vamsas/client/simpleclient/AppDataOutputStream.java b/src/org/vamsas/client/simpleclient/AppDataOutputStream.java new file mode 100644 index 0000000..db13652 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/AppDataOutputStream.java @@ -0,0 +1,86 @@ +/** + * + */ +package org.vamsas.client.simpleclient; + +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author jimp + * + */ +public class AppDataOutputStream extends DataOutputStream { + private Log log = LogFactory.getLog(AppDataOutputStream.class); + private boolean isOpen=true; + /** + * @param out + */ + public AppDataOutputStream(OutputStream out) { + super(out); + isOpen=true; + } + /* (non-Javadoc) + * @see java.io.DataOutputStream#flush() + */ + public void flush() throws IOException { + if (isOpen) + super.flush(); + else + log.warn("flush() called on closed AppDataOutputStream"); + } + /* (non-Javadoc) + * @see java.io.DataOutputStream#write(byte[], int, int) + */ + public synchronized void write(byte[] b, int off, int len) throws IOException { + if (isOpen) { + super.write(b, off, len); + } else { + log.debug("write(b,off,len) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + /* (non-Javadoc) + * @see java.io.DataOutputStream#write(int) + */ + public synchronized void write(int b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + /** + * Sets an internal flag preventing further write operations + * to the AppData output stream and flushes any pending writes. + * @see java.io.FilterOutputStream#close() + */ + public void close() throws IOException { + isOpen=false; + super.flush(); + log.debug("AppDataOutputStream was closed."); + } + /* (non-Javadoc) + * @see java.io.FilterOutputStream#write(byte[]) + */ + public void write(byte[] b) throws IOException { + if (isOpen) { + super.write(b); + } else { + log.debug("write(b[]) called on closed AppDataOutputStream"); + throw new IOException("Attempt to write to closed AppDataOutputStream"); + } + } + /** + * @return true if stream is still Open. + */ + public boolean isOpen() { + return isOpen; + } + +} diff --git a/src/org/vamsas/client/simpleclient/ArchiveUrn.java b/src/org/vamsas/client/simpleclient/ArchiveUrn.java new file mode 100644 index 0000000..304e1f2 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/ArchiveUrn.java @@ -0,0 +1,34 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; +import java.net.MalformedURLException; + +/** + * Vamsas Document URN for files understood by ArchiveReader and + * written by VamsasArchive. + * vdoc://{Absolute path to file} + * @author jimp + * + */ +public class ArchiveUrn extends org.vamsas.client.SessionUrn { + /** + * a simple vamsas document urn prefix + */ + public static String VAMSASDOCUMENT="vdoc"; + static { + TYPES.put(ArchiveUrn.VAMSASDOCUMENT, ArchiveUrn.class); + } + + public ArchiveUrn(File docLocation) throws MalformedURLException { + super(VAMSASDOCUMENT, docLocation.getAbsoluteFile().toURL()); + } + + /** + * TODO: LATER: think about this again. + * @return File(urn.getPath()) + */ + public File asFile() { + return new File(urn.getPath()); + } + // TODO: add abstract 'handler' methods for resolving the URN to a particular class +} diff --git a/src/org/vamsas/client/simpleclient/ClientDocument.java b/src/org/vamsas/client/simpleclient/ClientDocument.java new file mode 100644 index 0000000..3b654f8 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/ClientDocument.java @@ -0,0 +1,510 @@ +/* + * + */ +package org.vamsas.client.simpleclient; + +import java.io.IOException; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.ClientHandle; +import org.vamsas.client.IClientAppdata; +import org.vamsas.client.IClientDocument; +import org.vamsas.client.UserHandle; +import org.vamsas.client.Vobject; +import org.vamsas.client.VorbaId; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.User; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.objects.utils.AppDataReference; +import org.vamsas.test.objects.Core; + +/** + * Maintains a collection of vamsas objects, appdatas and states, and provides api for a SimpleClient's client. + * @author jimp + */ +public class ClientDocument extends org.vamsas.client.ClientDocument implements IClientDocument { + private static Log log = LogFactory.getLog(ClientDocument.class); + private VamsasDocument doc; + protected SimpleClient sclient; + protected VamsasArchive archive = null; + /** + * indicate if new data has been incorporated + */ + private boolean isModified = false; + /** + * Public method for internal use by SimpleClient. + * @return true if document has been modified. + */ + public boolean isModified() { + return isModified; + } + private Vector updatedObjects=null; + /** + * + * prepare Application-side dataset from the vamsas Document archive + * @param doc - the dataset + * @param docHandler - the sessionFile IO handler + * @param Factory - the source of current and new vorbaIds + * @param sclient - the simpleclient instance + */ + protected ClientDocument(VamsasDocument doc, VamsasArchive docHandler, IdFactory Factory, SimpleClient sclient) { + super(Factory.getVorbaIdHash(), Factory); + + + /** + * prepare Application-side dataset from the vamsas Document archive + */ + this.sclient = sclient; + archive = docHandler; + this.doc = doc; + updatedObjects=null; /// TODO: correct this line + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClientDocument#getObject(org.vamsas.client.VorbaId) + */ + public Vobject getObject(VorbaId id) { + if (vamsasObjects==null) { + log.debug("getObject called on null objrefs list."); + return null; + } + if (vamsasObjects.containsKey(id)) + return (Vobject) vamsasObjects.get(id); + log.debug("Returning null Vobject reference for id "+id.getId()); + return null; + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClientDocument#getObjects(org.vamsas.client.VorbaId[]) + */ + public Vobject[] getObjects(VorbaId[] ids) { + if (vamsasObjects==null) { + log.debug("getObject[] called on null vamsasObjects list."); + return null; + } + Vobject[] vo = new Vobject[ids.length]; + for (int i=0,j=ids.length; i-1) { + if (isValidUpdate(newr[k], original[i])) { + modified=true; + rts.add(newr[k]); + newr[k]=null; + } else { + // LATER: try harder to merge ducument roots. + log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); + newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD + } + } else { + // add in order. + rts.add(original[i]); + } + } + // add remaining (new) roots + for (int i=0,j=newr.length; i0) { + + ObjectInputStream is = new ObjectInputStream(fileLock.getBufferedInputStream(true)); + Object o; + o=is.readObject(); + if (o!=null) { + try { + clients = (ClientHandle[]) o; + } + catch (Exception e) { + System.err.println("Garbage in the clientHandle list "+this.sessionFile); + } + } + } + return clients; + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(System.err); + } catch (Exception e) { + e.printStackTrace(System.err); + } + } + return null; + } + /** + * get the clientList from the file. May return null if lock failed! + * @return clientList + */ + public ClientHandle[] retrieveClientList() { + if (lockFile()) { + ClientHandle[] clients = retrieveClientHandles(); + unlockFile(); + return clients; + } + return null; + } + /** + * get list from the locked ClientList. + * @param extantlock + * @return clientList or null if lock failed (or file was empty) + */ + public ClientHandle[] retrieveClientList(Lock extantlock) { + if (lockFile(extantlock)) { + ClientHandle[] clients = retrieveClientHandles(); + unlockFile(); + return clients; + } + return null; + } + /** + * adds clientHandle me to the clientList under an existing lock extantLock. + * @param me + * @param extantLock + * @return client index in list or 0 if lock was invalid or addClient operation failed. + */ + public int addClient(ClientHandle me, Lock extantLock) { + return addClient(me, true, extantLock); + } + + /** + * adds clientHandle me to the clientList under an existing lock. + * @param me - clientHandle + * @param disambig - if true then add will fail if an identical clientHandle already exists + * @param extantLock - existing lock + * @return client index in list or 0 if addClient (or the lock) failed. + */ + + public int addClient(ClientHandle me, boolean disambig, Lock extantLock) { + if (lockFile(extantLock)) { + syncnum = addClient(me, disambig); + unlockFile(); + return syncnum; + } + return 0; + } + + /** + * adds the ClientHandle to the list - if it is not unique, then the + * ClientHandle object is modified to make it unique in the list. returns the + * clientNumber for the client in the session. + * + * @param me + * @return + */ + + public int addClient(ClientHandle me) { + syncnum = addClient(me, true); + unlockFile(); + return syncnum; + } + + /** + * removes 'me' from the session ClientList without complaint if 'me' isn't in the clientList already. + * @param me client handle to be removed + * @param clientlock existing lock passed from watcher. + */ + public void removeClient(ClientHandle me, Lock clientlock) { + int mynum=-1; + if (lockFile(clientlock)) { + ClientHandle[] clients = retrieveClientHandles(); + if (clients != null) { + if ((syncnum<=0 || syncnum>clients.length) || clients[syncnum-1]!=me) { + for (int i = 0, j = clients.length; i < j; i++) + if (clients[i].equals(me)) { + mynum=i; + break; + } + } else { + mynum=syncnum-1; + } + if (mynum>-1) { + ClientHandle[] newlist = new ClientHandle[clients.length - 1]; + for (int k=0,i = 0, j = clients.length; i < j; i++) + if (i!=mynum) + newlist[k++] = clients[i]; + if (!putClientList(newlist)) + throw new Error("Failed to write new clientList!"); // failed to put the clientList to disk. + } + } + unlockFile(); + } else { + throw new Error("Couldn't get lock for "+((sessionFile==null) ? "Unitialised sessionFile in ClientsFile" : sessionFile.getAbsolutePath())); + } + } + /** + * Adds a ClientHandle to the ClientList file - optionally disambiguating + * the ClientHandle (modifes the URN). + * Note: Caller is left to release the lock on the ClientList. + * @param me + * @param disambiguate - + * flag indicating if the URN for me should be disambiguated to + * differentiate between sessions. + * @return index of clientHandle in new list, or -1-position of existing + * clientHandle (if disambiguate is true) + */ + protected int addClient(ClientHandle me, boolean disambiguate) { + int newclient = 0; + int tries=5; + while (tries-->0 && !lockFile()) + try { Thread.sleep(1); } catch (Exception e){}; + if (lockFile()) { + ClientHandle[] clients = retrieveClientHandles(); + if (me.getClientUrn()==null) { + // TODO: move this into ClientUrn as a standard form method. + me.setClientUrn("vamsas://"+me.getClientName()+":"+me.getVersion()+"/"); + } + if (clients == null) { + clients = new ClientHandle[1]; + clients[0] = me; + newclient = 1; + } else { + int k = 0; + for (int i = 0, j = clients.length; i < j; i++) { + if (clients[i].equals(me)) { + if (disambiguate) { + while (clients[i].equals(me)) { + me.setClientUrn(me.getClientUrn() + k++); // TODO: make a better + // disambiguation of + // urn. + } + } else { + // will not write the ambiguous clientHandle to disk, just return + // its index. + return -1 - i; + } + } + } + int i, j; + ClientHandle[] newlist = new ClientHandle[clients.length + 1]; + for (i = 0, j = clients.length; i < j; i++) + newlist[i] = clients[i]; + newlist[j] = me; + clients = newlist; + newclient = j+1; + } + if (!putClientList(clients)) + return 0; // failed to put the clientList to disk. + } + return newclient; + } + /** + * when set true - get FileNotFoundExceptions on WinXP when writing to locked stream after the backup has been made (via the backupFile method) + */ + boolean backup=false; + /** + * safely writes clients array to the file referred to by sessionFile. + * + * @param clients + * @return true if successful write. Throws Errors otherwise. + */ + protected boolean putClientList(ClientHandle[] clients) { + if (lockFile()) { + File templist=null; + if (!backup || (templist = backupSessionFile()) != null) { + int retries=3; + while (retries-->0) { + try { + ObjectOutputStream os = + new ObjectOutputStream(fileLock.getBufferedOutputStream(true)); + log.debug("About to write "+clients.length+" clientHandles to output stream."); + os.writeObject(clients); + os.close(); + // All done - remove the backup. + if (backup) + templist.delete(); + templist = null; + retries=-1; + } catch (Exception e) { + System.err + .println("Serious - problems writing to sessionFile."); + if (retries>0 && templist != null) { + System.err.println("Recovering from Backup in " + + templist.getAbsolutePath()); + templist.renameTo(fileLock.target); + } + e.printStackTrace(System.err); + } + } + if (retries>-2) { + System.err + .println("Serious - problems writing to sessionFile. Giving Up."); + return false; + } + } else { + throw new Error( + "Couldn't create backup of the clientList before writing to it!"); + } + } else { + throw new Error("Could not lock the clientList: " + + ((sessionFile == null) ? "Unitialized ClientsFile" + : " failed to get lock on " + sessionFile.getAbsolutePath())); + } + // successful! + return true; + } + + public void clearList() { + if (lockFile()) { + try { + FileOutputStream fout = fileLock.getFileOutputStream(true); + fout.flush(); + fout.close(); + } catch (Exception e) { + throw new Error("Problems trying to clear clientlist!",e); + + } + } + + } +} diff --git a/src/org/vamsas/client/simpleclient/EventGeneratorThread.java b/src/org/vamsas/client/simpleclient/EventGeneratorThread.java new file mode 100644 index 0000000..d9aa1db --- /dev/null +++ b/src/org/vamsas/client/simpleclient/EventGeneratorThread.java @@ -0,0 +1,277 @@ +package org.vamsas.client.simpleclient; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.Events; + +/** + * monitors watcher objects and generates events. + */ +public class EventGeneratorThread extends Thread implements Runnable { + private static Log log = LogFactory.getLog(EventGeneratorThread.class); + private SimpleClient client; + private Hashtable handlers; // manager object + private VamsasSession session; + + /** + * list with all the clientHandles for the session + */ + protected FileWatcher clientfile=null; + /** + * the session's vamsasDocument + */ + protected FileWatcher vamsasfile=null; + /** + * written to by client when its app calls storeDocument. + */ + protected FileWatcher storeFile=null; + + private boolean watch=false; + + + EventGeneratorThread(VamsasSession s, SimpleClient _client, Hashtable eventhandlers) { + if (eventhandlers==null || s==null || _client==null) + throw new Error("Null arguments to EventGeneratorThread constructor."); + handlers = eventhandlers; + session = s; + client = _client; + setName(s.sessionDir.getName()); + initWatchers(); + } + + private void initWatchers() { + if (clientfile==null) + clientfile = session.getClientWatcher(); + if (vamsasfile ==null) + vamsasfile = session.getDocWatcher(); + if (storeFile == null) + storeFile = session.getStoreWatcher(); + clientfile.setState(); + vamsasfile.setState(); + storeFile.setState(); + } + boolean ownsf = false; + /** + * scans all watchers and fires changeEvents if necessary + * @return number of events generated. + */ + private int checkforEvents() { + Lock watchlock; + //TODO : leave slog.info messages for the events that occur. + int raised=0; + // could make this general - but for now keep simple + if ((watchlock=storeFile.getChangedState())!=null) { + // TODO: define the storeFile semaphore mechanism : file exists - all clients inform their apps, and then the client that wrote the file should delete the file (it should hold the lock to it). + if (storeFile.exists) { + PropertyChangeSupport h = (PropertyChangeSupport) handlers.get(Events.DOCUMENT_FINALIZEAPPDATA); + if (h!=null) { + log.debug("Triggering DOCUMENT_FINALIZEAPPDATA"); + raised++; + h.firePropertyChange(client.getSessionUrn(), null, client); + // expect client to + vamsasfile.setState(); + } + } + } + if ((watchlock=clientfile.getChangedState())!=null) { + // see what happened to the clientfile - compare our internal version with the one in the file, or just send the updated list out...? + // + /** + * Generated when a new vamsas client is attached to a session (Handle is + * passed) Note: the newly created client does not receive the event. + * + public static final String CLIENT_CREATION = "org.vamsas.client.events.clientCreateEvent"; + */ // as the test + /** + * Generated when a vamsas client leaves a session (Handle is passed to all + * others). + public static final String CLIENT_FINALIZATION = "org.vamsas.client.events.clientFinalizationEvent"; + */ // again - as the test. + raised++; + } + if ((watchlock=vamsasfile.getChangedState())!=null) { + + /** + * Generated when a client has finished updating the document. Passes + * applicationHandle of client so the updating client can recognise its own + * updates. + public static final String DOCUMENT_UPDATE = "org.vamsas.client.events.documentUpdateEvent"; + */ + // read apphandle from 'lastUpdate' session file. + // pass apphandle name to appHandler ? + + } + /** + * Generated when a new vamsas document is created (perhaps from some existing + * Vamsas data) so an application may do its own data space initialization. + * TODO: decide if this is called when an app is connected to a stored + * session... + public static final String DOCUMENT_CREATE = "org.vamsas.client.events.documentCreateEvent"; + */ + // check if this session's appInit flag is set - if not - generate event for this app. + // prolly don't need this at the moment - when an app does getDocument it can to the initing then. + + + /** + * Generated prior to session Shutdown, after the last participating vamsas + * client has finalized. + * TODO: decide on purpose of this ? is this for benefit of multi-session Apps only ? + public static final String SESSION_SHUTDOWN = "org.vamsas.client.events.SessionShutdownEvent"; + */ + + /** + * Generated for all clients when any client calls IClient.storeDocument() to + * allow them to store any updates before an offline copy of the session is + * created. Any client that handles this should call the + * IClient.getDocument(), update and then IClient.updateDocument in the same + * handler thread. + * EventName: + * NewValue: org.vamsas.client.IClient for session. + * + public static final String DOCUMENT_FINALIZEAPPDATA = "org.vamsas.client.events.DocumentFinalizeAppData"; +*/ + // watch for finalization semaphore (last finalised sessionFile). + + /** + * Generated by Vorba stub after the penultimate client makes a call to + * closeDocument(). Sequence is as follows : 1. All other vamsas clients have + * called closeDocument() 2. Final living client monitors closures, and + * realises that it is last. 3. Final client generates event to prompt + * associated application to inquire if the user wishes to save the document + * for future reference. + * * Any call to closeDocument in a thread other than the registered + * EventListener will block until the RequestToClose handler has exited. + * + */ + // public static final String DOCUMENT_REQUESTTOCLOSE = "org.vamas.client.DocumentRequestToCloseEvent"; + + return raised; + } + + private void initEvents() { + + } + /** + * Events raised by IClient and propagated to others in session + */ + + /** + * number of milliseconds between any file state check. + */ + long POLL_UNIT = 20; + protected void wait(int u) { + if (u<=0) + u=1; + long l = System.currentTimeMillis()+POLL_UNIT*u; + while (System.currentTimeMillis()0) { + sequence++; + } else { + idstring+="1/"; + sequence=1; + } + newidstring=idstring+Integer.toString(sequence); + } while (extantids.containsKey(newidstring)); + extantids.put(newidstring, vobject); // hash the Vobject by its new Id + VorbaId id = newId(newidstring); // VorbaId.hash()==newidstring.hash() so we can still recover vobject + return id; + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#setSession(org.vamsas.client.SessionHandle) + */ + protected void setSession(SessionHandle sessionhandle) { + if (sessionhandle!=null) + session=sessionhandle; + else + log.warn("setSession(null) called."); + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#getSessionHandle() + */ + public SessionHandle getSessionHandle() { + return session; + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#setClient(org.vamsas.client.ClientHandle) + */ + protected void setClient(ClientHandle appHandle) { + if (appHandle!=null) + client = appHandle; + else + log.warn("setClient(null) called."); + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#getClientHandle() + */ + public ClientHandle getClientHandle() { + return client; + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#setUser(org.vamsas.client.UserHandle) + */ + protected void setUser(UserHandle userHandle) { + if (userHandle!=null) + user = userHandle; + else + log.warn("setUser(null) called."); + } + + /* (non-Javadoc) + * @see org.vamsas.client.VorbaIdFactory#getUserHandle() + */ + public UserHandle getUserHandle() { + return user; + } + /** + * Convenience method used for default behaviour in testing + * and any anonymous internal vamsasDocument unmarshalling + * @param clientname + * @return + */ + protected static IdFactory getDummyFactory(String clientname) { + if (clientname==null) + clientname="org.vamsas.client.simpleclient.IdFactory"; + return new IdFactory(new SessionHandle("dummy.session"), + new ClientHandle(clientname,VersionEntries.latestVersion()), + new UserHandle(clientname, "Arnold User's Inc.")); + } +} diff --git a/src/org/vamsas/client/simpleclient/ListFile.java b/src/org/vamsas/client/simpleclient/ListFile.java new file mode 100644 index 0000000..30956e9 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/ListFile.java @@ -0,0 +1,25 @@ +/** + * + */ +package org.vamsas.client.simpleclient; + +import java.io.File; + + +/** + * base class for generic list storage and retrieval operations from a locked IO file + * TODO: LATER: generalize for all list storage and retrieval operations + * (pull-up from ClientsFile object) + */ +public class ListFile extends SessionFile { + + /** + * @param file + */ + public ListFile(File file) throws java.io.IOException { + super(file); + if (!this.sessionFile.exists()) + this.sessionFile.createNewFile(); + } + +} diff --git a/src/org/vamsas/client/simpleclient/Lock.java b/src/org/vamsas/client/simpleclient/Lock.java new file mode 100644 index 0000000..d3a5889 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/Lock.java @@ -0,0 +1,96 @@ +package org.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.channels.ByteChannel; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; + +import org.apache.commons.logging.LogFactory; + +/** + * transient object representing a file lock + * This lock should hold for all processes interacting in a session. + * @author jimp + */ + +public abstract class Lock { + protected org.apache.commons.logging.Log log = LogFactory.getLog(Lock.class); + File target = null; // The file that is being locked + protected RandomAccessFile rafile=null; + + /** + * creates a valid Lock (test with isLocked) + * if a lock could be obtained for lockfile + * @param lockfile + */ + protected Lock(java.io.File lockfile) { + target = lockfile; + } + /** + * + * @return true if lock is held on the target + */ + public abstract boolean isLocked(); + /** + * release lock and close all managed channels to file + * + */ + public abstract void release(); + /** + * optionally close the open random access channel on the file when releasing lock + * @param closeChannel + */ + public abstract void release(boolean closeChannel); + + /** + * gets Locked Stream for reading from + * @param atStart true to start reading at beginning of file. + * @return null if file not locked + * @throws IOException + */ + public abstract FileInputStream getFileInputStream(boolean atStart) throws IOException; + + /** + * gets Locked stream to write to + * FileInput always starts at the *end* of the file (after any truncation) + * @param clear true means file will be cleared to zero length + * @return null if file is not locked + * @throws IOException + */ + public abstract FileOutputStream getFileOutputStream(boolean clear) throws IOException; + /** + * return buffered output stream to locked file. + * @param clear - true means file is truncated to 0 length before writing + * @return + */ + public abstract BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException; + + protected void finalize() throws Throwable { + target=null; + } + /** + * return buffered input stream for locked file. + * @param atStart - true means read from begining of file + * @return null if file is not locked. + */ + public BufferedInputStream getBufferedInputStream(boolean atStart) throws IOException { + FileInputStream fis = getFileInputStream(atStart); + if (fis!=null) + return new BufferedInputStream(fis); + return null; + } + /** + * safe lock target length() function. + * @return -1 for non-lockable target, otherwise target's file length + */ + public abstract long length(); + public abstract RandomAccessFile getRaFile() throws IOException; + public abstract FileChannel getRaChannel() throws IOException; +} diff --git a/src/org/vamsas/client/simpleclient/LockFactory.java b/src/org/vamsas/client/simpleclient/LockFactory.java new file mode 100644 index 0000000..5fdde6c --- /dev/null +++ b/src/org/vamsas/client/simpleclient/LockFactory.java @@ -0,0 +1,52 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class LockFactory { + protected static Log log = LogFactory.getLog(LockFactory.class); + public static int locktype=0; // use file lock by default + public static String[] locktypes = {"file","native"}; + { + String lockt = System.getProperty("vamsas.locktype"); + if (lockt!=null) { + int i,j; + for (i=0, j=locktypes.length; i=j) { + String lt = "'"+locktypes[0]+"'"; + for (i=1; i0 && !fileLock.isLocked()); + if (!fileLock.isLocked()) + log.error("Failed to get lock for "+sessionFile); + // fileLock = new Lock(sessionFile); + return fileLock.isLocked(); + } + + /** + * Explicitly release the SessionFile's lock. + * + * @return true if lock was released. + */ + protected void unlockFile() { + if (fileLock != null) { + fileLock.release(); + fileLock = null; + } + } + + /** + * Makes a backup of the sessionFile. + * @return Backed up SessionFile or null if failed to make backup. + */ + protected File backupSessionFile() { + return backupSessionFile(null, sessionFile.getName(),".old", sessionFile.getParentFile()); + } + + protected File backupSessionFile(Lock extantLock, String backupPrefix, String backupSuffix, File backupDir) { + File tempfile=null; + if (lockFile(extantLock)) { + try { + tempfile = File.createTempFile(backupPrefix, backupSuffix, backupDir); + if (fileLock.length()>0) { + FileOutputStream tos = new FileOutputStream(tempfile); + ReadableByteChannel channel; + tos.getChannel().transferFrom(channel=fileLock.getRaChannel(), 0, + fileLock.length()); + tos.close(); + if (!channel.isOpen()) + throw new Error(tos.getChannel().getClass()+".transferFrom closes source channel!"); + if (!lockFile(extantLock)) + throw new Error("Lost lock for "+sessionFile.getName()+" after backup."); + + } + } catch (FileNotFoundException e1) { + log.warn("Can't create temp file for "+sessionFile.getName(),e1); + tempfile=null; + } catch (IOException e1) { + log.warn("Error when copying content to temp file for "+sessionFile.getName(),e1); + tempfile=null; + } + } + return tempfile; + } + /** + * Replaces data in sessionFile with data from file handled by another sessionFile + * passes up any exceptions. + * @param newData source for new data + */ + protected void updateFrom(Lock extantLock, SessionFile newData) throws IOException { + log.debug("Updating "+sessionFile.getAbsolutePath()+" from "+newData.sessionFile.getAbsolutePath()); + if (newData==null) + throw new IOException("Null newData object."); + if (newData.sessionFile==null) + throw new IOException("Null SessionFile in newData."); + + if (!lockFile(extantLock)) + throw new IOException("Failed to get write lock for "+sessionFile); + if (!newData.lockFile()) + throw new IOException("Failed to get lock for updateFrom "+newData.sessionFile); + RandomAccessFile nrafile = newData.fileLock.getRaFile(); + nrafile.seek(0); + RandomAccessFile trafile = fileLock.getRaFile(); + /*long tries=5000; + while (trafile==null && --tries>0) { + log.debug("Lost lock on "+sessionFile+"! Re-trying for a transfer."); + lockFile(); + trafile = fileLock.getRaFile(); + }*/ + trafile.seek(0); + trafile.getChannel().transferFrom(nrafile.getChannel(), 0, + nrafile.length()); + } + /** + * remove all trace of the sessionFile file + * + */ + protected void eraseExistence() { + unlockFile(); + if (sessionFile!=null) { + sessionFile.delete(); + sessionFile = null; + } + } + /* (non-Javadoc) + * @see org.vamsas.client.simpleclient.Lock#getBufferedInputStream(boolean) + */ + public BufferedInputStream getBufferedInputStream(boolean atStart) throws IOException { + lockFile(); + return fileLock.getBufferedInputStream(atStart); + } + + /* (non-Javadoc) + * @see org.vamsas.client.simpleclient.Lock#getBufferedOutputStream(boolean) + */ + public BufferedOutputStream getBufferedOutputStream(boolean clear) throws IOException { + lockFile(); + return fileLock.getBufferedOutputStream(clear); + } + + /* (non-Javadoc) + * @see org.vamsas.client.simpleclient.Lock#getFileInputStream(boolean) + */ + public FileInputStream getFileInputStream(boolean atStart) throws IOException { + lockFile(); + return fileLock.getFileInputStream(atStart); + } + + /* (non-Javadoc) + * @see org.vamsas.client.simpleclient.Lock#getFileOutputStream(boolean) + */ + public FileOutputStream getFileOutputStream(boolean clear) throws IOException { + lockFile(); + return fileLock.getFileOutputStream(clear); + } + +} diff --git a/src/org/vamsas/client/simpleclient/SessionFlagFile.java b/src/org/vamsas/client/simpleclient/SessionFlagFile.java new file mode 100644 index 0000000..7826fbc --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SessionFlagFile.java @@ -0,0 +1,85 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * methods for setting and checking + * binary flags in a vamsas session directory. + * all methods apart from the constructor will + * throw a fatal error if the flagFile is not + * a valid java.io.File object. + * LATER: extract SessionFlag interface for generalizing the vamsas session code + * @author jimp + * + */ +public class SessionFlagFile { + private static Log log = LogFactory.getLog(SessionFlagFile.class); + protected File flagFile=null; + private void checkFlagFile() { + if (flagFile==null) { + log.fatal("Implementation error - uninitialized SessionFlagFile", + new Error("Implementation error - uninitialized SessionFlagFile")); + } + } + /** + * will log a warning if exceptions occur during flag creation. + * @return true if flag was set successfully + */ + public boolean setFlag() { + checkFlagFile(); + try { + if (flagFile.createNewFile()) { + log.debug("Set session flag "+flagFile); + } else { + log.debug("Session flag already set "+flagFile); + } + return true; + } + catch (Exception e) { + log.warn("Couldn't set session flag "+flagFile, e); + } + return false; + } + /** + * + * @return true if flag was cleared successfully + */ + public boolean clearFlag() { + checkFlagFile(); + if (flagFile.exists()) { + log.debug("clearing session flag "+flagFile); + if (!flagFile.delete()) { + log.warn("failed to clear session flag "+flagFile); + return false; + } + } else { + log.debug("clearFlag called for already cleared flag "+flagFile); + } + return true; + } + /** + * + * @return state of session flag + */ + public boolean checkFlag() { + checkFlagFile(); + if (flagFile.exists()) { + if (log.isDebugEnabled()) + log.debug("Flag '"+flagFile+"' is set."); + return true; + } + if (log.isDebugEnabled()) + log.debug("Flag '"+flagFile+"' is not set."); + return false; + } + /** + * @param flagFile + */ + public SessionFlagFile(File flagFile) { + super(); + this.flagFile = flagFile; + }; +} diff --git a/src/org/vamsas/client/simpleclient/SessionUrn.java b/src/org/vamsas/client/simpleclient/SessionUrn.java new file mode 100644 index 0000000..13b6f23 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SessionUrn.java @@ -0,0 +1,40 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; +import java.net.MalformedURLException; + +/** + * SessionUrn for simpleclient sessions: + * simpleclient://{Absolute path to session directory} + * @author jimp + * + */ +public class SessionUrn extends org.vamsas.client.SessionUrn { + /** + * a simple client session urn prefix + */ + public static final String SIMPLECLIENT="simpleclient"; + public static String VAMSASDOCUMENT="vdoc"; + static { + TYPES.put(SIMPLECLIENT, SessionUrn.class); + TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class); + } + + public SessionUrn(File sessionLocation) throws MalformedURLException { + // TODO: LATER: implement switch to have vamsas document or simpleclient sessions for same constructor + super(SIMPLECLIENT, sessionLocation.getAbsoluteFile().toURL()); + //else + // super(VAMSASDOCUMENT, sessionLocation); + } + public SessionUrn(VamsasSession session) throws MalformedURLException { + super(SIMPLECLIENT, session.sessionDir.getAbsoluteFile().toURL()); + } + /** + * TODO: LATER: think about this again. + * @return File(urn.getPath()) + */ + public File asFile() { + return new File(urn.getPath()); + } + // TODO: add abstract 'handler' methods for resolving the URN to a particular class +} diff --git a/src/org/vamsas/client/simpleclient/SessionsFile.java b/src/org/vamsas/client/simpleclient/SessionsFile.java new file mode 100644 index 0000000..eb80f45 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SessionsFile.java @@ -0,0 +1,342 @@ +/* EMBL - The European Bioinformatics institute +* MSD Group +* VAMSAS Project +* +* Copyright (c) 2005-2006 Thr European Bioinformatics Institute. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The name MSD must not be used to endorse or promote products +* derived from this software without prior written permission. For +* written permission, please contact msd-help@ebi.ac.uk +* +* 4. Products derived from this software may not be called "MSD" +* nor may "MSD" appear in their names without prior written +* permission of the MSD developers. +* +* 5. Redistributions of any form whatsoever must retain the following +* acknowledgment: +* "This product includes software developed by MSD +* (http://www.ebi.ac.uk/)" +* +* THIS SOFTWARE IS PROVIDED BY THE MSD GROUP ``AS IS'' AND ANY +* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ENSEMBL GROUP OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +* OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The European Bioinformatics Institute may publish revised and/or new +* versions of this license with new releases of VAMSAS software. +*============================================================================== +* +* @author Pierre MARGUERITE +* +* Dec 13, 2006 - VamsasClientV4 +* +*/ + +package org.vamsas.client.simpleclient; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.SessionHandle; + +/** + * @author Pierre MARGUERITE + * + * + */ +public class SessionsFile extends ListFile { + + private static Log log = LogFactory.getLog(SessionsFile.class); + /** + * when set true - get FileNotFoundExceptions on WinXP when writing to locked stream after the backup has been made (via the backupFile method) + */ + boolean backup=false; + /** + * number of my session in list - passed back when a session + * is added to list, and used (if valid) for quickly + * looking up presence of session handle in the list. + */ + private int syncnum = 1; + /** + * @param file + */ + public SessionsFile(File file) throws java.io.IOException { + super(file); + } + + + /** + * internal method for getting sessionsList - ensures a lock has been made but + * does not release it. + * + * @return list of clients + */ + private SessionHandle[] retrieveSessionHandles() { + if (lockFile()) { + try { + SessionHandle[] clients=null; + if (this.fileLock.length()>0) { + + ObjectInputStream is = new ObjectInputStream(this.fileLock.getBufferedInputStream(true)); + Object o; + o=is.readObject(); + if (o!=null) { + try { + clients = (SessionHandle[]) o; + } + catch (Exception e) { + log.error("Garbage in the clientHandle list "+this.sessionFile,e); + } + } + } + return clients; + } catch (FileNotFoundException e) { + // e.printStackTrace(System.err); + log.error(e); + } catch (Exception e) { + log.error(e); + //e.printStackTrace(System.err); + } + } + return null; + } + + /** + * get the SessionsList from the file. May return null if lock failed! + * @return sessionsList + */ + public SessionHandle[] retrieveSessionsList() { + if (lockFile()) { + SessionHandle[] clients = retrieveSessionHandles(); + unlockFile(); + return clients; + } + return null; + } + + /** + * get list from the locked ClientList. + * @param extantlock + * @return clientList or null if lock failed (or file was empty) + */ + public SessionHandle[] retrieveSessionsList(Lock extantlock) { + if (lockFile(extantlock)) { + SessionHandle[] clients = retrieveSessionHandles(); + unlockFile(); + return clients; + } + return null; + } + + + /** + * adds clientHandle me to the clientList under an existing lock extantLock. + * @param me + * @param extantLock + * @return client index in list or 0 if lock was invalid or addClient operation failed. + */ + public int addSession(SessionHandle me, Lock extantLock) { + return addSession(me, true, extantLock); + } + + /** + * adds SessionsHandle me to the sessionsList under an existing lock. + * @param me - sessionsHandle + * @param disambig - if true then add will fail if an identical clientHandle already exists + * @param extantLock - existing lock + * @return client index in list or 0 if addClient (or the lock) failed. + */ + + public int addSession(SessionHandle session, boolean disambig, Lock extantLock) { + if (lockFile(extantLock)) { + this.syncnum = addSession(session, disambig); + unlockFile(); + return this.syncnum; + } + return 0; + } + + /** + * removes the current session from the SessionsList without complaint if the session isn't in the sessionsList already. + * @param me client handle to be removed + * @param clientlock existing lock passed from watcher. + */ + public void removeSession(SessionHandle session, Lock clientlock) { + int mynum =-1; + if (lockFile(clientlock)) { + SessionHandle[] sessions = retrieveSessionHandles(); + if (sessions != null) { + if ((this.syncnum<=0 || this.syncnum>sessions.length) || sessions[this.syncnum-1]!=session) { + for (int i = 0, j = sessions.length; i < j; i++) + if (sessions[i].equals(session)) { + mynum=i; + break; + } + } else { + mynum=this.syncnum-1; + } + if (mynum>-1) { + SessionHandle[] newlist = new SessionHandle[sessions.length - 1]; + for (int k=0,i = 0, j = sessions.length; i < j; i++) + if (i!=mynum) + newlist[k++] = sessions[i]; + if (!putSessionsList(newlist)) + throw new Error("Failed to write new sessionsList!"); // failed to put the sessionList to disk. + } + } + unlockFile(); + } else { + throw new Error("Couldn't get lock for "+((sessionFile==null) ? "Unitialised sessionFile in SessionsFile" : this.sessionFile.getAbsolutePath())); + } + } + /** + * Adds a SessionHandle to the SessionList file - optionally disambiguating + * the SessionHandle (modifes the URN). + * Note: Caller is left to release the lock on the SessionList. + * @param me + * @param disambiguate - + * flag indicating if the URN for me should be disambiguated to + * differentiate between sessions. + * @return index of sessionHandle in new list, or -1-position of existing + * sessionHandle (if disambiguate is true) + */ + protected int addSession(SessionHandle session, boolean disambiguate) { + int newsession = 0; + int tries=5; + while (tries-->0 && !lockFile()) + try { Thread.sleep(1); } catch (Exception e){}; + if (lockFile()) { + SessionHandle[] sessions = retrieveSessionHandles(); + + if (sessions == null) { + sessions = new SessionHandle[1]; + sessions[0] = session; + newsession = 1; + } else { + int k = 0; + for (int i = 0, j = sessions.length; i < j; i++) { + if ( sessions[i].equals(session)) { + if (disambiguate) { + while (sessions[i].equals(session)) { + // me.setClientUrn(me.getClientUrn() + k++); // TODO: make a better + // disambiguation of + // urn. + } + } else { + // will not write the ambiguous clientHandle to disk, just return + // its index. + return -1 - i; + } + } + } + int i, j; + SessionHandle[] newlist = new SessionHandle[sessions.length + 1]; + for (i = 0, j = sessions.length; i < j; i++) + newlist[i] = sessions[i]; + newlist[j] = session; + sessions = newlist; + newsession = j+1; + } + if (!putSessionsList(sessions)) + return 0; // failed to put the clientList to disk. + } + return newsession; + } + + + /** + * safely writes sessions array to the file referred to by sessionFile. + * + * @param clients + * @return true if successful write. Throws Errors otherwise. + */ + protected boolean putSessionsList(SessionHandle[] clients) { + if (lockFile()) { + File templist=null; + if (!this.backup || (templist = backupSessionFile()) != null) { + int retries=3; + while (retries-->0) { + try { + ObjectOutputStream os = + new ObjectOutputStream(this.fileLock.getBufferedOutputStream(true)); + log.debug("About to write "+clients.length+" sessionHandles to output stream."); + os.writeObject(clients); + os.close(); + // All done - remove the backup. + if (this.backup) + templist.delete(); + templist = null; + retries=-1; + } catch (Exception e) { + // System.err + //.println("Serious - problems writing to sessionFile."); + log.error("Serious - problems writing to sessionFile.",e); + if (retries>0 && templist != null) { + // System.err.println("Recovering from Backup in " + // + templist.getAbsolutePath()); + log.error("Recovering from Backup in "+ templist.getAbsolutePath()); + templist.renameTo(this.fileLock.target); + } + //e.printStackTrace(System.err); + log.error(e); + } + } + if (retries>-2) { + // System.err + // .println("Serious - problems writing to sessionFile. Giving Up."); + log.error("Serious - problems writing to sessionFile. Giving Up."); + return false; + } + } else { + throw new Error( + "Couldn't create backup of the clientList before writing to it!"); + } + } else { + throw new Error("Could not lock the clientList: " + + ((this.sessionFile == null) ? "Unitialized ClientsFile" + : " failed to get lock on " + this.sessionFile.getAbsolutePath())); + } + // successful! + return true; + } + + public void clearList() { + if (lockFile()) { + try { + FileOutputStream fout = this.fileLock.getFileOutputStream(true); + fout.flush(); + fout.close(); + } catch (Exception e) { + throw new Error("Problems trying to clear clientlist!",e); + + } + } + + } +} diff --git a/src/org/vamsas/client/simpleclient/SimpleClient.java b/src/org/vamsas/client/simpleclient/SimpleClient.java new file mode 100644 index 0000000..2041c11 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SimpleClient.java @@ -0,0 +1,416 @@ +/* + * Created on 15-Sep-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.client.simpleclient; + +import java.beans.EventHandler; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.ClientHandle; +import org.vamsas.client.Events; +import org.vamsas.client.IClient; +import org.vamsas.client.IClientDocument; +import org.vamsas.client.IObjectUpdate; +import org.vamsas.client.InvalidSessionUrnException; +import org.vamsas.client.SessionHandle; +import org.vamsas.client.UserHandle; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.Entry; +import org.vamsas.objects.core.LockFile; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.objects.utils.AppDataReference; +import org.vamsas.objects.utils.ProvenanceStuff; +import org.vamsas.objects.utils.document.VersionEntries; + +/** + * @author jimp + */ +public class SimpleClient implements IClient { + + private static Log log = LogFactory.getLog(SimpleClient.class); + + protected UserHandle user = null; + + protected SessionUrn session = null; + protected VamsasSession _session; + protected ClientHandle client = null; + protected EventGeneratorThread evgen = null; + protected ClientDocument cdocument = null; + /** + * object hash table that persists in each client holding vorbaIds and hash values after a document write + */ + protected Hashtable extantobjects=null; + /** + * construct a transient IdFactory instance - this should last only as long as the + * SimpleClient object holds the lock on the vamsas document being created/manipulated. + * @return + */ + private IdFactory makeVorbaIdFactory() { + return new IdFactory(getSessionHandle(), client, user); + } + + /** + * construct SimpleClient for user, client and VamsasSession directory + * use the SimpleClientFactory rather than this constructor directly. + * @param user + * @param client + * @param sess + */ + protected SimpleClient(UserHandle user, ClientHandle client, VamsasSession sess) throws InvalidSessionUrnException { + // TODO: validate user/client/session + _session = sess; + this.user = user; + this.client = client; + try { + session = new SessionUrn(_session); + } catch (MalformedURLException e) { + log.error("Couldn't form a valid SessionUrn object!",e); + throw new InvalidSessionUrnException(_session.toString()); + } + } + /** + * construct new session by importing objects from an existing vamsas document + * @param user + * @param client + * @param sess + * @param importingArchive + * @throws Exception IOExceptions for Session IO problems, and general Exception if importing document is invalid. + */ + protected SimpleClient(UserHandle user, ClientHandle client, VamsasSession sess, File importingArchive) throws Exception { + this(user, client, sess); + VamsasArchive sessdoc = _session.getVamsasDocument(); + try { + VamsasArchiveReader odoc = new VamsasArchiveReader(importingArchive); + SimpleDocument sdoc = new SimpleDocument(makeVorbaIdFactory()); + VamsasDocument doc = sdoc.getVamsasDocument(odoc); + sessdoc.putVamsasDocument(doc, sdoc.vorba); + sessdoc.closeArchive(); + } catch (Exception e) { + sessdoc.cancelArchive(); + // write a dummy archive + _session.slog.info("Exception when importing document data from "+importingArchive); + throw new Exception("Failed to import data from "+importingArchive, e); + } + } + + /* + * (non-Javadoc) + * LATER: check that build substitution variables are correct + * @see org.vamsas.client.IClient#getAbout() + */ + public String getAbout() { + return new String("VORBA SimpleClient version $version$ build $build$"); + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#getSessionUrn() + */ + public String getSessionUrn() { + return session.getSessionUrn(); + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#getSessionHandle() + */ + public SessionHandle getSessionHandle() { + // TODO: eliminate SessionHandle ? need to refactor interfaces. + SessionHandle sh = new SessionHandle(session.getSessionUrn()); + return sh; + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#getClientHandle() + */ + public ClientHandle getClientHandle() { + return client; + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#getUserHandle() + */ + public UserHandle getUserHandle() { + return user; + } + /** + * + * @return user field for a provenance entry + */ + protected String getProvenanceUser() { + return new String(user.getFullName()); + } + /** + * construct a provenance entry for this client with the specified action string. + * @param action + * @return properly completed provenance entry + */ + protected Entry getProvenanceEntry(String action) { + Entry prov = ProvenanceStuff.newProvenanceEntry(client.getClientUrn(), getProvenanceUser(), action); + return prov; + } + private Hashtable handlers = initHandlers(); + + private Vector listeners = new Vector(); + + /** + * make all the PropertyChangeSupport objects for the + * events described in org.vamsas.client.Event + * @return + */ + private static Hashtable initHandlers() { + Hashtable events = new Hashtable(); + java.util.Iterator evt = Events.EventList.iterator(); + while (evt.hasNext()) { + Object ths = evt.next(); + events.put(ths, (Object) new PropertyChangeSupport(ths)); + } + return events; + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#addDocumentUpdateHandler(java.util.EventListener) + */ + public void addDocumentUpdateHandler(PropertyChangeListener evt) { + if (handlers.containsKey(Events.DOCUMENT_UPDATE)) { + Object handler; + ((PropertyChangeSupport) (handler = handlers.get(Events.DOCUMENT_UPDATE))) + .addPropertyChangeListener(evt); + listeners.add(handler); + listeners.add((Object) evt); + } + } + boolean finalized=false; + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#finalizeClient() + */ + public void finalizeClient() { + // TODO: determine if this is last client in session + // TODO: raise events like : ((lst_client && document.request.to.close), (client_finalization), ( + + // if (handlers.containsKey(Events.)) + // if (handlers.containsKey(Events.CLIENT_FINALIZATION)) + // deregister listeners. + // mark this instance as finalized + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#getClientDocument() + */ + public IClientDocument getClientDocument() throws IOException { + if (cdocument!=null) { + // cdocument is non-nill if the ClientDocument.finalise() method hasn't been called. + return cdocument; + } + VamsasArchive va = null; + try { + // LATER: bail out if it takes too long to get the lock ? + va = _session.getVamsasDocument(); + } + catch (IOException e) { + throw new IOException("Failed to get lock on session document"); + } + VamsasDocument doc=null; + IdFactory vorba = null; + // TODO: reduce size of vorba ids generated from these parameters to IdFactory (mainly sessionHandle rationalization ?) + try { + va.setVorba(vorba=makeVorbaIdFactory()); + // if session currently holds data - read it in - or get a dummy + _session.slog.debug("Accessing document"); + doc = + va.getVamsasDocument(getProvenanceUser(), + "created new session document.", null); + if (doc!=null) + _session.slog.debug("Successfully retrieved document."); + else + log.error("Unexpectedly retrieved null document!"); + } + catch (Exception e) { + log.error("Failed to get session document for session directory '"+_session.sessionDir+"'", e); + throw new IOException("Failed to get session document for session directory '"+_session.sessionDir+"'"); + } + // Construct the IClientDocument instance + + ClientDocument cdoc = new ClientDocument(doc, va, vorba, this); + return cdoc; + } + + /* + * (non-Javadoc) + * @throws Errors for invalid newdoc parameter + * @see org.vamsas.client.IClient#updateDocument(org.vamsas.client.IClientDocument) + */ + public void updateDocument(IClientDocument newdoc) { + if (!(newdoc instanceof ClientDocument)) { + throw new Error("Invalid IClientDocument instance for SimpleClient."); + } + if (cdocument==null) + throw new Error("Client Error - updateDocument() called before getClientDocument()."); + if (newdoc!=cdocument) + throw new Error("Client Error - SimpleClient.updateDocument() can only take the IClientDocument instance returned from SimpleClient.getClientDocument()"); + if (!cdocument.isModified()) { + if (log.isDebugEnabled()) + log.debug("updateDocument for "+session.getSessionUrn()+" with unmodified IClientDocument."); + } else { + try { + if (!cdocument.updateSessionDocument()) { + log.warn("Session document did not update properly for session directory "+_session.sessionDir); + // cdocument.archive.cancelArchive(); // LATER: could be done - would need to prevent updateSessionDocument closing the archive. + _session.slog.warn("Session Document updated but may not be valid (false return from org.vamsas.simpleclient.ClientDocument.updateSessionDocument()"); + } + } + catch (IOException e) { + log.warn("IO Problems when updating document!",e); + _session.slog.error("IO problems when attempting to update document."); + } + } + // garbage collect the ClientDocument instance. + try { + cdocument.finalize(); + + } catch (Throwable e) { + log.error("Exception when trying to garbage collect ClientDocument for "+session.getSessionUrn(), e); + } + cdocument = null; // this is probably done by finalize + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#storeDocument(java.io.File) + */ + public void storeDocument(File location) { + + // write storeDocument file to inform other clients that they should raise + Lock vamlock = evgen.want_to_store(); + // Events.DOCUMENT_FINALIZEAPPDATA + try { + _session.writeVamsasDocument(location, vamlock); + _session.clearUnsavedFlag(); + } catch (Exception e) { + log.warn("Exception whilst trying to store document in "+location,e); + } + + vamlock.release(); + } + + /* + * (non-Javadoc) + * + * @see org.vamsas.client.IClient#addVorbaEventHandler(java.lang.String, + * java.beans.PropertyChangeListener) + */ + public void addVorbaEventHandler(String EventChain, PropertyChangeListener evt) { + if (handlers.containsKey(EventChain)) { + Object handler; + ((PropertyChangeSupport) (handler = handlers.get(EventChain))) + .addPropertyChangeListener(evt); + listeners.add(handler); + listeners.add((Object) evt); + } + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClient#pollUpdate() + */ + public void pollUpdate() { + + if (evgen==null) { + log.warn("pollUpdate called on incomplete SimpleClient object."); + return; + } + + if (!evgen.isAlive()) { + log.warn("pollUpdate called before joinSession() - trying to do this."); + try { + joinSession(); + } catch (Exception e) { + log.error("Unexpected exception on default call to joinSession",e); + } + } + + //TODO ensure event generator robustly handles these interrupts. + log.debug("interrrupting event generator."); + evgen.interrupt(); + log.debug("interrrupted event generator."); + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClient#joinSession() + */ + public void joinSession() throws Exception { + // start the EventGenerator thread. + if (evgen==null) { + log.warn("joinSession called on incomplete SimpleClient object."); + return; + } + if (evgen.isAlive()) + throw new Error("Join session called twice for the same SimpleClient (IClient instance)."); + evgen.start(); + if (evgen.isAlive()) + log.debug("Started EventGenerator thread."); + else { + log.warn("Failed to start EventGenerator thread."); + throw new Exception("Failed to start event generator thread - client cannot be instantiated."); + } + if (evgen.countHandlersFor(Events.DOCUMENT_CREATE)>0) { + //TODO: is this application connecting to a newly created session document ? + //evgen.raise(Events.DOCUMENT_CREATE); + } + } + + + + /* (non-Javadoc) + * @see org.vamsas.client.IClient#importDocument(java.io.File) + */ + public void importDocument(File location) { + // TODO LATER: implement SimpleClient.importDocument() + log.error("importDocument is not yet implemented for a SimpleClient Session."); + } + + public IObjectUpdate getUpdateHandler(Class rootObject) { + // TODO Auto-generated method stub + return null; + } + + public IObjectUpdate[] getUpdateHandlers() { + // TODO Auto-generated method stub + return null; + } + + public void removeUpdateHandler(Class rootObject) { + // TODO Auto-generated method stub + + } + + public void setUpdateHandler(IObjectUpdate handler) { + // TODO Auto-generated method stub + + } +} diff --git a/src/org/vamsas/client/simpleclient/SimpleClientAppdata.java b/src/org/vamsas/client/simpleclient/SimpleClientAppdata.java new file mode 100644 index 0000000..84bc48a --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SimpleClientAppdata.java @@ -0,0 +1,543 @@ +/** + * + */ +package org.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.IClientAppdata; +import org.vamsas.objects.core.AppData; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.User; +import org.vamsas.objects.utils.AppDataReference; + +/** + * @author jimp + * Access interface to data chunks read from a VamsasArchiveReader stream + * (or byte buffer input stream) or written to a VamsasArchive stream. + * // TODO: get VamsasArchiveReader from sclient + */ +public class SimpleClientAppdata implements IClientAppdata { + private static Log log = LogFactory.getLog(SimpleClientAppdata.class); + /** + * has the session's document been accessed to get the AppData entrys? + */ + protected boolean accessedDocument = false; + /** + * has the user datablock been modified ? + * temporary file containing new user specific application data chunk + */ + SessionFile newUserData=null; + JarOutputStream newUserDataStream = null; + /** + * has the apps global datablock been modified ? + * temporary file containing new global application data chunk + */ + SessionFile newAppData=null; + JarOutputStream newAppDataStream=null; + /** + * set by extractAppData + */ + protected ApplicationData appsGlobal = null; + /** + * set by extractAppData + */ + protected User usersData = null; + + ClientDocument clientdoc; + /** + * state flags + * - accessed ClientAppdata + * - accessed UserAppdata + * => inputStream from embedded xml or jar entry of backup has been created + * - set ClientAppdata + * - set UserAppdata + * => an output stream has been created and written to - or a data chunk has been written. + * - need flag for switching between embedded and jar entry mode ? - always write a jar entry for a stream. + * - need code for rewind and overwriting if the set*Appdata methods are called more than once. + * - need flags for streams to except a call to set*Appdata when an output stream exists and is open. + * - need + * @param clientdoc The ClientDocument instance that this IClientAppData is accessing + */ + protected SimpleClientAppdata(ClientDocument clientdoc) { + if (clientdoc==null) { + log.fatal("Implementation error - Null ClientDocument for SimpleClientAppdata construction."); + throw new Error("Implementation error - Null ClientDocument for SimpleClientAppdata construction."); + } + this.clientdoc = clientdoc; + } + /** + * gets appropriate app data for the application, if it exists in this dataset + * Called by every accessor to ensure data has been retrieved from document. + */ + private void extractAppData(org.vamsas.objects.core.VamsasDocument doc) { + if (doc==null) { + log.debug("extractAppData called for null document object"); + return; + } + if (accessedDocument) { + return; + } + Vector apldataset = AppDataReference.getUserandApplicationsData( + doc, clientdoc.sclient.getUserHandle(), clientdoc.sclient.getClientHandle()); + accessedDocument = true; + if (apldataset!=null) { + if (apldataset.size()>0) { + AppData clientdat = (AppData) apldataset.get(0); + if (clientdat instanceof ApplicationData) { + appsGlobal = (ApplicationData) clientdat; + if (apldataset.size()>1) { + clientdat = (AppData) apldataset.get(1); + if (clientdat instanceof User) { + usersData = (User) clientdat; + } + if (apldataset.size()>2) + log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query."); + } + } else { + log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName()); + } + apldataset.removeAllElements(); // destroy references. + } + } + } + /** + * LATER: generalize this for different low-level session implementations (it may not always be a Jar) + * @param appdata + * @param docreader + * @return + */ + private JarInputStream getAppDataStream(AppData appdata, VamsasArchiveReader docreader) { + String entryRef = appdata.getDataReference(); + if (entryRef!=null) { + log.debug("Resolving appData reference +"+entryRef); + InputStream entry = docreader.getAppdataStream(entryRef); + if (entry!=null) { + if (entry instanceof JarInputStream) { + return (JarInputStream) entry; + } + log.warn("Implementation problem - docreader didn't return a JarInputStream entry."); + } + } else { + log.debug("GetAppDataStream called for an AppData without a data reference."); + } + return null; + } + /** + * yuk - size of buffer used for slurping appData JarEntry into a byte array. + */ + private final int _TRANSFER_BUFFER=4096*4; + + /** + * Resolve AppData object to a byte array. + * @param appdata + * @param archiveReader + * @return null or the application data as a byte array + */ + private byte[] getAppDataAsByteArray(AppData appdata, VamsasArchiveReader docreader) { + if (appdata.getData()==null) { + if (docreader==null) { + log.warn("Silently failing getAppDataAsByteArray with null docreader.",new Exception()); + return null; + } + // resolve and load data + JarInputStream entry = getAppDataStream(appdata, docreader); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try { + byte buff[] = new byte[_TRANSFER_BUFFER]; + int olen=0; + while (entry.available()>0) { + int len = entry.read(buff, olen, _TRANSFER_BUFFER); + bytes.write(buff, 0, len); + olen+=len; + } + buff=null; + } catch (Exception e) { + log.warn("Unexpected exception - probable truncation when accessing VamsasDocument entry "+appdata.getDataReference(), e); + } + if (bytes.size()>0) { + // LATER: deal with probable OutOfMemoryErrors here + log.debug("Got "+bytes.size()+" bytes from AppDataReference "+appdata.getDataReference()); + byte data[] = bytes.toByteArray(); + bytes = null; + return data; + } + return null; + } else { + log.debug("Returning inline AppData block for "+appdata.getVorbaId()); + return appdata.getData(); + } + } + /** + * internal method for getting a DataInputStream from an AppData object. + * @param appdata + * @param docreader + * @return data in object or null if no data is accessible + */ + private DataInput getAppDataAsDataInputStream(AppData appdata, VamsasArchiveReader docreader) { + if (appdata!=null && docreader!=null) { + String entryRef = appdata.getDataReference(); + if (entryRef!=null) { + log.debug("Resolving AppData reference for "+entryRef); + InputStream jstrm = docreader.getAppdataStream(entryRef); + if (jstrm!=null) + return new AppDataInputStream(jstrm); + else { + log.debug("Returning null input stream for unresolved reference ("+entryRef+") id="+appdata.getVorbaId()); + return null; + } + } else { + // return a byteArray input stream + byte[] data=appdata.getData(); + if (data.length>0) { + ByteArrayInputStream stream = new ByteArrayInputStream(data); + return new DataInputStream(stream); + } else { + log.debug("Returning null input stream for empty Appdata data block in id="+appdata.getVorbaId()); + return null; + } + } + } else { + log.debug("Returning null DataInputStream for appdata entry:"+appdata.getVorbaId()); + } + return null; + } + + /** + * internal method for getting ByteArray from AppData object + * @param clientOrUser - true for returning userData, otherwise return Client AppData. + * @return null or byte array + */ + private byte[] _getappdataByteArray(boolean clientOrUser) { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + byte[] data=null; + String appdName; + if (!clientOrUser) { + appdName = "Client's Appdata"; + } else { + appdName = "User's Appdata"; + } + log.debug("getting "+appdName+" as a byte array"); + extractAppData(clientdoc.getVamsasDocument()); + AppData object; + if (!clientOrUser) { + object = appsGlobal; + } else { + object = usersData; + } + if (object!=null) { + log.debug("Trying to resolve "+appdName+" object to byte array."); + data = getAppDataAsByteArray(object, clientdoc.getVamsasArchiveReader()); + } + if (data == null) + log.debug("Returning null for "+appdName+"ClientAppdata byte[] array"); + return data; + + } + + /** + * common method for Client and User AppData->InputStream accessor + * @param clientOrUser - the appData to resolve - false for client, true for user appdata. + * @return null or the DataInputStream desired. + */ + private DataInput _getappdataInputStream(boolean clientOrUser) { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + String appdName; + if (!clientOrUser) { + appdName = "Client's Appdata"; + } else { + appdName = "User's Appdata"; + } + if (log.isDebugEnabled()) + log.debug("getting "+appdName+" as an input stream."); + extractAppData(clientdoc.getVamsasDocument()); + AppData object; + if (!clientOrUser) { + object = appsGlobal; + } else { + object = usersData; + } + if (object!=null) { + log.debug("Trying to resolve ClientAppdata object to an input stream."); + return getAppDataAsDataInputStream(object, clientdoc.getVamsasArchiveReader()); + } + log.debug("getClientInputStream returning null."); + return null; + } + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getClientAppdata() + */ + public byte[] getClientAppdata() { + return _getappdataByteArray(false); + } + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getClientInputStream() + */ + public DataInput getClientInputStream() { + return _getappdataInputStream(false); + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getUserAppdata() + */ + public byte[] getUserAppdata() { + return _getappdataByteArray(true); + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getUserInputStream() + */ + public DataInput getUserInputStream() { + return _getappdataInputStream(true); + } + /** + * methods for writing new AppData entries. + */ + private DataOutput _getAppdataOutputStream(boolean clientOrUser) { + String apdname; + SessionFile apdfile=null; + if (!clientOrUser) { + apdname = "clientAppData"; + apdfile = newAppData; + } else { + apdname = "userAppData"; + apdfile = newUserData; + } + try { + if (apdfile==null) { + apdfile=clientdoc.sclient._session.getTempSessionFile(apdname,".jar"); + log.debug("Successfully made temp appData file for "+apdname); + } else { + // truncate to remove existing data. + apdfile.fileLock.getRaFile().setLength(0); + log.debug("Successfully truncated existing temp appData for "+apdname); + } + } catch (Exception e) { + log.error("Whilst opening temp file in directory "+clientdoc.sclient._session.sessionDir, e); + } + // we do not make another file for the new entry if one exists already + if (!clientOrUser) { + newAppData = apdfile; + } else { + newUserData = apdfile; + } + try { + apdfile.lockFile(); + // LATER: Refactor these local AppDatastream IO stuff to their own class. + JarOutputStream dstrm = + new JarOutputStream(apdfile.fileLock.getBufferedOutputStream(true)); + if (!clientOrUser) { + newAppDataStream = dstrm; + } else { + newUserDataStream = dstrm; + } + dstrm.putNextEntry(new JarEntry("appData_entry.dat")); + // LATER: there may be trouble ahead if an AppDataOutputStream is written to by one thread when another truncates the file. This situation should be prevented if possible + return new AppDataOutputStream(dstrm); + } + catch (Exception e) { + log.error("Whilst opening jar output stream for file "+apdfile.sessionFile); + } + // tidy up and return null + apdfile.unlockFile(); + return null; + } + /** + * copy data from the appData jar file to an appropriately + * referenced jar or Data entry for the given ApplicationData + * Assumes the JarFile is properly closed. + * @param vdoc session Document handler + * @param appd the AppData whose block is being updated + * @param apdjar the new data in a Jar written by this class + */ + protected void updateAnAppdataEntry(VamsasArchive vdoc, AppData appd, SessionFile apdjar) throws IOException { + if (apdjar==null || apdjar.sessionFile==null || !apdjar.sessionFile.exists()) { + throw new IOException("No temporary Appdata to recover and transfer."); + } + if (vdoc==null) { + log.fatal("FATAL! NO DOCUMENT TO WRITE TO!"); + throw new IOException("FATAL! NO DOCUMENT TO WRITE TO!"); + } + log.debug("Recovering AppData entry from "+apdjar.sessionFile); + JarInputStream istrm = new JarInputStream(apdjar.getBufferedInputStream(true)); + JarEntry je=null; + while (istrm.available()>0 && (je=istrm.getNextJarEntry())!=null && !je.getName().equals("appData_entry.dat")) { + if (je!=null) + log.debug("Ignoring extraneous entry "+je.getName()); + } + if (istrm.available()>0 && je!=null) { + log.debug("Found appData_entry.dat in Jar"); + String ref = appd.getDataReference(); + if (ref==null) { + throw new IOException("Null AppData.DataReference passed."); + } + if (vdoc.writeAppdataFromStream(ref, istrm)) { + log.debug("Entry updated successfully."); + } else { + throw new IOException("writeAppdataFromStream did not return true - expect future badness."); // LATER - verify why this might occur. + } + } else { + throw new IOException("Couldn't find appData_entry.dat in temporary jar file "+apdjar.sessionFile.getAbsolutePath()); + } + istrm.close(); + } + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getClientOutputStream() + */ + public DataOutput getClientOutputStream() { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + if (log.isDebugEnabled()) + log.debug("trying to getClientOutputStream for "+clientdoc.sclient.client.getClientUrn()); + return _getAppdataOutputStream(false); + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#getUserOutputStream() + */ + public DataOutput getUserOutputStream() { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + if (log.isDebugEnabled()) + log.debug("trying to getUserOutputStream for (" + +clientdoc.sclient.getUserHandle().getFullName()+")"+clientdoc.sclient.client.getClientUrn()); + return _getAppdataOutputStream(true); + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#hasClientAppdata() + */ + public boolean hasClientAppdata() { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + extractAppData(clientdoc.getVamsasDocument()); + // LATER - check validity of a DataReference before we return true + if ((appsGlobal!=null) && (appsGlobal.getDataReference()!=null || appsGlobal.getData()!=null)) + return true; + return false; + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#hasUserAppdata() + */ + public boolean hasUserAppdata() { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + extractAppData(clientdoc.getVamsasDocument()); + // LATER - check validity of a DataReference before we return true + if ((appsGlobal!=null) && (appsGlobal.getDataReference()!=null || appsGlobal.getData()!=null)) + return true; + return false; + } + private boolean _writeAppDataStream(JarOutputStream ostrm, byte[] data) { + try { + if (data!=null && data.length>0) + ostrm.write(data); + ostrm.closeEntry(); + return true; + } + catch (Exception e) { + log.error("Serious! - IO error when writing AppDataStream to file "+newAppData.sessionFile, e); + } + return false; + } + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#setClientAppdata(byte[]) + */ + public void setClientAppdata(byte[] data) { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + _getAppdataOutputStream(false); + if (newAppDataStream==null) { + // LATER: define an exception for this ? - operation may fail even if file i/o not involved + log.error("Serious! - couldn't open new AppDataStream in session directory "+clientdoc.sclient._session.sessionDir); + } else { + _writeAppDataStream(newAppDataStream, data); + // LATER: deal with error case - do we make session read only, or what ? + } + } + + /* (non-Javadoc) + * @see org.vamsas.client.IClientAppdata#setUserAppdata(byte[]) + */ + public void setUserAppdata(byte[] data) { + if (clientdoc==null) + throw new Error("Implementation error, Improperly initialized SimpleClientAppdata."); + _getAppdataOutputStream(true); + if (newUserDataStream==null) { + // LATER: define an exception for this ? - operation may fail even if file i/o not involved + log.error("Serious! - couldn't open new UserDataStream in session directory "+clientdoc.sclient._session.sessionDir); + } else { + _writeAppDataStream(newUserDataStream, data); + // LATER: deal with error case - do we make session read only, or what ? + } + } + /** + * flush and close outstanding output streams. + * - do this before checking data length. + * @throws IOException + */ + protected void closeForWriting() throws IOException { + if (newAppDataStream!=null) { + newAppDataStream.flush(); + newAppDataStream.closeEntry(); + newAppDataStream.close(); + } + if (newUserDataStream!=null) { + newUserDataStream.flush(); + newUserDataStream.closeEntry(); + newUserDataStream.close(); + } + } + + + /** + * + * @return true if any AppData blocks have to be updated in session Jar + */ + protected boolean isModified() { + // LATER differentiate between core xml modification and Jar Entry modification. + if (newAppData.sessionFile.exists() || newUserData.sessionFile.exists()) + return true; + return false; + } + /* (non-Javadoc) + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + if (newAppDataStream!=null) { + newAppDataStream = null; + } + if (newAppDataStream!=null) { + newUserDataStream = null; + } + if (newAppData!=null) { + newAppData.eraseExistence(); + newAppData = null; + } + if (newUserData!=null) { + newUserData.eraseExistence(); + newUserData = null; + } + super.finalize(); + } + +} diff --git a/src/org/vamsas/client/simpleclient/SimpleClientFactory.java b/src/org/vamsas/client/simpleclient/SimpleClientFactory.java new file mode 100644 index 0000000..6f5509a --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SimpleClientFactory.java @@ -0,0 +1,262 @@ +/* +* VAMSAS Project +* + +* +* Dec 13, 2006 +* +*/ + +package org.vamsas.client.simpleclient; + +import java.io.File; + +import java.io.IOException; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.ClientHandle; +import org.vamsas.client.IClient; +import org.vamsas.client.IClientFactory; +import org.vamsas.client.InvalidSessionUrnException; +import org.vamsas.client.NoDefaultSessionException; +import org.vamsas.client.SessionHandle; +import org.vamsas.client.UserHandle; + +/** + * + * + */ +public class SimpleClientFactory implements IClientFactory { + + private static Log log = LogFactory.getLog(SimpleClientFactory.class); + + private File sessionArena = null; + + private String vamsasSubdirectoryName = ".vamsas"; + + private SessionsFile sessionFile = null; + private static final String SESSION_LIST="sessions.obj"; + + //private String[] currentlyAvailableDessions = null; + + /** + * default constructor - called by CreateClientFactory only. + * + *Inits the sessionarena to the directory .vamsas of the user home directory. + * + */ + public SimpleClientFactory() throws IOException + { + // sessionArena + + //retrieves user home directory + String userHomeDirectory = System.getProperty("user.home"); + if (userHomeDirectory == null || userHomeDirectory.length()<1) + { + new IOException("Unable to detect user home directory"); + } + String sessionArenaPath = userHomeDirectory.concat(File.separator.concat(this.vamsasSubdirectoryName)); + + this.initSessionArena(sessionArenaPath); + this.initFactoryObjects(); + } + + + /** + * Create a client factory that works with sessions at the given + * path. + * @param path path to directory called session arena, where will be created session directories and session files. + */ + public SimpleClientFactory(String path) throws IOException + { + this.initSessionArena(path); + } + /** + * Inits sessionArena to a given path. + * checks if path is valid. + * + * @param path path to a directory to use + * @throws IOException if the path is incorrect + */ + private void initSessionArena (String path) throws IOException + { + // Check path is valid and read/writeable. + File arenaFile = new File (path); + if (!arenaFile.exists()) + { + if (! arenaFile.mkdirs()) + { + this.sessionArena = null; + throw(new IOException("Unable to create a directory called "+path)); + } + } + if (arenaFile.exists() && arenaFile.isDirectory() && arenaFile.canRead() && arenaFile.canWrite()) + { + this.sessionArena = arenaFile; + } + else + { + this.sessionArena = null; + throw(new IOException("Cannot read and write to a directory called "+path)); + } + } + + /** + * construct SessionFile objects and watchers for each + */ + private void initFactoryObjects() throws IOException { + if (this.sessionFile!=null ) + throw new IOException("initFactoryObjects called for initialised ClientFactory object."); + this.sessionFile = new SessionsFile(new File(this.sessionArena,SESSION_LIST)); + + } + /** + * @see org.vamsas.client.IClientFactory#getCurrentSessions() + */ + public String[] getCurrentSessions() + { + String[] sessions = null; + if (this.sessionFile!=null ) + { + SessionHandle[] sessionHandles = this.sessionFile.retrieveSessionsList(); + if (sessionHandles != null) + { + sessions = new String[sessionHandles.length]; + for (int i = sessionHandles.length -1; i > 0; i--) + { + SessionHandle sessionHandle = sessionHandles[i]; + sessions [i] = sessionHandle.getSessionUrn(); + } + } + } + return sessions; + } + + + private void discoverSession() + { + + } + + /** + * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle) + * + * Creates a IClient object, using default UserHandle with system variables:"user.name" or "USERNAME")), + "host.name" or "HOSTNAME" + */ + public IClient getIClient(ClientHandle applicationHandle) + throws NoDefaultSessionException { + + return this.getIClient(applicationHandle, (UserHandle) null); + } + + /** + * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, java.lang.String) + */ + public IClient getIClient(ClientHandle applicationHandle, String sessionUrn) { + // TODO Auto-generated method stub + return null; + } + + /** + * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, org.vamsas.client.UserHandle, java.lang.String) + */ + public IClient getIClient(ClientHandle applicationHandle, UserHandle userId, + String sessionUrn) { + // TODO Auto-generated method stub + return null; + } + + /** + * @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, org.vamsas.client.UserHandle) + */ + public IClient getIClient(ClientHandle applicationHandle, UserHandle userId) + throws NoDefaultSessionException { + SimpleClient client = null; + if (this.sessionArena==null) + throw new Error("Improperly initialised SimpleClientFactory object - null sessionArena."); + + ClientHandle clientHandle =applicationHandle; + //create default clientHandle with "SimpleVamsasClientApp","0.1", + if (clientHandle == null) + clientHandle = new ClientHandle("SimpleVamsasClientApp","0.1"); + + //check if any available session(s) + String[] availableSessions = this.getCurrentSessions(); + if (availableSessions != null) + {//there are available sessions + if (availableSessions.length>1) + {//more than one session if available... can not choose + + //represents list of session as String + StringBuffer sessionURNs = new StringBuffer(""); + for (int i = 0; i< availableSessions.length ; i++) + { + sessionURNs.append(availableSessions[i]+" "); + } + throw new NoDefaultSessionException("Several sessions available, please pick one: "+sessionURNs); + } + + //check if only one session available. if yes, open it + if (availableSessions.length == 1) + { + //only one session available, open it. + return this.getIClient(clientHandle, availableSessions[0]); + } + } + //no session available - create a new one + + + try + { + //create sessionDirectory + File sessdir = File.createTempFile("sess", ".simpleclient", this.sessionArena); + log.debug("Creating new session directory"); + if (!(sessdir.delete() && sessdir.mkdir())) + throw new IOException("Could not make session directory "+sessdir); + //create session + VamsasSession vamsasSession = new VamsasSession(sessdir); + + this.getSessionFile().addSession(new SessionHandle(new SessionUrn(vamsasSession).getSessionUrn()), false); + if (userId == null) + { + //create a default userHandle + //with current OS user and hostname + userId = new UserHandle(System.getProperty("user.name", System.getProperty("USERNAME","Joe Doe")), + System.getProperty("host.name",System.getProperty("HOSTNAME", "Unknown") ));// clientName, clientVersion, sessionPath); + } + + + //create simple client + client = new SimpleClient(userId, clientHandle, vamsasSession); + } + catch (IOException e) + { + log.error("error while creating new IClient",e); + } + catch (InvalidSessionUrnException e) + { + log.error("Unable to create new IClient. The session urn is incorrect ",e); + } + + return client; + } + + + /** + * @return the sessionFile + */ + private SessionsFile getSessionFile() throws IOException + { + if (this.sessionFile == null) + { + this.sessionFile = new SessionsFile( new File (this.sessionArena, SESSION_LIST)); + } + return this.sessionFile; + } + + + +} diff --git a/src/org/vamsas/client/simpleclient/SimpleDocBinding.java b/src/org/vamsas/client/simpleclient/SimpleDocBinding.java new file mode 100644 index 0000000..c0c8084 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/SimpleDocBinding.java @@ -0,0 +1,138 @@ +package org.vamsas.client.simpleclient; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Vector; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.Vobject; +import org.vamsas.client.VorbaIdFactory; +import org.vamsas.client.VorbaXmlBinder; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.objects.utils.AppDataReference; +import org.vamsas.objects.utils.DocumentStuff; +import org.vamsas.objects.utils.ProvenanceStuff; +import org.vamsas.objects.utils.document.VersionEntries; + +/** + * Base class for SimpleClient Vamsas Document Object Manipulation + * holds static vamsasDocument from XML routines and + * state objects for a particular unmarshalled Document instance. + * @author jimp + */ + + +public class SimpleDocBinding { + + protected VorbaIdFactory vorba; + protected static Log log = LogFactory.getLog(SimpleDocBinding.class); + + /** + * @return Returns the vorba. + */ + public VorbaIdFactory getVorba() { + return vorba; + } + + /** + * @param vorba The vorba to set. + */ + public void setVorba(VorbaIdFactory vorba) { + this.vorba = vorba; + } + + /** + * Uses VorbaXmlBinder to retrieve the VamsasDocument from the given stream + */ + public VamsasDocument getVamsasDocument(VamsasArchiveReader oReader) throws IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + if (oReader!=null) { + // check the factory + if (vorba==null) { + log.error("Invalid SimpleDocument construction - no VorbaIdFactory defined!"); + return null; + } + + if (oReader.isValid()) { + // Read vamsasDocument.xsd instance + InputStreamReader vdoc = new InputStreamReader(oReader.getVamsasDocumentStream()); + Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vdoc, vorba, new VamsasDocument()); + if (unmarsh==null) + log.fatal("Couldn't unmarshall document!"); + + Vobject vobjs = (Vobject) unmarsh[0]; + if (vobjs!=null) { + VamsasDocument doc=(VamsasDocument) vobjs; + if (doc!=null) + return doc; + } + log.debug("Found no VamsasDocument object in properly formatted Vamsas Archive."); + } else { + // deprecated data handler (vamsas.xsd instance) + InputStream vxmlis = oReader.getVamsasXmlStream(); + if (vxmlis!=null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(oReader.getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + Object unmarsh[] = VorbaXmlBinder.getVamsasObjects(vxml, vorba, new VAMSAS()); + + if (unmarsh==null) + log.fatal("Couldn't unmarshall document!"); + + VAMSAS root[]= new VAMSAS[] { null}; + root[0] = (VAMSAS) unmarsh[0]; + + if (root[0]==null) { + log.debug("Found no VAMSAS object in VamsasXML stream."); + } else { + log.debug("Making new VamsasDocument from VamsasXML stream."); + VamsasDocument doc = DocumentStuff.newVamsasDocument(root, + ProvenanceStuff.newProvenance( + vorba.getUserHandle().getFullName(), + "Vamsas Document constructed from vamsas.xml"), VersionEntries.ALPHA_VERSION); + // VAMSAS: decide on 'system' operations provenance form + // LATER: implement classes for translating Vorba properties into provenance user fields. + // VAMSAS: decide on machine readable info embedding in provenance should be done + root[0]=null; + root=null; + return doc; + } + } + } + } + // otherwise - there was no valid original document to read. + return null; + } + + /** + * Extract all jarEntries in an archive referenced by the vamsas document + * LATER: a family of methods for finding extraneous jarEntries , and invalid appDataReferences + * @param doc + * @param oReader + * @return array of the subset of JarEntry names that are referenced in doc + */ + public Vector getReferencedEntries(VamsasDocument doc, VamsasArchiveReader oReader) { + if (oReader==null) + return null; + if (doc==null) { + try { doc = getVamsasDocument(oReader); } + catch (Exception e) { log.warn("Failed to get document from "+oReader.jfile.getName()); }; + } + Vector docrefs = AppDataReference.getAppDataReferences(doc); + if (docrefs==null) + return null; + Vector entries = oReader.getExtraEntries(); + if (entries!=null && docrefs.size()>0) { + int i=0, j=entries.size(); + do { + if (!docrefs.contains(entries.get(i))) { + entries.remove(i); + j--; + } else + i++; + } while (iarchive + * @throws IOException + */ + public VamsasArchive(File archive, boolean overwrite, boolean vamsasdocument, SessionFile extantLock) throws IOException { + super(); + if (archive==null || (archive!=null && !(archive.getAbsoluteFile().getParentFile().canWrite() && (!archive.exists() || archive.canWrite())))) { + log.fatal("Expect Badness! -- Invalid parameters for VamsasArchive constructor:"+((archive!=null) + ? "File cannot be overwritten." : "Null Object not valid constructor parameter")); + return; + } + + this.vamsasdocument = vamsasdocument; + if (archive.exists() && !overwrite) { + this.original = archive; + if (extantLock!=null) { + this.odoclock = extantLock; + if (odoclock.fileLock==null || !odoclock.fileLock.isLocked()) + odoclock.lockFile(); + } else { + this.odoclock = new SessionFile(archive); + } + odoclock.lockFile(); // lock the file *immediatly* + this.archive = null; // archive will be a temp file when the open method is called + virginArchive=false; + try { + this.accessOriginal(); + } catch (IOException e) { + throw new IOException("Lock failed for existing archive"+archive); + } + } else { + this.original = null; + this.archive = archive; // archive is written in place. + if (extantLock!=null) + rchive=extantLock; + else + rchive = new SessionFile(archive); + rchive.lockFile(); + if (rchive.fileLock==null || !rchive.fileLock.isLocked()) + throw new IOException("Lock failed for new archive"+archive); + rchive.fileLock.getRaFile().setLength(0); // empty the archive. + virginArchive = true; + } + this.openArchive(); // open archive + } + /** + * open original archive file for exclusive (locked) reading. + * @throws IOException + */ + private void accessOriginal() throws IOException { + if (original!=null && original.exists()) { + if (odoclock==null) + odoclock = new SessionFile(original); + odoclock.lockFile(); + if (odoc == null) + odoc = new VamsasArchiveReader(original); + // this constructor is not implemented yet odoc = new VamsasArchiveReader(odoclock.fileLock); + } + } + + /** + * Add unique entry strings to internal JarEntries list. + * @param entry + * @return true if entry was unique and was added. + */ + private boolean addEntry(String entry) { + if (entries!=null) + entries=new Hashtable(); + if (entries.containsKey(entry)) + return false; + entries.put(entry, new Integer(entries.size())); + return true; + } + /** + * adds named entry to newarchive or returns false. + * @param entry + * @return true if entry was unique and could be added + * @throws IOException if entry name was invalid or a new entry could not be made on newarchive + */ + private boolean addValidEntry(String entry) throws IOException { + JarEntry je = new JarEntry(entry); + if (!addEntry(entry)) + return false; + newarchive.flush(); + newarchive.putNextEntry(je); + return true; + } + /** + * called by app to get name of backup if it was made. + * If this is called, the caller app *must* delete the backup themselves. + * @return null or a valid file object + */ + public File backupFile() { + + if (!virginArchive) { + makeBackup(); + donotdeletebackup=false; // external reference has been made. + return ((original!=null) ? originalBackup : null); + } + return null; + } + + /** + * Stops any current write to archive, and reverts to the backup if it exists. + * All existing locks on the original will be released. All backup files are removed. + */ + public boolean cancelArchive() { + if (newarchive!=null) { + try { + newarchive.closeEntry(); + newarchive.putNextEntry(new JarEntry("deleted")); + newarchive.closeEntry(); + newarchive.close(); + + } catch (Exception e) { + log.debug("Whilst closing newarchive",e); + }; + if (!virginArchive) { + // then there is something to recover. + try { + recoverBackup(); + } + catch (Exception e) { + log.warn("Problems when trying to cancel Archive "+archive.getAbsolutePath(), e); + return false; + } + } + + } else { + log.warn("Client Error: cancelArchive called before archive("+original.getAbsolutePath()+") has been opened!"); + } + closeAndReset(); // tidy up and release locks. + return true; + } + + /** + * only do this if you want to destroy the current file output stream + * + */ + private void closeAndReset() { + if (rchive!=null) { + rchive.unlockFile(); + rchive=null; + } + if (original!=null) { + if (odoc!=null) { + odoc.close(); + odoc=null; + } + if (archive!=null) + archive.delete(); + if (odoclock!=null) { + odoclock.unlockFile(); + odoclock = null; + } + } + removeBackup(); + newarchive=null; + original=null; + entries=null; + } + /** + * Tidies up and closes archive, removing any backups that were created. + * NOTE: It is up to the caller to delete the original archive backup obtained from backupFile() + * TODO: ensure all extant AppDataReference jar entries are transferred to new Jar + * TODO: provide convenient mechanism for generating new unique AppDataReferences and adding them to the document + */ + public void closeArchive() throws IOException { + if (newarchive!=null) { + newarchive.flush(); + newarchive.closeEntry(); + if (!isDocumentWritten()) + log.warn("Premature closure of archive '"+archive.getAbsolutePath()+"': No document has been written."); + newarchive.finish();// close(); // use newarchive.finish(); for a stream IO + newarchive.flush(); + // + updateOriginal(); + closeAndReset(); + } else { + log.warn("Attempt to close archive that has not been opened for writing."); + } + } + /** + * Opens and returns the applicationData output stream for the appdataReference string. + * @param appdataReference + * @return Output stream to write to + * @throws IOException + */ + public AppDataOutputStream getAppDataStream(String appdataReference) throws IOException { + if (newarchive==null) + throw new IOException("Attempt to write to closed VamsasArchive object."); + if (addValidEntry(appdataReference)) { + return new AppDataOutputStream(newarchive); + } + return null; + } + + /** + * + * @return JarEntry name for the vamsas XML stream in this archive + */ + protected String getDocumentJarEntry() { + if (vamsasdocument) + return VamsasArchiveReader.VAMSASDOC; + return VamsasArchiveReader.VAMSASXML; + } + /** + * Safely initializes the VAMSAS XML document Jar Entry. + * @return Writer to pass to the marshalling function. + * @throws IOException if a document entry has already been written. + */ + public PrintWriter getDocumentOutputStream() throws IOException { + if (newarchive==null) + openArchive(); + if (!isDocumentWritten()) { + try { + if (addValidEntry(getDocumentJarEntry())) + return new PrintWriter(new java.io.OutputStreamWriter(newarchive, "UTF-8")); + } catch (Exception e) { + log.warn("Problems opening XML document JarEntry stream",e); + } + } else { + throw new IOException("Vamsas Document output stream is already written."); + } + return null; + } + + /** + * Access original archive if it exists, pass the reader to the client + * Note: this is NOT thread safe and a call to closeArchive() will by necessity + * close and invalidate the VamsasArchiveReader object. + * @return null if no original archive exists. + */ + public VamsasArchiveReader getOriginalArchiveReader() throws IOException { + if (!virginArchive) { + accessOriginal(); + return odoc; + } + return null; + } + /** + * returns original document's root vamsas elements. + * @return + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public Vobject[] getOriginalRoots() throws IOException, + org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + return VamsasArchive.getOriginalRoots(this); + } + /** + * @return original document or a new empty document (with default provenance) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public VamsasDocument getVamsasDocument() throws IOException, + org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + return getVamsasDocument("org.vamsas.simpleclient.VamsasArchive", "Created new empty document", null); + } + /** + * Return the original document or a new empty document with initial provenance entry. + * @param provenance_user (null sets user to be the class name) + * @param provenance_action (null sets action to be 'created new document') + * @param version (null means use latest version) + * @return (original document or a new vamsas document with supplied provenance and version info) + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public VamsasDocument getVamsasDocument(String provenance_user, String provenance_action, String version) 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; + // validate parameters + if (provenance_user==null) + provenance_user = "org.vamsas.simpleclient.VamsasArchive"; + if (provenance_action == null) + provenance_action="Created new empty document"; + if (version==null) + version = VersionEntries.latestVersion(); + // Create a new document and return it + _doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { new VAMSAS()}, + ProvenanceStuff.newProvenance(provenance_user, provenance_action), version); + return _doc; + } + /** + * @return Returns the current VorbaIdFactory for the archive. + */ + public VorbaIdFactory getVorba() { + if (vorba==null) + vorba = new SimpleDocument("simpleclient.VamsasArchive"); + return vorba.getVorba(); + } + /** + * @return true if Vamsas Document has been written to archive + */ + protected boolean isDocumentWritten() { + if (newarchive==null) + log.warn("isDocumentWritten() called for unopened archive."); + if (entries!=null) { + if (entries.containsKey(getDocumentJarEntry())) + return true; + } + return false; + } + private void makeBackup() { + if (!virginArchive) { + if (originalBackup==null && original!=null && original.exists()) { + try { + accessOriginal(); + originalBackup = odoclock.backupSessionFile(null, original.getName(), ".bak", original.getParentFile()); + } + catch (IOException e) { + log.warn("Problem whilst making a backup of original archive.",e); + } + } + } + } + /** + * opens the new archive ready for writing. If the new archive is replacing an existing one, + * then the existing archive will be locked, and the new archive written to a temporary file. + * The new archive will be put in place once close() is called. + * @param doclock LATER - pass existing lock on document, if it exists.... no need yet? + * @throws IOException + */ + private void openArchive() throws IOException { + + if (newarchive!=null) { + log.warn("openArchive() called multiple times."); + throw new IOException("Vamsas Archive '"+archive.getAbsolutePath()+"' is already open."); + } + if (archive==null && (virginArchive || original==null)) { + log.warn("openArchive called on uninitialised VamsasArchive object."); + throw new IOException("Badly initialised VamsasArchive object - no archive file specified."); + } + if (!virginArchive) { + // lock the original + accessOriginal(); + // make a temporary file to write to + archive = File.createTempFile(original.getName(), ".new",original.getParentFile()); + } else { + if (archive.exists()) + log.warn("New archive file name already in use! Possible lock failure imminent?"); + } + + if (rchive==null) + rchive = new SessionFile(archive); + if (!rchive.lockFile()) + throw new IOException("Failed to get lock on file "+archive); + // LATER: locked IO stream based access. + Manifest newmanifest = new Manifest(); + newarchive = new JarOutputStream(rchive.fileLock.getBufferedOutputStream(true), newmanifest); + //newarchive = new JarOutputStream(new BufferedOutputStream(new java.io.FileOutputStream(archive))); + entries = new Hashtable(); + } + public void putVamsasDocument(VamsasDocument doc) throws IOException, + org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + putVamsasDocument(doc, getVorba()); + } + /** + * + * @param doc + * @param vorba + * @return (vorbaId string, Vobjhash) pairs for last hash of each object in document + * @throws IOException + * @throws org.exolab.castor.xml.MarshalException + * @throws org.exolab.castor.xml.ValidationException + */ + public void putVamsasDocument(VamsasDocument doc, VorbaIdFactory vorba) throws IOException, + org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + if (vamsasdocument) + doc.setVersion(VersionEntries.latestVersion()); // LATER: ensure this does the correct thing. + VorbaXmlBinder.putVamsasDocument(getDocumentOutputStream(), vorba, doc); + } + + /** + * recovers the original file's contents from the (temporary) backup. + * @throws Exception if any SessionFile or file removal operations fail. + */ + private void recoverBackup() throws Exception { + if (originalBackup!=null) { + // backup has been made. + // revert from backup and delete it (changing backup filename) + if (rchive==null) { + rchive = new SessionFile(original); + } + SessionFile bckup = new SessionFile(originalBackup); + + rchive.updateFrom(null, bckup); // recover from backup file. + bckup.unlockFile(); + bckup=null; + removeBackup(); + } + } + + /** + * forget about any backup that was made - removing it first if it was only temporary. + */ + private void removeBackup() { + if (originalBackup!=null) { + log.debug("Removing backup in "+originalBackup.getAbsolutePath()); + if (!donotdeletebackup) + if (!originalBackup.delete()) + log.info("VamsasArchive couldn't remove temporary backup "+originalBackup.getAbsolutePath()); + originalBackup=null; + } + } + /** + * @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(); + } + /** + * Convenience method to copy over the referred entry from the backup to the new version. + * Warning messages are raised if no backup exists or the + * entry doesn't exist in the backed-up original. + * Duplicate writes return true - but a warning message will also be raised. + * @param AppDataReference + * @return true if AppDataReference now exists in the new document + * @throws IOException + */ + public boolean transferAppDataEntry(String AppDataReference) throws IOException { + return transferAppDataEntry(AppDataReference, AppDataReference); + } + /** + * Validates the AppDataReference: not null and not already written to archive. + * @param AppDataReference + * @return true if valid. false if not + * @throws IOException for really broken references! + */ + protected boolean _validNewAppDataReference(String newAppDataReference) throws IOException { + // LATER: Specify valid AppDataReference form in all VamsasArchive handlers + if (newAppDataReference==null) + throw new IOException("null newAppDataReference!"); + if (entries.containsKey(newAppDataReference)) { + log.warn("Attempt to write '"+newAppDataReference+"' twice! - IGNORED"); + // LATER: fix me? warning message should raise an exception here. + return false; + } + return true; + } + /** + * Transfers an AppDataReference from old to new vamsas archive, with a name change. + * @see transferAppDataEntry(String AppDataReference) + * @param AppDataReference + * @param NewAppDataReference - AppDataReference in new Archive + * @return + * @throws IOException + */ + public boolean transferAppDataEntry(String AppDataReference, String NewAppDataReference) throws IOException { + if (original==null || !original.exists()) { + log.warn("No backup archive exists."); + return false; + } + if (AppDataReference==null) + throw new IOException("null AppDataReference!"); + + if (!_validNewAppDataReference(NewAppDataReference)) + return false; + + accessOriginal(); + + java.io.InputStream adstream = odoc.getAppdataStream(AppDataReference); + + if (adstream==null) { + log.warn("AppDataReference '"+AppDataReference+"' doesn't exist in backup archive."); + return false; + } + + java.io.OutputStream adout = getAppDataStream(NewAppDataReference); + // copy over the bytes + int written=-1; + long count=0; + byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a sensible buffer + do { + if ((written = adstream.read(buffer))>-1) { + adout.write(buffer, 0, written); + log.debug("Transferring "+written+"."); + count+=written; + } + } while (written>-1); + log.debug("Sucessfully transferred AppData for '" + +AppDataReference+"' as '"+NewAppDataReference+"' ("+count+" bytes)"); + return true; + } + /** + * write data from a stream into an appData reference. + * @param AppDataReference - New AppDataReference not already written to archive + * @param adstream Source of data for appData reference - read until .read(buffer) returns -1 + * @return true on success. + * @throws IOException for file IO or invalid AppDataReference string + */ + public boolean writeAppdataFromStream(String AppDataReference, java.io.InputStream adstream) throws IOException { + if (!_validNewAppDataReference(AppDataReference)) { + log.warn("Invalid AppDataReference passed to writeAppdataFromStream"); + throw new IOException("Invalid AppDataReference! (null, or maybe non-unique)!"); + } + + if (AppDataReference==null) { + log.warn("null appdata passed."); + throw new IOException("Null AppDataReference"); + } + + java.io.OutputStream adout = getAppDataStream(AppDataReference); + // copy over the bytes + int written=-1; + long count=0; + byte[] buffer = new byte[_TRANSFER_BUFFER]; // conservative estimate of a sensible buffer + do { + if ((written = adstream.read(buffer))>-1) { + adout.write(buffer, 0, written); + log.debug("Transferring "+written+"."); + count+=written; + } + } while (written>-1); + return true; + } + /** + * transfers any AppDataReferences existing in the old document + * that haven't already been transferred to the new one + * LATER: do the same for transfers requiring a namechange - more document dependent. + * @return true if data was transferred. + */ + public boolean transferRemainingAppDatas() throws IOException { + boolean transfered=false; + if (original==null || !original.exists()) { + log.warn("No backup archive exists."); + return false; + } + accessOriginal(); + + if (getVorba()!=null) { + Vector originalRefs=null; + try { + originalRefs = vorba.getReferencedEntries(getVamsasDocument(), getOriginalArchiveReader()); + } catch (Exception e) { + log.warn("Problems accessing original document entries!",e); + } + if (originalRefs!=null) { + Iterator ref = originalRefs.iterator(); + while (ref.hasNext()) { + String oldentry = (String) ref.next(); + if (oldentry!=null && !entries.containsKey(oldentry)) { + log.debug("Transferring remaining entry '"+oldentry+"'"); + transfered |= transferAppDataEntry(oldentry); + } + } + } + } + return transfered; + } + /** + * called after archive is written to put file in its final place + */ + private void updateOriginal() { + if (!virginArchive) { + // make sure original document really is backed up and then overwrite it. + if (odoc!=null) { + // try to shut the odoc reader. + odoc.close(); + odoc = null; + } + // Make a backup if it isn't done already + makeBackup(); + try { + // copy new Archive data that was writen to a temporary file + odoclock.updateFrom(null, rchive); + } + catch (IOException e) { + // LATER: decide if leaving nastily named backup files around is necessary. + File backupFile=backupFile(); + if (backupFile!=null) + log.error("Problem updating archive from temporary file! - backup left in '" + +backupFile().getAbsolutePath()+"'",e); + else + log.error("Problems updating, and failed to even make a backup file. Ooops!", e); + } + // Tidy up if necessary. + removeBackup(); + } else { + + + } + } +} diff --git a/src/org/vamsas/client/simpleclient/VamsasArchiveReader.java b/src/org/vamsas/client/simpleclient/VamsasArchiveReader.java new file mode 100644 index 0000000..2df47f5 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/VamsasArchiveReader.java @@ -0,0 +1,313 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.RandomAccessFile; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.objects.utils.document.VersionEntries; +/** + * Basic methods for accessing an existing Vamsas Archive, + * and Jar entry names for creating new vamsas archives. + * + * @author jimp + * + */ +public class VamsasArchiveReader { + private static Log log = LogFactory.getLog(VamsasArchiveReader.class); + JarFile jfile=null; + boolean stream=false; // true if we are seeking on the stream. + RandomAccessFile rfile; + ZipInputStream jstream=null; + Hashtable strmentries = null; + private void streamInit() { + //throw new Error("VamsasArchiveReader(Stream) Not implemented!"); + if (!stream) { + log.debug("Skipping init for Jar Stream input."); + return; + } + strmentries = new Hashtable(); + log.debug("Jar Stream input Initialisation"); + try { + rfile.seek(0); + // no buffering - we need to be able to move around the random access stream. + jstream = new ZipInputStream(new FileInputStream(rfile.getFD())); // no manifest (probably) + if (jstream.available()==0) + log.warn("Can't read from JarInputStream (Locked stream!)"); + ZipEntry entry=null; + long pos=0; + do { + if ((entry=jstream.getNextEntry())!=null) { + if (strmentries.containsKey(entry.getName())) { + log.info("Only recording last of duplicate entries '"+entry.getName()+"'"); + } + strmentries.put(entry.getName(), new Long(pos++)); + jstream.closeEntry(); + } + } while (entry!=null); + } + catch (Exception e) { + log.warn("Exceptions during init!",e); + jstream=null; + } + } + + public VamsasArchiveReader(File vamsasfile) { + jfile=null; + if (vamsasfile.exists()) { + try { + jfile=new JarFile(vamsasfile); + } + catch (Exception e) { + log.debug("non-serious? couldn't open new JarFile on "+vamsasfile,e); + jfile=null; + } + } + + } + /** + * in an ideal world - this constructor will create a reader object + * for the locked file's random access stream. + * + * @param vamsaslock + */ + public VamsasArchiveReader(Lock vamsaslock) { + // LATER: implement or remove + if (vamsaslock==null || !vamsaslock.isLocked()) + throw new Error("IMPLEMENTATION ERROR: Cannot create a VamsasArchiveReader without a valid lock."); + // throw new Error("VamsasArchiveReading from locked IO stream not yet implemented."); + try { + rfile = vamsaslock.getRaFile(); + } catch (Exception e) { + log.warn("Unexpected IO Exception when accessing locked vamsas archive stream "+vamsaslock.target,e); + } + stream = true; + streamInit(); + if (jstream==null) + throw new Error("Failed to open archive from Locked random access stream."); + } + + /** + * the vamsas document version(s) handled by this Reader + */ + final public static String DOCUMENT_VERSION=VersionEntries.BETA_VERSION; + /** + * name of the jarEntry containing a well formatted vamsas XML Document + */ + + final public static String VAMSASDOC="vamsasDocument.xml"; + + /** + * name of the jarEntry containing a root VAMSAS element, and containing a + * random sequence of VAMSAS DataSet elements + */ + + final public static String VAMSASXML="vamsas.xml"; + /** + * seeks jstream to the given entry name and reads it. + * @param entryname + * @return + */ + private JarEntry seekEntry(String entryname) { + if (jstream==null) + return null; + if (!strmentries.containsKey(entryname)) + return null; + Long entrypos = (Long) strmentries.get(entryname); + if (entrypos==null) { + log.error("Null entry position for "+entryname); + return null; + } + try { + jstream=null; + rfile.seek(0); + jstream = new ZipInputStream(new FileInputStream(rfile.getFD())); + ZipEntry entry = null; + long epos = entrypos.longValue(); + do { + entry = jstream.getNextEntry(); + } while (entry!=null && --epos>=0); + // rfile.seek(entrypos.longValue()); + // make a Jar entry from a zip entry. + return new JarEntry(entry); + } + catch (Exception e) { + log.warn("Whilst seeking for "+entryname, e); + } + return null; + } + /** + * + * @return JarEntry for VamsasArchiveReader.VAMSASDOC + */ + protected JarEntry getVamsasDocumentEntry() { + return getJarEntry(VAMSASDOC); + } + /** + * + * @return JarEntry for VamsasArchiveReader.VAMSASXML + */ + protected JarEntry getVamsasXmlEntry() { + return getJarEntry(VAMSASXML); + } + /** + * Test for valid vamsas document archive + * @return true if getVamsasDocumentStream will return a stream likely to contain valid XML + */ + public boolean isValid() { + // TODO: check if VAMSASDOC is well formed (follows www.vamsas.ac.uk/schemas/vamsasDocument.xsd) and all appData references are resolvable - preferably as jar entries + if (jfile!=null || jstream!=null) + return (getVamsasDocumentEntry()!=null); + return false; + } + + + protected JarEntry getAppdataEntry(String AppdataRef) { + JarEntry entry; + if ((jfile==null && jstream==null) || !isValid() || (entry=getJarEntry(AppdataRef))==null) + return null; + + return entry; + } + + public InputStream getAppdataStream(String AppdataRef) { + JarEntry entry=getAppdataEntry(AppdataRef); + try { + if (entry!=null) + return getInputStream(entry); + } catch (IOException e) { + log.error("Failed when opening AppdataStream for "+AppdataRef, e); + } + return null; + } + /** + * get the VamsasDocument input stream, if it exists. + * @return null or valid input stream + */ + public InputStream getVamsasDocumentStream() { + InputStream vdoc; + if ((jfile==null && jstream==null) || !isValid()) + return null; + try { + vdoc = getInputStream(getVamsasDocumentEntry()); + } catch (IOException e) { + log.error("Whilst geting document stream",e); + vdoc=null; + } + return vdoc; + } + + /** + * get the VamsasXML input stream, if it exists. + * Note: Deprecated beyond our prealpha testing. + * @return null or valid input stream. + */ + + public InputStream getVamsasXmlStream() { + // log.warn("Deprecated call"); + JarEntry xmle=getVamsasXmlEntry(); + InputStream vdoc; + if (xmle==null) + return null; + try { + vdoc = getInputStream(xmle); + } catch (IOException e) { + log.error("Whilst getting VamsasXmlStream",e); + vdoc=null; + } + return vdoc; + } + + /** + * silently close the jar file. + * + */ + public void close() { + if (jfile!=null) { + try { + jfile.close(); + } catch (IOException e) { + log.error("Whilst closing JarFile "+jfile.getName(), e); + } + } + if (jstream!=null) { + try { + jstream.closeEntry(); + jstream=null; + // LATER: reference counting for random access file instances is necessary. + } + catch (Exception e) { + log.error("Whilst finishing reading from jar input stream",e); + } + } + } + + /** + * returns all entries not matching the filespec of a vamsas xml entry + * @return array of entries. + */ + public Vector getExtraEntries() { + if ((jfile==null && jstream==null)|| !isValid()) + return null; + Vector e = new Vector(); + if (jstream!=null) { + Enumeration entries = strmentries.keys(); + if (entries!=null && entries.hasMoreElements()) { + do { + JarEntry el = (JarEntry) entries.nextElement(); + if (!el.getName().equals(VAMSASDOC) && !el.getName().equals(VAMSASXML)) + e.add(new String(el.getName())); // avoid references + } while (entries.hasMoreElements()); + } + } else { + Enumeration entries = jfile.entries(); + if (entries!=null && entries.hasMoreElements()) { + do { + JarEntry el = (JarEntry) entries.nextElement(); + if (!el.getName().equals(VAMSASDOC) && !el.getName().equals(VAMSASXML)) + e.add(new String(el.getName())); // avoid references + } while (entries.hasMoreElements()); + } + return e; + } + return null; + } + + /* (non-Javadoc) + * @see java.util.jar.JarFile#getInputStream(java.util.zip.ZipEntry) + */ + private InputStream getInputStream(ZipEntry ze) throws IOException { + if (jfile!=null) + return jfile.getInputStream(ze); + if (jstream!=null) { + seekEntry(ze.getName()); + return new AppDataInputStream(jstream); + } + return null; + } + + /* (non-Javadoc) + * @see java.util.jar.JarFile#getJarEntry(java.lang.String) + */ + private JarEntry getJarEntry(String name) { + if (jfile!=null) + return jfile.getJarEntry(name); + if (jstream!=null) + return seekEntry(name); + return null; + } + } diff --git a/src/org/vamsas/client/simpleclient/VamsasFile.java b/src/org/vamsas/client/simpleclient/VamsasFile.java new file mode 100644 index 0000000..3dd2581 --- /dev/null +++ b/src/org/vamsas/client/simpleclient/VamsasFile.java @@ -0,0 +1,100 @@ + +package org.vamsas.client.simpleclient; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.util.Timer; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; + +import org.vamsas.objects.core.LockFileDescriptor; + +/** + * low level vamsas document management routines + * analogous to ClientsFile + * Grew out of io tests on VamsasArchive class in org.vamsas.test.simpleclient.VamsasArchive + * This class is not thread safe. + * @author jimp + * + */ +public class VamsasFile extends SessionFile { + /** + * + * Connect to an existing Vamsas document in a given sessionDir + * or create a new one. + * + * @param sessionDir + * @throws java.io.IOException + */ + public VamsasFile(File sessionFile) throws java.io.IOException { + super(sessionFile); + } + /** + * + * @return the VamsasFile + */ + public File getVamsasFile() { + return sessionFile; + } + /** + * Expand a previously stored session into the sessionDir + * @param sessionDir + * @param storedSession + + public VamsasFile(File sessionDir, JarFile storedSession) throws IOException { + // check if sessionDir is live or not + if (!sessionDir.exists()) { + sessionDir.mkdir(); + } + + { + // check its actually a writable directory + } + + File sfile = new File(sessionDir, "vamsas.jar"); + VamsasFile(sfile); + // if live - try to merge storedSession with sessionDir + // - will probably fail through duplicate Vobject references needing to be dereferenced. + // TODO: think of a way of specifying vorba_id scope for an application's references to allow merging of one vamsasDocument with another. + + } + */ + /** + * public interface for getting a lock. + * The lock object is internally referenced + * so the lock will persist even after the + * return value of the method goes out of scope. + * @return null if lock couldn't be got or a valid Lock object. + */ + public Lock getLock() { + if (lockFile()) + return fileLock; + return null; + } + /** + * + * @param extantLock + * @return null, extantLock or new Lock. + */ + public Lock getLock(Lock extantLock) { + if (lockFile(extantLock)) + return fileLock; + return null; + } + /** + * explicitly unlocks vamsas file. + * if you have called getLock() you *must* + * call this to release the lock. + */ + public void unLock() { + this.unlockFile(); + } + +} diff --git a/src/org/vamsas/client/simpleclient/VamsasSession.java b/src/org/vamsas/client/simpleclient/VamsasSession.java new file mode 100644 index 0000000..a5359ad --- /dev/null +++ b/src/org/vamsas/client/simpleclient/VamsasSession.java @@ -0,0 +1,312 @@ +package org.vamsas.client.simpleclient; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.RandomAccessFile; +import java.io.Writer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Appender; +import org.apache.log4j.Logger; +import org.apache.log4j.FileAppender; +import org.vamsas.client.ClientHandle; +import org.vamsas.client.UserHandle; +/** + * Does all the IO operations for a SimpleClient instance accessing + * a SimpleClient vamsas session. + * + * Basically, it defines the various standard names for the files + * in the session directory (that maps to the sessionUrn), + * provides constructors for the file handlers and watchers of + * those file entities, and some higher level methods + * to check and change the state flags for the session. + * + * TODO: move the stuff below to the SimpleClientFactory documentation. + * much may not be valid now : + * Vamsas client is intialised with a path to create live session directories. + * This path may contain a vamsas.properties file + * that sets additional parameters (otherwise client + * just uses the one on the classpath). + * + * A vamsas session consists of : + * SessionDir - translates to urn of a live session. + * Contains: Vamsas Document (as a jar), Session client list file, + * both of which may be locked, and additional + * temporary versions of these files when write + * operations are taking place. + * + * Zip file entries + * - vamsasdocument.xml : core info + * one or more: + * - .version.sessionnumber.raw (string given in vamsasdocument.xml applicationData entry) + * + * Lockfile + * - filename given in the vamsasdocument.xml. Should be checked for validity by any client and rewritten if necessary. + * The lockfile can point to the jar itself. + * Mode of operation. + * Initially - documentHandler either: + * - creates a zip for a new session for the client + * - connect to an existing session zip + * 1. reads session urn file + * 2. waits for lock + * 3. examines session - decide whether to create new application data slice or connect to one stored in session. + * 4. writes info into session file + * 5. releases lock and generates local client events. + * 6. Creates Watcher thread to generate events. + * + * During the session + * - Update watcher checks for file change - + * + * Procedures for file based session message exchange + * - session document modification flag + * + */ + +public class VamsasSession { + /** + * indicator file for informing other processes that + * they should finalise their vamsas datasets for + * storing into a vamsas archive. + */ + public static final String CLOSEANDSAVE_FILE="stored.log"; + /** + * session file storing the last_stored_stat data + */ + public static final String MODIFIEDDOC_FILE="modified"; + + /** + * called to clear update flag after a successful offline storage event + */ + protected void clearUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, MODIFIEDDOC_FILE)); + if (!laststored.clearFlag()) + log.warn("Unsaved flag was not cleared for "+sessionDir); + } + /** + * called to indicate session document has been modified. + * + */ + protected void setUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, MODIFIEDDOC_FILE)); + if (!laststored.setFlag()) + log.warn("Couldn't set the Unsaved flag for "+sessionDir); + } + /** + * + * @return true if session document has been modified since last offline storage event + */ + protected boolean getUnsavedFlag() { + SessionFlagFile laststored = new SessionFlagFile(new File(sessionDir, MODIFIEDDOC_FILE)); + return laststored.checkFlag(); + } + /** + * log file location + */ + public static final String SESSION_LOG="Log.txt"; + private static Log log = LogFactory.getLog(VamsasSession.class); + protected Logger slog = Logger.getLogger("org.vamsas.client.SessionLog"); + /** + * setup the sessionLog using Log4j. + * @throws IOException + */ + private void initLog() throws IOException { + // LATER: make dedicated appender format for session log. + Appender app = slog.getAppender("SESSION_LOG"); + slog.addAppender(new FileAppender(app.getLayout(), new File(sessionDir, SESSION_LOG).getAbsolutePath())); + } + + /** + * the sessionDir is given as the session location for new clients. + */ + protected File sessionDir; + /** + * holds the list of attached clients + */ + ClientsFile clist; + public static final String CLIENT_LIST="Clients.obj"; + /** + * holds the data + */ + VamsasFile vamArchive; + public static final String VAMSAS_OBJ="VamDoc.jar"; + + /** + * sets up the vamsas session files and watchers in sessionDir + * @param sessionDir + */ + protected VamsasSession(File sessionDir) throws IOException { + if (sessionDir==null) + throw new Error("Null directory for VamsasSession."); + if (sessionDir.exists()) { + if (!sessionDir.isDirectory() || !sessionDir.canWrite() || !sessionDir.canRead()) + throw new IOException("Cannot access '"+sessionDir+"' as a read/writable Directory."); + if (checkSessionFiles(sessionDir)) { + // session files exist in the directory + this.sessionDir = sessionDir; + initSessionObjects(); + slog.debug("Initialising additional VamsasSession instance"); + log.debug("Attached to VamsasSession in "+sessionDir); + } + } else { + // start from scratch + if (!sessionDir.mkdir()) + throw new IOException("Failed to make VamsasSession directory in "+sessionDir); + this.sessionDir = sessionDir; + createSessionFiles(); + initSessionObjects(); + slog.debug("Session directory created."); + log.debug("Initialised VamsasSession in "+sessionDir); + } + } + /** + * tests presence of existing sessionfiles files in dir + * @param dir + * @return + */ + private boolean checkSessionFiles(File dir) throws IOException { + File c_file = new File(dir,CLIENT_LIST); + File v_doc = new File(dir,VAMSAS_OBJ); + if (c_file.exists() && v_doc.exists()) + return true; + return false; + } + /** + * create new empty files in dir + * + */ + private void createSessionFiles() throws IOException { + if (sessionDir==null) + throw new IOException("Invalid call to createSessionFiles() with null sessionDir"); + File c_file = new File(sessionDir,CLIENT_LIST); + File v_doc = new File(sessionDir,VAMSAS_OBJ); + if (c_file.createNewFile()) + log.debug("Created new ClientFile "+c_file); // don't care if this works or not + if (v_doc.createNewFile()) + log.debug("Created new Vamsas Session Document File "+v_doc); + } + /** + * construct SessionFile objects and watchers for each + */ + private void initSessionObjects() throws IOException { + if (clist!=null || vamArchive!=null) + throw new IOException("initSessionObjects called for initialised VamsasSession object."); + clist = new ClientsFile(new File(sessionDir,CLIENT_LIST)); + vamArchive = new VamsasFile(new File(sessionDir,VAMSAS_OBJ)); + initLog(); + } + /** + * make a new watcher object for the clientFile + * @return new ClientFile watcher instance + */ + public FileWatcher getClientWatcher() { + return new FileWatcher(clist.sessionFile); + } + FileWatcher session_doc_watcher=null; + /** + * make a new watcher object for the vamsas Document + * @return new ClientFile watcher instance + */ + public FileWatcher getDocWatcher() { + if (session_doc_watcher==null) + return session_doc_watcher = new FileWatcher(vamArchive.sessionFile); + return new FileWatcher(vamArchive.sessionFile); + } + FileWatcher store_doc_file=null; + /** + * make a new watcher object for the messages file + * (thread safe - keeps a reference to the first watcher) + * @return new watcher instance + */ + public FileWatcher getStoreWatcher() { + if (store_doc_file==null) + return store_doc_file = new FileWatcher(new File(CLOSEANDSAVE_FILE)); + return new FileWatcher(new File(CLOSEANDSAVE_FILE)); + + } + /** + * write to the StoreWatcher file to indicate that a storeDocumentRequest has been made. + * The local client's storeWatcher FileWatcher object is updated so the initial change is not registered. + * @param client + * @param user + * @return + */ + public void addStoreDocumentRequest(ClientHandle client, UserHandle user) throws IOException { + SessionFile sfw = new SessionFile(new File(sessionDir, CLOSEANDSAVE_FILE)); + while (!sfw.lockFile()) + log.debug("Trying to get lock for "+CLOSEANDSAVE_FILE); + RandomAccessFile sfwfile=sfw.fileLock.getRaFile(); + sfwfile.setLength(0); // wipe out any old info. + // TODO: rationalise what gets written to this file (ie do we want other clients to read the id of the requestor?) + sfwfile.writeUTF(client.getClientUrn()+":"+user.getFullName()+"@"+user.getOrganization()); + sfw.unlockFile(); + if (store_doc_file!=null) + store_doc_file.setState(); + slog.info("FinalizeAppData request from "+user.getFullName()+" using "+client.getClientUrn()+""); + } + /** + * create a new session with an existing vamsas Document - by copying it into the session. + * @param archive + */ + public void setVamsasDocument(File archive) throws IOException { + log.debug("Transferring vamsas data from "+archive+" to session:"+vamArchive.sessionFile); + SessionFile xtantdoc = new SessionFile(archive); + vamArchive.updateFrom(null, xtantdoc); + // LATER: decide if session archive provenance should be updated to reflect access. + // TODO: soon! do a proper import objects from external file + log.debug("Transfer complete."); + } + /** + * write session as a new vamsas Document (this will overwrite any existing file without warning) + * TODO: test + * TODO: verify that lock should be released for vamsas document. + * @param destarchive + */ + protected void writeVamsasDocument(File destarchive, Lock extlock) throws IOException { + log.debug("Transferring vamsas data from "+vamArchive.sessionFile+" to session:"+destarchive); + SessionFile newdoc = new SessionFile(destarchive); + if (extlock==null && !vamArchive.lockFile()) + while (!vamArchive.lockFile()) + log.info("Trying to get lock for "+vamArchive.sessionFile); + // TODO: LATER: decide if session archive provenance should be written in vamsasDocument file for this export. + newdoc.updateFrom(extlock, vamArchive); + // LATER: LATER: fix use of updateFrom for file systems where locks cannot be made (because they don't have a lockManager, ie NFS/Unix, etc). + vamArchive.unLock(); + newdoc.unlockFile(); + log.debug("Transfer complete."); + } + + /** + * Creates a VamsasArchive Vobject for accessing and updating document + * Note: this will lock the Vamsas Document for exclusive access to the client. + * @return session vamsas document + * @throws IOException if locks fail or vamsas document read fails. + */ + protected VamsasArchive getVamsasDocument() throws IOException { + // TODO: check we haven't already done this once + if (!vamArchive.lockFile()) + throw new IOException("Failed to get lock for vamsas archive."); + + VamsasArchive va = new VamsasArchive(vamArchive.sessionFile, false, true, vamArchive); + + return va; + } + /** + * create a uniquely named file in the session Directory + * @see java.io.File.createTempFile + * @param pref Prefix for name + * @param suff Suffix for name + * @return SessionFile object configured for the new file (of length zero) + * @throws IOException + */ + protected SessionFile getTempSessionFile(String pref, String suff) throws IOException { + File tfile = File.createTempFile(pref,suff,sessionDir); + SessionFile tempFile = new SessionFile(tfile); + return tempFile; + } +} + + diff --git a/src/org/vamsas/objects/core/.castor.cdr b/src/org/vamsas/objects/core/.castor.cdr new file mode 100644 index 0000000..8ec2cf3 --- /dev/null +++ b/src/org/vamsas/objects/core/.castor.cdr @@ -0,0 +1,3 @@ +-- listing properties -- +org.vamsas.objects.core.LockFile=org.vamsas.objects.core.LockFileDescr... +org.vamsas.objects.core.VamsasDocument=org.vamsas.objects.core.VamsasDocumen... diff --git a/src/org/vamsas/objects/core/Alignment.java b/src/org/vamsas/objects/core/Alignment.java new file mode 100644 index 0000000..bf70f4e --- /dev/null +++ b/src/org/vamsas/objects/core/Alignment.java @@ -0,0 +1,979 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Alignment. + * + * @version $Revision$ $Date$ + */ +public class Alignment extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _gapChar + */ + private java.lang.String _gapChar; + + /** + * Field _aligned + */ + private boolean _aligned; + + /** + * keeps track of state for field: _aligned + */ + private boolean _has_aligned; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Field _modifiable + */ + private java.lang.String _modifiable; + + /** + * This is annotation over the coordinate frame + * defined by all the columns in the alignment. + * + */ + private java.util.Vector _alignmentAnnotationList; + + /** + * Field _treeList + */ + private java.util.Vector _treeList; + + /** + * Field _alignmentSequenceList + */ + private java.util.Vector _alignmentSequenceList; + + /** + * typical properties may be additional + * alignment score objects + */ + private java.util.Vector _propertyList; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Alignment() + { + super(); + _alignmentAnnotationList = new Vector(); + _treeList = new Vector(); + _alignmentSequenceList = new Vector(); + _propertyList = new Vector(); + } //-- org.vamsas.objects.core.Alignment() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAlignmentAnnotation + * + * + * + * @param vAlignmentAnnotation + */ + public void addAlignmentAnnotation(org.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException + { + _alignmentAnnotationList.addElement(vAlignmentAnnotation); + } //-- void addAlignmentAnnotation(org.vamsas.objects.core.AlignmentAnnotation) + + /** + * Method addAlignmentAnnotation + * + * + * + * @param index + * @param vAlignmentAnnotation + */ + public void addAlignmentAnnotation(int index, org.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException + { + _alignmentAnnotationList.insertElementAt(vAlignmentAnnotation, index); + } //-- void addAlignmentAnnotation(int, org.vamsas.objects.core.AlignmentAnnotation) + + /** + * Method addAlignmentSequence + * + * + * + * @param vAlignmentSequence + */ + public void addAlignmentSequence(org.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException + { + _alignmentSequenceList.addElement(vAlignmentSequence); + } //-- void addAlignmentSequence(org.vamsas.objects.core.AlignmentSequence) + + /** + * Method addAlignmentSequence + * + * + * + * @param index + * @param vAlignmentSequence + */ + public void addAlignmentSequence(int index, org.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException + { + _alignmentSequenceList.insertElementAt(vAlignmentSequence, index); + } //-- void addAlignmentSequence(int, org.vamsas.objects.core.AlignmentSequence) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method addTree + * + * + * + * @param vTree + */ + public void addTree(org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.addElement(vTree); + } //-- void addTree(org.vamsas.objects.core.Tree) + + /** + * Method addTree + * + * + * + * @param index + * @param vTree + */ + public void addTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.insertElementAt(vTree, index); + } //-- void addTree(int, org.vamsas.objects.core.Tree) + + /** + * Method deleteAligned + * + */ + public void deleteAligned() + { + this._has_aligned= false; + } //-- void deleteAligned() + + /** + * Method enumerateAlignmentAnnotation + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAlignmentAnnotation() + { + return _alignmentAnnotationList.elements(); + } //-- java.util.Enumeration enumerateAlignmentAnnotation() + + /** + * Method enumerateAlignmentSequence + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAlignmentSequence() + { + return _alignmentSequenceList.elements(); + } //-- java.util.Enumeration enumerateAlignmentSequence() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Method enumerateTree + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateTree() + { + return _treeList.elements(); + } //-- java.util.Enumeration enumerateTree() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Alignment) { + + Alignment temp = (Alignment)obj; + if (this._gapChar != null) { + if (temp._gapChar == null) return false; + else if (!(this._gapChar.equals(temp._gapChar))) + return false; + } + else if (temp._gapChar != null) + return false; + if (this._aligned != temp._aligned) + return false; + if (this._has_aligned != temp._has_aligned) + return false; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) return false; + else if (!(this._modifiable.equals(temp._modifiable))) + return false; + } + else if (temp._modifiable != null) + return false; + if (this._alignmentAnnotationList != null) { + if (temp._alignmentAnnotationList == null) return false; + else if (!(this._alignmentAnnotationList.equals(temp._alignmentAnnotationList))) + return false; + } + else if (temp._alignmentAnnotationList != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) return false; + else if (!(this._treeList.equals(temp._treeList))) + return false; + } + else if (temp._treeList != null) + return false; + if (this._alignmentSequenceList != null) { + if (temp._alignmentSequenceList == null) return false; + else if (!(this._alignmentSequenceList.equals(temp._alignmentSequenceList))) + return false; + } + else if (temp._alignmentSequenceList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'aligned'. + * + * @return boolean + * @return the value of field 'aligned'. + */ + public boolean getAligned() + { + return this._aligned; + } //-- boolean getAligned() + + /** + * Method getAlignmentAnnotation + * + * + * + * @param index + * @return AlignmentAnnotation + */ + public org.vamsas.objects.core.AlignmentAnnotation getAlignmentAnnotation(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentAnnotationList.size())) { + throw new IndexOutOfBoundsException("getAlignmentAnnotation: Index value '"+index+"' not in range [0.."+_alignmentAnnotationList.size()+ "]"); + } + + return (org.vamsas.objects.core.AlignmentAnnotation) _alignmentAnnotationList.elementAt(index); + } //-- org.vamsas.objects.core.AlignmentAnnotation getAlignmentAnnotation(int) + + /** + * Method getAlignmentAnnotation + * + * + * + * @return AlignmentAnnotation + */ + public org.vamsas.objects.core.AlignmentAnnotation[] getAlignmentAnnotation() + { + int size = _alignmentAnnotationList.size(); + org.vamsas.objects.core.AlignmentAnnotation[] mArray = new org.vamsas.objects.core.AlignmentAnnotation[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.AlignmentAnnotation) _alignmentAnnotationList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.AlignmentAnnotation[] getAlignmentAnnotation() + + /** + * Method getAlignmentAnnotationCount + * + * + * + * @return int + */ + public int getAlignmentAnnotationCount() + { + return _alignmentAnnotationList.size(); + } //-- int getAlignmentAnnotationCount() + + /** + * Method getAlignmentSequence + * + * + * + * @param index + * @return AlignmentSequence + */ + public org.vamsas.objects.core.AlignmentSequence getAlignmentSequence(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentSequenceList.size())) { + throw new IndexOutOfBoundsException("getAlignmentSequence: Index value '"+index+"' not in range [0.."+_alignmentSequenceList.size()+ "]"); + } + + return (org.vamsas.objects.core.AlignmentSequence) _alignmentSequenceList.elementAt(index); + } //-- org.vamsas.objects.core.AlignmentSequence getAlignmentSequence(int) + + /** + * Method getAlignmentSequence + * + * + * + * @return AlignmentSequence + */ + public org.vamsas.objects.core.AlignmentSequence[] getAlignmentSequence() + { + int size = _alignmentSequenceList.size(); + org.vamsas.objects.core.AlignmentSequence[] mArray = new org.vamsas.objects.core.AlignmentSequence[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.AlignmentSequence) _alignmentSequenceList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.AlignmentSequence[] getAlignmentSequence() + + /** + * Method getAlignmentSequenceCount + * + * + * + * @return int + */ + public int getAlignmentSequenceCount() + { + return _alignmentSequenceList.size(); + } //-- int getAlignmentSequenceCount() + + /** + * Returns the value of field 'gapChar'. + * + * @return String + * @return the value of field 'gapChar'. + */ + public java.lang.String getGapChar() + { + return this._gapChar; + } //-- java.lang.String getGapChar() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'modifiable'. + * + * @return String + * @return the value of field 'modifiable'. + */ + public java.lang.String getModifiable() + { + return this._modifiable; + } //-- java.lang.String getModifiable() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Method getTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree getTree(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("getTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + + return (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } //-- org.vamsas.objects.core.Tree getTree(int) + + /** + * Method getTree + * + * + * + * @return Tree + */ + public org.vamsas.objects.core.Tree[] getTree() + { + int size = _treeList.size(); + org.vamsas.objects.core.Tree[] mArray = new org.vamsas.objects.core.Tree[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Tree[] getTree() + + /** + * Method getTreeCount + * + * + * + * @return int + */ + public int getTreeCount() + { + return _treeList.size(); + } //-- int getTreeCount() + + /** + * Method hasAligned + * + * + * + * @return boolean + */ + public boolean hasAligned() + { + return this._has_aligned; + } //-- boolean hasAligned() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAlignmentAnnotation + * + * + * + * @param index + * @return AlignmentAnnotation + */ + public org.vamsas.objects.core.AlignmentAnnotation removeAlignmentAnnotation(int index) + { + java.lang.Object obj = _alignmentAnnotationList.elementAt(index); + _alignmentAnnotationList.removeElementAt(index); + return (org.vamsas.objects.core.AlignmentAnnotation) obj; + } //-- org.vamsas.objects.core.AlignmentAnnotation removeAlignmentAnnotation(int) + + /** + * Method removeAlignmentSequence + * + * + * + * @param index + * @return AlignmentSequence + */ + public org.vamsas.objects.core.AlignmentSequence removeAlignmentSequence(int index) + { + java.lang.Object obj = _alignmentSequenceList.elementAt(index); + _alignmentSequenceList.removeElementAt(index); + return (org.vamsas.objects.core.AlignmentSequence) obj; + } //-- org.vamsas.objects.core.AlignmentSequence removeAlignmentSequence(int) + + /** + * Method removeAllAlignmentAnnotation + * + */ + public void removeAllAlignmentAnnotation() + { + _alignmentAnnotationList.removeAllElements(); + } //-- void removeAllAlignmentAnnotation() + + /** + * Method removeAllAlignmentSequence + * + */ + public void removeAllAlignmentSequence() + { + _alignmentSequenceList.removeAllElements(); + } //-- void removeAllAlignmentSequence() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeAllTree + * + */ + public void removeAllTree() + { + _treeList.removeAllElements(); + } //-- void removeAllTree() + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Method removeTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree removeTree(int index) + { + java.lang.Object obj = _treeList.elementAt(index); + _treeList.removeElementAt(index); + return (org.vamsas.objects.core.Tree) obj; + } //-- org.vamsas.objects.core.Tree removeTree(int) + + /** + * Sets the value of field 'aligned'. + * + * @param aligned the value of field 'aligned'. + */ + public void setAligned(boolean aligned) + { + this._aligned = aligned; + this._has_aligned = true; + } //-- void setAligned(boolean) + + /** + * Method setAlignmentAnnotation + * + * + * + * @param index + * @param vAlignmentAnnotation + */ + public void setAlignmentAnnotation(int index, org.vamsas.objects.core.AlignmentAnnotation vAlignmentAnnotation) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentAnnotationList.size())) { + throw new IndexOutOfBoundsException("setAlignmentAnnotation: Index value '"+index+"' not in range [0.."+_alignmentAnnotationList.size()+ "]"); + } + _alignmentAnnotationList.setElementAt(vAlignmentAnnotation, index); + } //-- void setAlignmentAnnotation(int, org.vamsas.objects.core.AlignmentAnnotation) + + /** + * Method setAlignmentAnnotation + * + * + * + * @param alignmentAnnotationArray + */ + public void setAlignmentAnnotation(org.vamsas.objects.core.AlignmentAnnotation[] alignmentAnnotationArray) + { + //-- copy array + _alignmentAnnotationList.removeAllElements(); + for (int i = 0; i < alignmentAnnotationArray.length; i++) { + _alignmentAnnotationList.addElement(alignmentAnnotationArray[i]); + } + } //-- void setAlignmentAnnotation(org.vamsas.objects.core.AlignmentAnnotation) + + /** + * Method setAlignmentSequence + * + * + * + * @param index + * @param vAlignmentSequence + */ + public void setAlignmentSequence(int index, org.vamsas.objects.core.AlignmentSequence vAlignmentSequence) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentSequenceList.size())) { + throw new IndexOutOfBoundsException("setAlignmentSequence: Index value '"+index+"' not in range [0.."+_alignmentSequenceList.size()+ "]"); + } + _alignmentSequenceList.setElementAt(vAlignmentSequence, index); + } //-- void setAlignmentSequence(int, org.vamsas.objects.core.AlignmentSequence) + + /** + * Method setAlignmentSequence + * + * + * + * @param alignmentSequenceArray + */ + public void setAlignmentSequence(org.vamsas.objects.core.AlignmentSequence[] alignmentSequenceArray) + { + //-- copy array + _alignmentSequenceList.removeAllElements(); + for (int i = 0; i < alignmentSequenceArray.length; i++) { + _alignmentSequenceList.addElement(alignmentSequenceArray[i]); + } + } //-- void setAlignmentSequence(org.vamsas.objects.core.AlignmentSequence) + + /** + * Sets the value of field 'gapChar'. + * + * @param gapChar the value of field 'gapChar'. + */ + public void setGapChar(java.lang.String gapChar) + { + this._gapChar = gapChar; + } //-- void setGapChar(java.lang.String) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable the value of field 'modifiable'. + */ + public void setModifiable(java.lang.String modifiable) + { + this._modifiable = modifiable; + } //-- void setModifiable(java.lang.String) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Method setTree + * + * + * + * @param index + * @param vTree + */ + public void setTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("setTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + _treeList.setElementAt(vTree, index); + } //-- void setTree(int, org.vamsas.objects.core.Tree) + + /** + * Method setTree + * + * + * + * @param treeArray + */ + public void setTree(org.vamsas.objects.core.Tree[] treeArray) + { + //-- copy array + _treeList.removeAllElements(); + for (int i = 0; i < treeArray.length; i++) { + _treeList.addElement(treeArray[i]); + } + } //-- void setTree(org.vamsas.objects.core.Tree) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Alignment + */ + public static org.vamsas.objects.core.Alignment unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Alignment) Unmarshaller.unmarshal(org.vamsas.objects.core.Alignment.class, reader); + } //-- org.vamsas.objects.core.Alignment unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AlignmentAnnotation.java b/src/org/vamsas/objects/core/AlignmentAnnotation.java new file mode 100644 index 0000000..3fb9dfc --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentAnnotation.java @@ -0,0 +1,249 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * This is annotation over the coordinate frame + * defined by all the columns in the alignment. + * + * + * @version $Revision$ $Date$ + */ +public class AlignmentAnnotation extends org.vamsas.objects.core.RangeAnnotation +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * TODO: decide if this flag is + * redundant - when true it would suggest that + * the annotationElement values together form a + * graph + */ + private boolean _graph; + + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentAnnotation() + { + super(); + } //-- org.vamsas.objects.core.AlignmentAnnotation() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteGraph + * + */ + public void deleteGraph() + { + this._has_graph= false; + } //-- void deleteGraph() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof AlignmentAnnotation) { + + AlignmentAnnotation temp = (AlignmentAnnotation)obj; + if (this._graph != temp._graph) + return false; + if (this._has_graph != temp._has_graph) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'graph'. The field 'graph' has + * the following description: TODO: decide if this flag is + * redundant - when true it would suggest that + * the annotationElement values together form a + * graph + * + * @return boolean + * @return the value of field 'graph'. + */ + public boolean getGraph() + { + return this._graph; + } //-- boolean getGraph() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Method hasGraph + * + * + * + * @return boolean + */ + public boolean hasGraph() + { + return this._has_graph; + } //-- boolean hasGraph() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'graph'. The field 'graph' has the + * following description: TODO: decide if this flag is + * redundant - when true it would suggest that + * the annotationElement values together form a + * graph + * + * @param graph the value of field 'graph'. + */ + public void setGraph(boolean graph) + { + this._graph = graph; + this._has_graph = true; + } //-- void setGraph(boolean) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return RangeType + */ + public static org.vamsas.objects.core.RangeType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.AlignmentAnnotation) Unmarshaller.unmarshal(org.vamsas.objects.core.AlignmentAnnotation.class, reader); + } //-- org.vamsas.objects.core.RangeType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AlignmentAnnotationDescriptor.java b/src/org/vamsas/objects/core/AlignmentAnnotationDescriptor.java new file mode 100644 index 0000000..fb81a9a --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentAnnotationDescriptor.java @@ -0,0 +1,255 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AlignmentAnnotationDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AlignmentAnnotationDescriptor extends org.vamsas.objects.core.RangeAnnotationDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentAnnotationDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.RangeAnnotationDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "AlignmentAnnotation"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _graph + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_graph", "graph", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentAnnotation target = (AlignmentAnnotation) object; + if(!target.hasGraph()) + return null; + return (target.getGraph() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setGraph( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _graph + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentAnnotation target = (AlignmentAnnotation) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentAnnotation target = (AlignmentAnnotation) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AlignmentAnnotationDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.AlignmentAnnotation.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/AlignmentDescriptor.java b/src/org/vamsas/objects/core/AlignmentDescriptor.java new file mode 100644 index 0000000..4804a61 --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentDescriptor.java @@ -0,0 +1,503 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AlignmentDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AlignmentDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "Alignment"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _gapChar + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_gapChar", "gapChar", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getGapChar(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.setGapChar( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _gapChar + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _aligned + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_aligned", "aligned", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + if(!target.hasAligned()) + return null; + return (target.getAligned() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteAligned(); + return; + } + target.setAligned( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _aligned + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getModifiable(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.setModifiable( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _alignmentAnnotationList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AlignmentAnnotation.class, "_alignmentAnnotationList", "AlignmentAnnotation", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getAlignmentAnnotation(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.addAlignmentAnnotation( (org.vamsas.objects.core.AlignmentAnnotation) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.AlignmentAnnotation(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _alignmentAnnotationList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getTree(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.addTree( (org.vamsas.objects.core.Tree) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _alignmentSequenceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AlignmentSequence.class, "_alignmentSequenceList", "alignmentSequence", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getAlignmentSequence(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.addAlignmentSequence( (org.vamsas.objects.core.AlignmentSequence) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.AlignmentSequence(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _alignmentSequenceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Alignment target = (Alignment) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Alignment target = (Alignment) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AlignmentDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Alignment.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/AlignmentSequence.java b/src/org/vamsas/objects/core/AlignmentSequence.java new file mode 100644 index 0000000..3a0a72e --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentSequence.java @@ -0,0 +1,385 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class AlignmentSequence. + * + * @version $Revision$ $Date$ + */ +public class AlignmentSequence extends org.vamsas.objects.core.SequenceType +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object + * referencing + */ + private java.lang.String _id; + + /** + * Dataset Sequence from which + * this alignment sequence is taken from + * + */ + private java.lang.Object _refid; + + /** + * Field _alignmentSequenceAnnotationList + */ + private java.util.Vector _alignmentSequenceAnnotationList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentSequence() + { + super(); + _alignmentSequenceAnnotationList = new Vector(); + } //-- org.vamsas.objects.core.AlignmentSequence() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAlignmentSequenceAnnotation + * + * + * + * @param vAlignmentSequenceAnnotation + */ + public void addAlignmentSequenceAnnotation(org.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException + { + _alignmentSequenceAnnotationList.addElement(vAlignmentSequenceAnnotation); + } //-- void addAlignmentSequenceAnnotation(org.vamsas.objects.core.AlignmentSequenceAnnotation) + + /** + * Method addAlignmentSequenceAnnotation + * + * + * + * @param index + * @param vAlignmentSequenceAnnotation + */ + public void addAlignmentSequenceAnnotation(int index, org.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException + { + _alignmentSequenceAnnotationList.insertElementAt(vAlignmentSequenceAnnotation, index); + } //-- void addAlignmentSequenceAnnotation(int, org.vamsas.objects.core.AlignmentSequenceAnnotation) + + /** + * Method enumerateAlignmentSequenceAnnotation + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAlignmentSequenceAnnotation() + { + return _alignmentSequenceAnnotationList.elements(); + } //-- java.util.Enumeration enumerateAlignmentSequenceAnnotation() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof AlignmentSequence) { + + AlignmentSequence temp = (AlignmentSequence)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._refid != null) { + if (temp._refid == null) return false; + else if (!(this._refid.equals(temp._refid))) + return false; + } + else if (temp._refid != null) + return false; + if (this._alignmentSequenceAnnotationList != null) { + if (temp._alignmentSequenceAnnotationList == null) return false; + else if (!(this._alignmentSequenceAnnotationList.equals(temp._alignmentSequenceAnnotationList))) + return false; + } + else if (temp._alignmentSequenceAnnotationList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getAlignmentSequenceAnnotation + * + * + * + * @param index + * @return AlignmentSequenceAnnotation + */ + public org.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentSequenceAnnotationList.size())) { + throw new IndexOutOfBoundsException("getAlignmentSequenceAnnotation: Index value '"+index+"' not in range [0.."+_alignmentSequenceAnnotationList.size()+ "]"); + } + + return (org.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList.elementAt(index); + } //-- org.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation(int) + + /** + * Method getAlignmentSequenceAnnotation + * + * + * + * @return AlignmentSequenceAnnotation + */ + public org.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation() + { + int size = _alignmentSequenceAnnotationList.size(); + org.vamsas.objects.core.AlignmentSequenceAnnotation[] mArray = new org.vamsas.objects.core.AlignmentSequenceAnnotation[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation() + + /** + * Method getAlignmentSequenceAnnotationCount + * + * + * + * @return int + */ + public int getAlignmentSequenceAnnotationCount() + { + return _alignmentSequenceAnnotationList.size(); + } //-- int getAlignmentSequenceAnnotationCount() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'refid'. The field 'refid' has + * the following description: Dataset Sequence from which + * this alignment sequence is taken from + * + * + * @return Object + * @return the value of field 'refid'. + */ + public java.lang.Object getRefid() + { + return this._refid; + } //-- java.lang.Object getRefid() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAlignmentSequenceAnnotation + * + * + * + * @param index + * @return AlignmentSequenceAnnotation + */ + public org.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotation(int index) + { + java.lang.Object obj = _alignmentSequenceAnnotationList.elementAt(index); + _alignmentSequenceAnnotationList.removeElementAt(index); + return (org.vamsas.objects.core.AlignmentSequenceAnnotation) obj; + } //-- org.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotation(int) + + /** + * Method removeAllAlignmentSequenceAnnotation + * + */ + public void removeAllAlignmentSequenceAnnotation() + { + _alignmentSequenceAnnotationList.removeAllElements(); + } //-- void removeAllAlignmentSequenceAnnotation() + + /** + * Method setAlignmentSequenceAnnotation + * + * + * + * @param index + * @param vAlignmentSequenceAnnotation + */ + public void setAlignmentSequenceAnnotation(int index, org.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentSequenceAnnotationList.size())) { + throw new IndexOutOfBoundsException("setAlignmentSequenceAnnotation: Index value '"+index+"' not in range [0.."+_alignmentSequenceAnnotationList.size()+ "]"); + } + _alignmentSequenceAnnotationList.setElementAt(vAlignmentSequenceAnnotation, index); + } //-- void setAlignmentSequenceAnnotation(int, org.vamsas.objects.core.AlignmentSequenceAnnotation) + + /** + * Method setAlignmentSequenceAnnotation + * + * + * + * @param alignmentSequenceAnnotationArray + */ + public void setAlignmentSequenceAnnotation(org.vamsas.objects.core.AlignmentSequenceAnnotation[] alignmentSequenceAnnotationArray) + { + //-- copy array + _alignmentSequenceAnnotationList.removeAllElements(); + for (int i = 0; i < alignmentSequenceAnnotationArray.length; i++) { + _alignmentSequenceAnnotationList.addElement(alignmentSequenceAnnotationArray[i]); + } + } //-- void setAlignmentSequenceAnnotation(org.vamsas.objects.core.AlignmentSequenceAnnotation) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'refid'. The field 'refid' has the + * following description: Dataset Sequence from which + * this alignment sequence is taken from + * + * + * @param refid the value of field 'refid'. + */ + public void setRefid(java.lang.Object refid) + { + this._refid = refid; + } //-- void setRefid(java.lang.Object) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return SequenceType + */ + public static org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.AlignmentSequence) Unmarshaller.unmarshal(org.vamsas.objects.core.AlignmentSequence.class, reader); + } //-- org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AlignmentSequenceAnnotation.java b/src/org/vamsas/objects/core/AlignmentSequenceAnnotation.java new file mode 100644 index 0000000..0f229af --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentSequenceAnnotation.java @@ -0,0 +1,256 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class AlignmentSequenceAnnotation. + * + * @version $Revision$ $Date$ + */ +public class AlignmentSequenceAnnotation extends org.vamsas.objects.core.RangeAnnotation +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * TODO: + * decide if this flag is + * redundant - when true it + * would suggest that the + * annotationElement values + * together form a graph + * + */ + private boolean _graph; + + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentSequenceAnnotation() + { + super(); + } //-- org.vamsas.objects.core.AlignmentSequenceAnnotation() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteGraph + * + */ + public void deleteGraph() + { + this._has_graph= false; + } //-- void deleteGraph() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof AlignmentSequenceAnnotation) { + + AlignmentSequenceAnnotation temp = (AlignmentSequenceAnnotation)obj; + if (this._graph != temp._graph) + return false; + if (this._has_graph != temp._has_graph) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'graph'. The field 'graph' has + * the following description: TODO: + * decide if this flag is + * redundant - when true it + * would suggest that the + * annotationElement values + * together form a graph + * + * + * @return boolean + * @return the value of field 'graph'. + */ + public boolean getGraph() + { + return this._graph; + } //-- boolean getGraph() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Method hasGraph + * + * + * + * @return boolean + */ + public boolean hasGraph() + { + return this._has_graph; + } //-- boolean hasGraph() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'graph'. The field 'graph' has the + * following description: TODO: + * decide if this flag is + * redundant - when true it + * would suggest that the + * annotationElement values + * together form a graph + * + * + * @param graph the value of field 'graph'. + */ + public void setGraph(boolean graph) + { + this._graph = graph; + this._has_graph = true; + } //-- void setGraph(boolean) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return RangeType + */ + public static org.vamsas.objects.core.RangeType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.AlignmentSequenceAnnotation) Unmarshaller.unmarshal(org.vamsas.objects.core.AlignmentSequenceAnnotation.class, reader); + } //-- org.vamsas.objects.core.RangeType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AlignmentSequenceAnnotationDescriptor.java b/src/org/vamsas/objects/core/AlignmentSequenceAnnotationDescriptor.java new file mode 100644 index 0000000..a4aa126 --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentSequenceAnnotationDescriptor.java @@ -0,0 +1,255 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AlignmentSequenceAnnotationDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AlignmentSequenceAnnotationDescriptor extends org.vamsas.objects.core.RangeAnnotationDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentSequenceAnnotationDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.RangeAnnotationDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "AlignmentSequenceAnnotation"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _graph + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_graph", "graph", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + if(!target.hasGraph()) + return null; + return (target.getGraph() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setGraph( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _graph + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentSequenceAnnotation target = (AlignmentSequenceAnnotation) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AlignmentSequenceAnnotationDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.AlignmentSequenceAnnotation.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/AlignmentSequenceDescriptor.java b/src/org/vamsas/objects/core/AlignmentSequenceDescriptor.java new file mode 100644 index 0000000..afbe5cd --- /dev/null +++ b/src/org/vamsas/objects/core/AlignmentSequenceDescriptor.java @@ -0,0 +1,282 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AlignmentSequenceDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AlignmentSequenceDescriptor extends org.vamsas.objects.core.SequenceTypeDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AlignmentSequenceDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.SequenceTypeDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "alignmentSequence"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentSequence target = (AlignmentSequence) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _refid + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_refid", "refid", org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentSequence target = (AlignmentSequence) object; + return target.getRefid(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.setRefid( (java.lang.Object) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _refid + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _alignmentSequenceAnnotationList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AlignmentSequenceAnnotation.class, "_alignmentSequenceAnnotationList", "AlignmentSequenceAnnotation", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AlignmentSequence target = (AlignmentSequence) object; + return target.getAlignmentSequenceAnnotation(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AlignmentSequence target = (AlignmentSequence) object; + target.addAlignmentSequenceAnnotation( (org.vamsas.objects.core.AlignmentSequenceAnnotation) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.AlignmentSequenceAnnotation(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _alignmentSequenceAnnotationList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AlignmentSequenceDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.AlignmentSequence.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/AnnotationElement.java b/src/org/vamsas/objects/core/AnnotationElement.java new file mode 100644 index 0000000..b2ed9c5 --- /dev/null +++ b/src/org/vamsas/objects/core/AnnotationElement.java @@ -0,0 +1,673 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class AnnotationElement. + * + * @version $Revision$ $Date$ + */ +public class AnnotationElement extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * position with respect to the coordinate frame defined by a + * rangeType specification + */ + private int _position; + + /** + * keeps track of state for field: _position + */ + private boolean _has_position; + + /** + * true means the annotation element appears between the + * specified position and the next + */ + private boolean _after = false; + + /** + * keeps track of state for field: _after + */ + private boolean _has_after; + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Free text at this position + */ + private java.lang.String _description; + + /** + * Discrete symbol - possibly graphically represented + * + */ + private java.util.Vector _glyphList; + + /** + * Ordered set of float values - an application may treat + * the values together as a vector with common support for a + * set of + * annotation elements - but this is, again, not validated so + * applications + * should deal gracefully with varying numbers of dimensions + * + */ + private java.util.Vector _valueList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AnnotationElement() + { + super(); + _glyphList = new Vector(); + _valueList = new Vector(); + } //-- org.vamsas.objects.core.AnnotationElement() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addGlyph + * + * + * + * @param vGlyph + */ + public void addGlyph(org.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException + { + _glyphList.addElement(vGlyph); + } //-- void addGlyph(org.vamsas.objects.core.Glyph) + + /** + * Method addGlyph + * + * + * + * @param index + * @param vGlyph + */ + public void addGlyph(int index, org.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException + { + _glyphList.insertElementAt(vGlyph, index); + } //-- void addGlyph(int, org.vamsas.objects.core.Glyph) + + /** + * Method addValue + * + * + * + * @param vValue + */ + public void addValue(float vValue) + throws java.lang.IndexOutOfBoundsException + { + _valueList.addElement(new java.lang.Float(vValue)); + } //-- void addValue(float) + + /** + * Method addValue + * + * + * + * @param index + * @param vValue + */ + public void addValue(int index, float vValue) + throws java.lang.IndexOutOfBoundsException + { + _valueList.insertElementAt(new java.lang.Float(vValue), index); + } //-- void addValue(int, float) + + /** + * Method deleteAfter + * + */ + public void deleteAfter() + { + this._has_after= false; + } //-- void deleteAfter() + + /** + * Method deletePosition + * + */ + public void deletePosition() + { + this._has_position= false; + } //-- void deletePosition() + + /** + * Method enumerateGlyph + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateGlyph() + { + return _glyphList.elements(); + } //-- java.util.Enumeration enumerateGlyph() + + /** + * Method enumerateValue + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateValue() + { + return _valueList.elements(); + } //-- java.util.Enumeration enumerateValue() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof AnnotationElement) { + + AnnotationElement temp = (AnnotationElement)obj; + if (this._position != temp._position) + return false; + if (this._has_position != temp._has_position) + return false; + if (this._after != temp._after) + return false; + if (this._has_after != temp._has_after) + return false; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._description != null) { + if (temp._description == null) return false; + else if (!(this._description.equals(temp._description))) + return false; + } + else if (temp._description != null) + return false; + if (this._glyphList != null) { + if (temp._glyphList == null) return false; + else if (!(this._glyphList.equals(temp._glyphList))) + return false; + } + else if (temp._glyphList != null) + return false; + if (this._valueList != null) { + if (temp._valueList == null) return false; + else if (!(this._valueList.equals(temp._valueList))) + return false; + } + else if (temp._valueList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'after'. The field 'after' has + * the following description: true means the annotation element + * appears between the + * specified position and the next + * + * @return boolean + * @return the value of field 'after'. + */ + public boolean getAfter() + { + return this._after; + } //-- boolean getAfter() + + /** + * Returns the value of field 'description'. The field + * 'description' has the following description: Free text at + * this position + * + * @return String + * @return the value of field 'description'. + */ + public java.lang.String getDescription() + { + return this._description; + } //-- java.lang.String getDescription() + + /** + * Method getGlyph + * + * + * + * @param index + * @return Glyph + */ + public org.vamsas.objects.core.Glyph getGlyph(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _glyphList.size())) { + throw new IndexOutOfBoundsException("getGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]"); + } + + return (org.vamsas.objects.core.Glyph) _glyphList.elementAt(index); + } //-- org.vamsas.objects.core.Glyph getGlyph(int) + + /** + * Method getGlyph + * + * + * + * @return Glyph + */ + public org.vamsas.objects.core.Glyph[] getGlyph() + { + int size = _glyphList.size(); + org.vamsas.objects.core.Glyph[] mArray = new org.vamsas.objects.core.Glyph[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Glyph) _glyphList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Glyph[] getGlyph() + + /** + * Method getGlyphCount + * + * + * + * @return int + */ + public int getGlyphCount() + { + return _glyphList.size(); + } //-- int getGlyphCount() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'position'. The field 'position' + * has the following description: position with respect to the + * coordinate frame defined by a + * rangeType specification + * + * @return int + * @return the value of field 'position'. + */ + public int getPosition() + { + return this._position; + } //-- int getPosition() + + /** + * Method getValue + * + * + * + * @param index + * @return float + */ + public float getValue(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _valueList.size())) { + throw new IndexOutOfBoundsException("getValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]"); + } + + return ((java.lang.Float)_valueList.elementAt(index)).floatValue(); + } //-- float getValue(int) + + /** + * Method getValue + * + * + * + * @return float + */ + public float[] getValue() + { + int size = _valueList.size(); + float[] mArray = new float[size]; + for (int index = 0; index < size; index++) { + mArray[index] = ((java.lang.Float)_valueList.elementAt(index)).floatValue(); + } + return mArray; + } //-- float[] getValue() + + /** + * Method getValueCount + * + * + * + * @return int + */ + public int getValueCount() + { + return _valueList.size(); + } //-- int getValueCount() + + /** + * Method hasAfter + * + * + * + * @return boolean + */ + public boolean hasAfter() + { + return this._has_after; + } //-- boolean hasAfter() + + /** + * Method hasPosition + * + * + * + * @return boolean + */ + public boolean hasPosition() + { + return this._has_position; + } //-- boolean hasPosition() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllGlyph + * + */ + public void removeAllGlyph() + { + _glyphList.removeAllElements(); + } //-- void removeAllGlyph() + + /** + * Method removeAllValue + * + */ + public void removeAllValue() + { + _valueList.removeAllElements(); + } //-- void removeAllValue() + + /** + * Method removeGlyph + * + * + * + * @param index + * @return Glyph + */ + public org.vamsas.objects.core.Glyph removeGlyph(int index) + { + java.lang.Object obj = _glyphList.elementAt(index); + _glyphList.removeElementAt(index); + return (org.vamsas.objects.core.Glyph) obj; + } //-- org.vamsas.objects.core.Glyph removeGlyph(int) + + /** + * Method removeValue + * + * + * + * @param index + * @return float + */ + public float removeValue(int index) + { + java.lang.Object obj = _valueList.elementAt(index); + _valueList.removeElementAt(index); + return ((java.lang.Float)obj).floatValue(); + } //-- float removeValue(int) + + /** + * Sets the value of field 'after'. The field 'after' has the + * following description: true means the annotation element + * appears between the + * specified position and the next + * + * @param after the value of field 'after'. + */ + public void setAfter(boolean after) + { + this._after = after; + this._has_after = true; + } //-- void setAfter(boolean) + + /** + * Sets the value of field 'description'. The field + * 'description' has the following description: Free text at + * this position + * + * @param description the value of field 'description'. + */ + public void setDescription(java.lang.String description) + { + this._description = description; + } //-- void setDescription(java.lang.String) + + /** + * Method setGlyph + * + * + * + * @param index + * @param vGlyph + */ + public void setGlyph(int index, org.vamsas.objects.core.Glyph vGlyph) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _glyphList.size())) { + throw new IndexOutOfBoundsException("setGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]"); + } + _glyphList.setElementAt(vGlyph, index); + } //-- void setGlyph(int, org.vamsas.objects.core.Glyph) + + /** + * Method setGlyph + * + * + * + * @param glyphArray + */ + public void setGlyph(org.vamsas.objects.core.Glyph[] glyphArray) + { + //-- copy array + _glyphList.removeAllElements(); + for (int i = 0; i < glyphArray.length; i++) { + _glyphList.addElement(glyphArray[i]); + } + } //-- void setGlyph(org.vamsas.objects.core.Glyph) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'position'. The field 'position' has + * the following description: position with respect to the + * coordinate frame defined by a + * rangeType specification + * + * @param position the value of field 'position'. + */ + public void setPosition(int position) + { + this._position = position; + this._has_position = true; + } //-- void setPosition(int) + + /** + * Method setValue + * + * + * + * @param index + * @param vValue + */ + public void setValue(int index, float vValue) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _valueList.size())) { + throw new IndexOutOfBoundsException("setValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]"); + } + _valueList.setElementAt(new java.lang.Float(vValue), index); + } //-- void setValue(int, float) + + /** + * Method setValue + * + * + * + * @param valueArray + */ + public void setValue(float[] valueArray) + { + //-- copy array + _valueList.removeAllElements(); + for (int i = 0; i < valueArray.length; i++) { + _valueList.addElement(new java.lang.Float(valueArray[i])); + } + } //-- void setValue(float) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AnnotationElement + */ + public static org.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.AnnotationElement) Unmarshaller.unmarshal(org.vamsas.objects.core.AnnotationElement.class, reader); + } //-- org.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AnnotationElementDescriptor.java b/src/org/vamsas/objects/core/AnnotationElementDescriptor.java new file mode 100644 index 0000000..cc7bb65 --- /dev/null +++ b/src/org/vamsas/objects/core/AnnotationElementDescriptor.java @@ -0,0 +1,405 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AnnotationElementDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AnnotationElementDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AnnotationElementDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "annotationElement"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _position + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_position", "position", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + if(!target.hasPosition()) + return null; + return new java.lang.Integer(target.getPosition()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setPosition( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _position + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _after + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_after", "after", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + if(!target.hasAfter()) + return null; + return (target.getAfter() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteAfter(); + return; + } + target.setAfter( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _after + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + return target.getDescription(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + target.setDescription( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _glyphList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Glyph.class, "_glyphList", "glyph", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + return target.getGlyph(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + target.addGlyph( (org.vamsas.objects.core.Glyph) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Glyph(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _glyphList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _valueList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(float.class, "_valueList", "value", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AnnotationElement target = (AnnotationElement) object; + return target.getValue(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AnnotationElement target = (AnnotationElement) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.addValue( ((java.lang.Float)value).floatValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _valueList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + FloatValidator typeValidator = new FloatValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AnnotationElementDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.AnnotationElement.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/AppData.java b/src/org/vamsas/objects/core/AppData.java new file mode 100644 index 0000000..168bc6b --- /dev/null +++ b/src/org/vamsas/objects/core/AppData.java @@ -0,0 +1,239 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class AppData. + * + * @version $Revision$ $Date$ + */ +public class AppData extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Internal choice value storage + */ + private java.lang.Object _choiceValue; + + /** + * Field _data + */ + private byte[] _data; + + /** + * Field _dataReference + */ + private java.lang.String _dataReference; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AppData() + { + super(); + } //-- org.vamsas.objects.core.AppData() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof AppData) { + + AppData temp = (AppData)obj; + if (this._choiceValue != null) { + if (temp._choiceValue == null) return false; + else if (!(this._choiceValue.equals(temp._choiceValue))) + return false; + } + else if (temp._choiceValue != null) + return false; + if (this._data != null) { + if (temp._data == null) return false; + else if (!(this._data.equals(temp._data))) + return false; + } + else if (temp._data != null) + return false; + if (this._dataReference != null) { + if (temp._dataReference == null) return false; + else if (!(this._dataReference.equals(temp._dataReference))) + return false; + } + else if (temp._dataReference != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'choiceValue'. The field + * 'choiceValue' has the following description: Internal choice + * value storage + * + * @return Object + * @return the value of field 'choiceValue'. + */ + public java.lang.Object getChoiceValue() + { + return this._choiceValue; + } //-- java.lang.Object getChoiceValue() + + /** + * Returns the value of field 'data'. + * + * @return byte + * @return the value of field 'data'. + */ + public byte[] getData() + { + return this._data; + } //-- byte[] getData() + + /** + * Returns the value of field 'dataReference'. + * + * @return String + * @return the value of field 'dataReference'. + */ + public java.lang.String getDataReference() + { + return this._dataReference; + } //-- java.lang.String getDataReference() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'data'. + * + * @param data the value of field 'data'. + */ + public void setData(byte[] data) + { + this._data = data; + this._choiceValue = data; + } //-- void setData(byte) + + /** + * Sets the value of field 'dataReference'. + * + * @param dataReference the value of field 'dataReference'. + */ + public void setDataReference(java.lang.String dataReference) + { + this._dataReference = dataReference; + this._choiceValue = dataReference; + } //-- void setDataReference(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.AppData) Unmarshaller.unmarshal(org.vamsas.objects.core.AppData.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AppDataDescriptor.java b/src/org/vamsas/objects/core/AppDataDescriptor.java new file mode 100644 index 0000000..d0eeab9 --- /dev/null +++ b/src/org/vamsas/objects/core/AppDataDescriptor.java @@ -0,0 +1,250 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AppDataDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AppDataDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AppDataDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "appData"; + + //-- set grouping compositor + setCompositorAsChoice(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- initialize element descriptors + + //-- _data + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(byte[].class, "_data", "data", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AppData target = (AppData) object; + return target.getData(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AppData target = (AppData) object; + target.setData( (byte[]) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _data + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _dataReference + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dataReference", "dataReference", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + AppData target = (AppData) object; + return target.getDataReference(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + AppData target = (AppData) object; + target.setDataReference( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _dataReference + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.AppDataDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.AppData.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/ApplicationData.java b/src/org/vamsas/objects/core/ApplicationData.java new file mode 100644 index 0000000..76f44be --- /dev/null +++ b/src/org/vamsas/objects/core/ApplicationData.java @@ -0,0 +1,572 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class ApplicationData. + * + * @version $Revision$ $Date$ + */ +public class ApplicationData extends org.vamsas.objects.core.AppData +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Version string describing the application specific + * data storage version used + */ + private java.lang.String _version; + + /** + * Canonical name of application + */ + private java.lang.String _name; + + /** + * Field _userList + */ + private java.util.Vector _userList; + + /** + * Field _common + */ + private org.vamsas.objects.core.Common _common; + + /** + * Field _instanceList + */ + private java.util.Vector _instanceList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public ApplicationData() + { + super(); + _userList = new Vector(); + _instanceList = new Vector(); + } //-- org.vamsas.objects.core.ApplicationData() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addInstance + * + * + * + * @param vInstance + */ + public void addInstance(org.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException + { + _instanceList.addElement(vInstance); + } //-- void addInstance(org.vamsas.objects.core.Instance) + + /** + * Method addInstance + * + * + * + * @param index + * @param vInstance + */ + public void addInstance(int index, org.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException + { + _instanceList.insertElementAt(vInstance, index); + } //-- void addInstance(int, org.vamsas.objects.core.Instance) + + /** + * Method addUser + * + * + * + * @param vUser + */ + public void addUser(org.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException + { + _userList.addElement(vUser); + } //-- void addUser(org.vamsas.objects.core.User) + + /** + * Method addUser + * + * + * + * @param index + * @param vUser + */ + public void addUser(int index, org.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException + { + _userList.insertElementAt(vUser, index); + } //-- void addUser(int, org.vamsas.objects.core.User) + + /** + * Method enumerateInstance + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateInstance() + { + return _instanceList.elements(); + } //-- java.util.Enumeration enumerateInstance() + + /** + * Method enumerateUser + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateUser() + { + return _userList.elements(); + } //-- java.util.Enumeration enumerateUser() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof ApplicationData) { + + ApplicationData temp = (ApplicationData)obj; + if (this._version != null) { + if (temp._version == null) return false; + else if (!(this._version.equals(temp._version))) + return false; + } + else if (temp._version != null) + return false; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + if (this._userList != null) { + if (temp._userList == null) return false; + else if (!(this._userList.equals(temp._userList))) + return false; + } + else if (temp._userList != null) + return false; + if (this._common != null) { + if (temp._common == null) return false; + else if (!(this._common.equals(temp._common))) + return false; + } + else if (temp._common != null) + return false; + if (this._instanceList != null) { + if (temp._instanceList == null) return false; + else if (!(this._instanceList.equals(temp._instanceList))) + return false; + } + else if (temp._instanceList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'common'. + * + * @return Common + * @return the value of field 'common'. + */ + public org.vamsas.objects.core.Common getCommon() + { + return this._common; + } //-- org.vamsas.objects.core.Common getCommon() + + /** + * Method getInstance + * + * + * + * @param index + * @return Instance + */ + public org.vamsas.objects.core.Instance getInstance(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _instanceList.size())) { + throw new IndexOutOfBoundsException("getInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]"); + } + + return (org.vamsas.objects.core.Instance) _instanceList.elementAt(index); + } //-- org.vamsas.objects.core.Instance getInstance(int) + + /** + * Method getInstance + * + * + * + * @return Instance + */ + public org.vamsas.objects.core.Instance[] getInstance() + { + int size = _instanceList.size(); + org.vamsas.objects.core.Instance[] mArray = new org.vamsas.objects.core.Instance[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Instance) _instanceList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Instance[] getInstance() + + /** + * Method getInstanceCount + * + * + * + * @return int + */ + public int getInstanceCount() + { + return _instanceList.size(); + } //-- int getInstanceCount() + + /** + * Returns the value of field 'name'. The field 'name' has the + * following description: Canonical name of application + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Method getUser + * + * + * + * @param index + * @return User + */ + public org.vamsas.objects.core.User getUser(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _userList.size())) { + throw new IndexOutOfBoundsException("getUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]"); + } + + return (org.vamsas.objects.core.User) _userList.elementAt(index); + } //-- org.vamsas.objects.core.User getUser(int) + + /** + * Method getUser + * + * + * + * @return User + */ + public org.vamsas.objects.core.User[] getUser() + { + int size = _userList.size(); + org.vamsas.objects.core.User[] mArray = new org.vamsas.objects.core.User[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.User) _userList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.User[] getUser() + + /** + * Method getUserCount + * + * + * + * @return int + */ + public int getUserCount() + { + return _userList.size(); + } //-- int getUserCount() + + /** + * Returns the value of field 'version'. The field 'version' + * has the following description: Version string describing the + * application specific + * data storage version used + * + * @return String + * @return the value of field 'version'. + */ + public java.lang.String getVersion() + { + return this._version; + } //-- java.lang.String getVersion() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllInstance + * + */ + public void removeAllInstance() + { + _instanceList.removeAllElements(); + } //-- void removeAllInstance() + + /** + * Method removeAllUser + * + */ + public void removeAllUser() + { + _userList.removeAllElements(); + } //-- void removeAllUser() + + /** + * Method removeInstance + * + * + * + * @param index + * @return Instance + */ + public org.vamsas.objects.core.Instance removeInstance(int index) + { + java.lang.Object obj = _instanceList.elementAt(index); + _instanceList.removeElementAt(index); + return (org.vamsas.objects.core.Instance) obj; + } //-- org.vamsas.objects.core.Instance removeInstance(int) + + /** + * Method removeUser + * + * + * + * @param index + * @return User + */ + public org.vamsas.objects.core.User removeUser(int index) + { + java.lang.Object obj = _userList.elementAt(index); + _userList.removeElementAt(index); + return (org.vamsas.objects.core.User) obj; + } //-- org.vamsas.objects.core.User removeUser(int) + + /** + * Sets the value of field 'common'. + * + * @param common the value of field 'common'. + */ + public void setCommon(org.vamsas.objects.core.Common common) + { + this._common = common; + } //-- void setCommon(org.vamsas.objects.core.Common) + + /** + * Method setInstance + * + * + * + * @param index + * @param vInstance + */ + public void setInstance(int index, org.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _instanceList.size())) { + throw new IndexOutOfBoundsException("setInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]"); + } + _instanceList.setElementAt(vInstance, index); + } //-- void setInstance(int, org.vamsas.objects.core.Instance) + + /** + * Method setInstance + * + * + * + * @param instanceArray + */ + public void setInstance(org.vamsas.objects.core.Instance[] instanceArray) + { + //-- copy array + _instanceList.removeAllElements(); + for (int i = 0; i < instanceArray.length; i++) { + _instanceList.addElement(instanceArray[i]); + } + } //-- void setInstance(org.vamsas.objects.core.Instance) + + /** + * Sets the value of field 'name'. The field 'name' has the + * following description: Canonical name of application + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Method setUser + * + * + * + * @param index + * @param vUser + */ + public void setUser(int index, org.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _userList.size())) { + throw new IndexOutOfBoundsException("setUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]"); + } + _userList.setElementAt(vUser, index); + } //-- void setUser(int, org.vamsas.objects.core.User) + + /** + * Method setUser + * + * + * + * @param userArray + */ + public void setUser(org.vamsas.objects.core.User[] userArray) + { + //-- copy array + _userList.removeAllElements(); + for (int i = 0; i < userArray.length; i++) { + _userList.addElement(userArray[i]); + } + } //-- void setUser(org.vamsas.objects.core.User) + + /** + * Sets the value of field 'version'. The field 'version' has + * the following description: Version string describing the + * application specific + * data storage version used + * + * @param version the value of field 'version'. + */ + public void setVersion(java.lang.String version) + { + this._version = version; + } //-- void setVersion(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.ApplicationData) Unmarshaller.unmarshal(org.vamsas.objects.core.ApplicationData.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/ApplicationDataDescriptor.java b/src/org/vamsas/objects/core/ApplicationDataDescriptor.java new file mode 100644 index 0000000..894e945 --- /dev/null +++ b/src/org/vamsas/objects/core/ApplicationDataDescriptor.java @@ -0,0 +1,359 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class ApplicationDataDescriptor. + * + * @version $Revision$ $Date$ + */ +public class ApplicationDataDescriptor extends org.vamsas.objects.core.AppDataDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public ApplicationDataDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "ApplicationData"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "version", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + ApplicationData target = (ApplicationData) object; + return target.getVersion(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + ApplicationData target = (ApplicationData) object; + target.setVersion( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + ApplicationData target = (ApplicationData) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + ApplicationData target = (ApplicationData) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _userList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.User.class, "_userList", "User", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + ApplicationData target = (ApplicationData) object; + return target.getUser(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + ApplicationData target = (ApplicationData) object; + target.addUser( (org.vamsas.objects.core.User) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.User(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _userList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _common + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Common.class, "_common", "Common", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + ApplicationData target = (ApplicationData) object; + return target.getCommon(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + ApplicationData target = (ApplicationData) object; + target.setCommon( (org.vamsas.objects.core.Common) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Common(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _common + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _instanceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Instance.class, "_instanceList", "Instance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + ApplicationData target = (ApplicationData) object; + return target.getInstance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + ApplicationData target = (ApplicationData) object; + target.addInstance( (org.vamsas.objects.core.Instance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Instance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _instanceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.ApplicationDataDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.ApplicationData.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Attachment.java b/src/org/vamsas/objects/core/Attachment.java new file mode 100644 index 0000000..9bf14c2 --- /dev/null +++ b/src/org/vamsas/objects/core/Attachment.java @@ -0,0 +1,330 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Attachment. + * + * @version $Revision$ $Date$ + */ +public class Attachment extends org.vamsas.objects.core.AppData +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * true implies data will be decompresses with Zip + * before presenting to application + */ + private boolean _compressed = false; + + /** + * keeps track of state for field: _compressed + */ + private boolean _has_compressed; + + /** + * Type of arbitrary data - TODO: decide format - use + * (extended) MIME types ? + */ + private java.lang.String _type; + + /** + * Object the arbitrary data is associated with + * + */ + private java.lang.Object _objectref; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Attachment() + { + super(); + } //-- org.vamsas.objects.core.Attachment() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteCompressed + * + */ + public void deleteCompressed() + { + this._has_compressed= false; + } //-- void deleteCompressed() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Attachment) { + + Attachment temp = (Attachment)obj; + if (this._compressed != temp._compressed) + return false; + if (this._has_compressed != temp._has_compressed) + return false; + if (this._type != null) { + if (temp._type == null) return false; + else if (!(this._type.equals(temp._type))) + return false; + } + else if (temp._type != null) + return false; + if (this._objectref != null) { + if (temp._objectref == null) return false; + else if (!(this._objectref.equals(temp._objectref))) + return false; + } + else if (temp._objectref != null) + return false; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'compressed'. The field + * 'compressed' has the following description: true implies + * data will be decompresses with Zip + * before presenting to application + * + * @return boolean + * @return the value of field 'compressed'. + */ + public boolean getCompressed() + { + return this._compressed; + } //-- boolean getCompressed() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'objectref'. The field + * 'objectref' has the following description: Object the + * arbitrary data is associated with + * + * + * @return Object + * @return the value of field 'objectref'. + */ + public java.lang.Object getObjectref() + { + return this._objectref; + } //-- java.lang.Object getObjectref() + + /** + * Returns the value of field 'type'. The field 'type' has the + * following description: Type of arbitrary data - TODO: decide + * format - use + * (extended) MIME types ? + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method hasCompressed + * + * + * + * @return boolean + */ + public boolean hasCompressed() + { + return this._has_compressed; + } //-- boolean hasCompressed() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'compressed'. The field 'compressed' + * has the following description: true implies data will be + * decompresses with Zip + * before presenting to application + * + * @param compressed the value of field 'compressed'. + */ + public void setCompressed(boolean compressed) + { + this._compressed = compressed; + this._has_compressed = true; + } //-- void setCompressed(boolean) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'objectref'. The field 'objectref' + * has the following description: Object the arbitrary data is + * associated with + * + * + * @param objectref the value of field 'objectref'. + */ + public void setObjectref(java.lang.Object objectref) + { + this._objectref = objectref; + } //-- void setObjectref(java.lang.Object) + + /** + * Sets the value of field 'type'. The field 'type' has the + * following description: Type of arbitrary data - TODO: decide + * format - use + * (extended) MIME types ? + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Attachment) Unmarshaller.unmarshal(org.vamsas.objects.core.Attachment.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/AttachmentDescriptor.java b/src/org/vamsas/objects/core/AttachmentDescriptor.java new file mode 100644 index 0000000..e2669da --- /dev/null +++ b/src/org/vamsas/objects/core/AttachmentDescriptor.java @@ -0,0 +1,325 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class AttachmentDescriptor. + * + * @version $Revision$ $Date$ + */ +public class AttachmentDescriptor extends org.vamsas.objects.core.AppDataDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public AttachmentDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "Attachment"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _compressed + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_compressed", "compressed", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Attachment target = (Attachment) object; + if(!target.hasCompressed()) + return null; + return (target.getCompressed() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Attachment target = (Attachment) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteCompressed(); + return; + } + target.setCompressed( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _compressed + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Attachment target = (Attachment) object; + return target.getType(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Attachment target = (Attachment) object; + target.setType( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _objectref + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_objectref", "objectref", org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Attachment target = (Attachment) object; + return target.getObjectref(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Attachment target = (Attachment) object; + target.setObjectref( (java.lang.Object) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _objectref + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Attachment target = (Attachment) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Attachment target = (Attachment) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.AttachmentDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Attachment.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Common.java b/src/org/vamsas/objects/core/Common.java new file mode 100644 index 0000000..3fdab82 --- /dev/null +++ b/src/org/vamsas/objects/core/Common.java @@ -0,0 +1,141 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Common. + * + * @version $Revision$ $Date$ + */ +public class Common extends org.vamsas.objects.core.AppData +implements java.io.Serializable +{ + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Common() + { + super(); + } //-- org.vamsas.objects.core.Common() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Common) { + + Common temp = (Common)obj; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Common) Unmarshaller.unmarshal(org.vamsas.objects.core.Common.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/CommonDescriptor.java b/src/org/vamsas/objects/core/CommonDescriptor.java new file mode 100644 index 0000000..c7bc7e0 --- /dev/null +++ b/src/org/vamsas/objects/core/CommonDescriptor.java @@ -0,0 +1,167 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class CommonDescriptor. + * + * @version $Revision$ $Date$ + */ +public class CommonDescriptor extends org.vamsas.objects.core.AppDataDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public CommonDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "Common"; + } //-- org.vamsas.objects.core.CommonDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Common.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/DataSet.java b/src/org/vamsas/objects/core/DataSet.java new file mode 100644 index 0000000..e6d064e --- /dev/null +++ b/src/org/vamsas/objects/core/DataSet.java @@ -0,0 +1,850 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class DataSet. + * + * @version $Revision$ $Date$ + */ +public class DataSet extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _sequenceList + */ + private java.util.Vector _sequenceList; + + /** + * Field _dataSetAnnotationsList + */ + private java.util.Vector _dataSetAnnotationsList; + + /** + * Field _alignmentList + */ + private java.util.Vector _alignmentList; + + /** + * Field _treeList + */ + private java.util.Vector _treeList; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DataSet() + { + super(); + _sequenceList = new Vector(); + _dataSetAnnotationsList = new Vector(); + _alignmentList = new Vector(); + _treeList = new Vector(); + } //-- org.vamsas.objects.core.DataSet() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAlignment + * + * + * + * @param vAlignment + */ + public void addAlignment(org.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + _alignmentList.addElement(vAlignment); + } //-- void addAlignment(org.vamsas.objects.core.Alignment) + + /** + * Method addAlignment + * + * + * + * @param index + * @param vAlignment + */ + public void addAlignment(int index, org.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + _alignmentList.insertElementAt(vAlignment, index); + } //-- void addAlignment(int, org.vamsas.objects.core.Alignment) + + /** + * Method addDataSetAnnotations + * + * + * + * @param vDataSetAnnotations + */ + public void addDataSetAnnotations(org.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException + { + _dataSetAnnotationsList.addElement(vDataSetAnnotations); + } //-- void addDataSetAnnotations(org.vamsas.objects.core.DataSetAnnotations) + + /** + * Method addDataSetAnnotations + * + * + * + * @param index + * @param vDataSetAnnotations + */ + public void addDataSetAnnotations(int index, org.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException + { + _dataSetAnnotationsList.insertElementAt(vDataSetAnnotations, index); + } //-- void addDataSetAnnotations(int, org.vamsas.objects.core.DataSetAnnotations) + + /** + * Method addSequence + * + * + * + * @param vSequence + */ + public void addSequence(org.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + _sequenceList.addElement(vSequence); + } //-- void addSequence(org.vamsas.objects.core.Sequence) + + /** + * Method addSequence + * + * + * + * @param index + * @param vSequence + */ + public void addSequence(int index, org.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + _sequenceList.insertElementAt(vSequence, index); + } //-- void addSequence(int, org.vamsas.objects.core.Sequence) + + /** + * Method addTree + * + * + * + * @param vTree + */ + public void addTree(org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.addElement(vTree); + } //-- void addTree(org.vamsas.objects.core.Tree) + + /** + * Method addTree + * + * + * + * @param index + * @param vTree + */ + public void addTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.insertElementAt(vTree, index); + } //-- void addTree(int, org.vamsas.objects.core.Tree) + + /** + * Method enumerateAlignment + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAlignment() + { + return _alignmentList.elements(); + } //-- java.util.Enumeration enumerateAlignment() + + /** + * Method enumerateDataSetAnnotations + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateDataSetAnnotations() + { + return _dataSetAnnotationsList.elements(); + } //-- java.util.Enumeration enumerateDataSetAnnotations() + + /** + * Method enumerateSequence + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateSequence() + { + return _sequenceList.elements(); + } //-- java.util.Enumeration enumerateSequence() + + /** + * Method enumerateTree + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateTree() + { + return _treeList.elements(); + } //-- java.util.Enumeration enumerateTree() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof DataSet) { + + DataSet temp = (DataSet)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._sequenceList != null) { + if (temp._sequenceList == null) return false; + else if (!(this._sequenceList.equals(temp._sequenceList))) + return false; + } + else if (temp._sequenceList != null) + return false; + if (this._dataSetAnnotationsList != null) { + if (temp._dataSetAnnotationsList == null) return false; + else if (!(this._dataSetAnnotationsList.equals(temp._dataSetAnnotationsList))) + return false; + } + else if (temp._dataSetAnnotationsList != null) + return false; + if (this._alignmentList != null) { + if (temp._alignmentList == null) return false; + else if (!(this._alignmentList.equals(temp._alignmentList))) + return false; + } + else if (temp._alignmentList != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) return false; + else if (!(this._treeList.equals(temp._treeList))) + return false; + } + else if (temp._treeList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getAlignment + * + * + * + * @param index + * @return Alignment + */ + public org.vamsas.objects.core.Alignment getAlignment(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentList.size())) { + throw new IndexOutOfBoundsException("getAlignment: Index value '"+index+"' not in range [0.."+_alignmentList.size()+ "]"); + } + + return (org.vamsas.objects.core.Alignment) _alignmentList.elementAt(index); + } //-- org.vamsas.objects.core.Alignment getAlignment(int) + + /** + * Method getAlignment + * + * + * + * @return Alignment + */ + public org.vamsas.objects.core.Alignment[] getAlignment() + { + int size = _alignmentList.size(); + org.vamsas.objects.core.Alignment[] mArray = new org.vamsas.objects.core.Alignment[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Alignment) _alignmentList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Alignment[] getAlignment() + + /** + * Method getAlignmentCount + * + * + * + * @return int + */ + public int getAlignmentCount() + { + return _alignmentList.size(); + } //-- int getAlignmentCount() + + /** + * Method getDataSetAnnotations + * + * + * + * @param index + * @return DataSetAnnotations + */ + public org.vamsas.objects.core.DataSetAnnotations getDataSetAnnotations(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dataSetAnnotationsList.size())) { + throw new IndexOutOfBoundsException("getDataSetAnnotations: Index value '"+index+"' not in range [0.."+_dataSetAnnotationsList.size()+ "]"); + } + + return (org.vamsas.objects.core.DataSetAnnotations) _dataSetAnnotationsList.elementAt(index); + } //-- org.vamsas.objects.core.DataSetAnnotations getDataSetAnnotations(int) + + /** + * Method getDataSetAnnotations + * + * + * + * @return DataSetAnnotations + */ + public org.vamsas.objects.core.DataSetAnnotations[] getDataSetAnnotations() + { + int size = _dataSetAnnotationsList.size(); + org.vamsas.objects.core.DataSetAnnotations[] mArray = new org.vamsas.objects.core.DataSetAnnotations[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.DataSetAnnotations) _dataSetAnnotationsList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.DataSetAnnotations[] getDataSetAnnotations() + + /** + * Method getDataSetAnnotationsCount + * + * + * + * @return int + */ + public int getDataSetAnnotationsCount() + { + return _dataSetAnnotationsList.size(); + } //-- int getDataSetAnnotationsCount() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Method getSequence + * + * + * + * @param index + * @return Sequence + */ + public org.vamsas.objects.core.Sequence getSequence(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _sequenceList.size())) { + throw new IndexOutOfBoundsException("getSequence: Index value '"+index+"' not in range [0.."+_sequenceList.size()+ "]"); + } + + return (org.vamsas.objects.core.Sequence) _sequenceList.elementAt(index); + } //-- org.vamsas.objects.core.Sequence getSequence(int) + + /** + * Method getSequence + * + * + * + * @return Sequence + */ + public org.vamsas.objects.core.Sequence[] getSequence() + { + int size = _sequenceList.size(); + org.vamsas.objects.core.Sequence[] mArray = new org.vamsas.objects.core.Sequence[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Sequence) _sequenceList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Sequence[] getSequence() + + /** + * Method getSequenceCount + * + * + * + * @return int + */ + public int getSequenceCount() + { + return _sequenceList.size(); + } //-- int getSequenceCount() + + /** + * Method getTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree getTree(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("getTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + + return (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } //-- org.vamsas.objects.core.Tree getTree(int) + + /** + * Method getTree + * + * + * + * @return Tree + */ + public org.vamsas.objects.core.Tree[] getTree() + { + int size = _treeList.size(); + org.vamsas.objects.core.Tree[] mArray = new org.vamsas.objects.core.Tree[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Tree[] getTree() + + /** + * Method getTreeCount + * + * + * + * @return int + */ + public int getTreeCount() + { + return _treeList.size(); + } //-- int getTreeCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAlignment + * + * + * + * @param index + * @return Alignment + */ + public org.vamsas.objects.core.Alignment removeAlignment(int index) + { + java.lang.Object obj = _alignmentList.elementAt(index); + _alignmentList.removeElementAt(index); + return (org.vamsas.objects.core.Alignment) obj; + } //-- org.vamsas.objects.core.Alignment removeAlignment(int) + + /** + * Method removeAllAlignment + * + */ + public void removeAllAlignment() + { + _alignmentList.removeAllElements(); + } //-- void removeAllAlignment() + + /** + * Method removeAllDataSetAnnotations + * + */ + public void removeAllDataSetAnnotations() + { + _dataSetAnnotationsList.removeAllElements(); + } //-- void removeAllDataSetAnnotations() + + /** + * Method removeAllSequence + * + */ + public void removeAllSequence() + { + _sequenceList.removeAllElements(); + } //-- void removeAllSequence() + + /** + * Method removeAllTree + * + */ + public void removeAllTree() + { + _treeList.removeAllElements(); + } //-- void removeAllTree() + + /** + * Method removeDataSetAnnotations + * + * + * + * @param index + * @return DataSetAnnotations + */ + public org.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotations(int index) + { + java.lang.Object obj = _dataSetAnnotationsList.elementAt(index); + _dataSetAnnotationsList.removeElementAt(index); + return (org.vamsas.objects.core.DataSetAnnotations) obj; + } //-- org.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotations(int) + + /** + * Method removeSequence + * + * + * + * @param index + * @return Sequence + */ + public org.vamsas.objects.core.Sequence removeSequence(int index) + { + java.lang.Object obj = _sequenceList.elementAt(index); + _sequenceList.removeElementAt(index); + return (org.vamsas.objects.core.Sequence) obj; + } //-- org.vamsas.objects.core.Sequence removeSequence(int) + + /** + * Method removeTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree removeTree(int index) + { + java.lang.Object obj = _treeList.elementAt(index); + _treeList.removeElementAt(index); + return (org.vamsas.objects.core.Tree) obj; + } //-- org.vamsas.objects.core.Tree removeTree(int) + + /** + * Method setAlignment + * + * + * + * @param index + * @param vAlignment + */ + public void setAlignment(int index, org.vamsas.objects.core.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _alignmentList.size())) { + throw new IndexOutOfBoundsException("setAlignment: Index value '"+index+"' not in range [0.."+_alignmentList.size()+ "]"); + } + _alignmentList.setElementAt(vAlignment, index); + } //-- void setAlignment(int, org.vamsas.objects.core.Alignment) + + /** + * Method setAlignment + * + * + * + * @param alignmentArray + */ + public void setAlignment(org.vamsas.objects.core.Alignment[] alignmentArray) + { + //-- copy array + _alignmentList.removeAllElements(); + for (int i = 0; i < alignmentArray.length; i++) { + _alignmentList.addElement(alignmentArray[i]); + } + } //-- void setAlignment(org.vamsas.objects.core.Alignment) + + /** + * Method setDataSetAnnotations + * + * + * + * @param index + * @param vDataSetAnnotations + */ + public void setDataSetAnnotations(int index, org.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dataSetAnnotationsList.size())) { + throw new IndexOutOfBoundsException("setDataSetAnnotations: Index value '"+index+"' not in range [0.."+_dataSetAnnotationsList.size()+ "]"); + } + _dataSetAnnotationsList.setElementAt(vDataSetAnnotations, index); + } //-- void setDataSetAnnotations(int, org.vamsas.objects.core.DataSetAnnotations) + + /** + * Method setDataSetAnnotations + * + * + * + * @param dataSetAnnotationsArray + */ + public void setDataSetAnnotations(org.vamsas.objects.core.DataSetAnnotations[] dataSetAnnotationsArray) + { + //-- copy array + _dataSetAnnotationsList.removeAllElements(); + for (int i = 0; i < dataSetAnnotationsArray.length; i++) { + _dataSetAnnotationsList.addElement(dataSetAnnotationsArray[i]); + } + } //-- void setDataSetAnnotations(org.vamsas.objects.core.DataSetAnnotations) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Method setSequence + * + * + * + * @param index + * @param vSequence + */ + public void setSequence(int index, org.vamsas.objects.core.Sequence vSequence) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _sequenceList.size())) { + throw new IndexOutOfBoundsException("setSequence: Index value '"+index+"' not in range [0.."+_sequenceList.size()+ "]"); + } + _sequenceList.setElementAt(vSequence, index); + } //-- void setSequence(int, org.vamsas.objects.core.Sequence) + + /** + * Method setSequence + * + * + * + * @param sequenceArray + */ + public void setSequence(org.vamsas.objects.core.Sequence[] sequenceArray) + { + //-- copy array + _sequenceList.removeAllElements(); + for (int i = 0; i < sequenceArray.length; i++) { + _sequenceList.addElement(sequenceArray[i]); + } + } //-- void setSequence(org.vamsas.objects.core.Sequence) + + /** + * Method setTree + * + * + * + * @param index + * @param vTree + */ + public void setTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("setTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + _treeList.setElementAt(vTree, index); + } //-- void setTree(int, org.vamsas.objects.core.Tree) + + /** + * Method setTree + * + * + * + * @param treeArray + */ + public void setTree(org.vamsas.objects.core.Tree[] treeArray) + { + //-- copy array + _treeList.removeAllElements(); + for (int i = 0; i < treeArray.length; i++) { + _treeList.addElement(treeArray[i]); + } + } //-- void setTree(org.vamsas.objects.core.Tree) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return DataSet + */ + public static org.vamsas.objects.core.DataSet unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.DataSet) Unmarshaller.unmarshal(org.vamsas.objects.core.DataSet.class, reader); + } //-- org.vamsas.objects.core.DataSet unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/DataSetAnnotations.java b/src/org/vamsas/objects/core/DataSetAnnotations.java new file mode 100644 index 0000000..1d5552a --- /dev/null +++ b/src/org/vamsas/objects/core/DataSetAnnotations.java @@ -0,0 +1,217 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class DataSetAnnotations. + * + * @version $Revision$ $Date$ + */ +public class DataSetAnnotations extends org.vamsas.objects.core.RangeAnnotation +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * annotation is associated with a + * particular dataset sequence + */ + private java.lang.Object _seqRef; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DataSetAnnotations() + { + super(); + } //-- org.vamsas.objects.core.DataSetAnnotations() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof DataSetAnnotations) { + + DataSetAnnotations temp = (DataSetAnnotations)obj; + if (this._seqRef != null) { + if (temp._seqRef == null) return false; + else if (!(this._seqRef.equals(temp._seqRef))) + return false; + } + else if (temp._seqRef != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Returns the value of field 'seqRef'. The field 'seqRef' has + * the following description: annotation is associated with a + * particular dataset sequence + * + * @return Object + * @return the value of field 'seqRef'. + */ + public java.lang.Object getSeqRef() + { + return this._seqRef; + } //-- java.lang.Object getSeqRef() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Sets the value of field 'seqRef'. The field 'seqRef' has the + * following description: annotation is associated with a + * particular dataset sequence + * + * @param seqRef the value of field 'seqRef'. + */ + public void setSeqRef(java.lang.Object seqRef) + { + this._seqRef = seqRef; + } //-- void setSeqRef(java.lang.Object) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return RangeType + */ + public static org.vamsas.objects.core.RangeType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.DataSetAnnotations) Unmarshaller.unmarshal(org.vamsas.objects.core.DataSetAnnotations.class, reader); + } //-- org.vamsas.objects.core.RangeType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/DataSetAnnotationsDescriptor.java b/src/org/vamsas/objects/core/DataSetAnnotationsDescriptor.java new file mode 100644 index 0000000..a8b2741 --- /dev/null +++ b/src/org/vamsas/objects/core/DataSetAnnotationsDescriptor.java @@ -0,0 +1,249 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class DataSetAnnotationsDescriptor. + * + * @version $Revision$ $Date$ + */ +public class DataSetAnnotationsDescriptor extends org.vamsas.objects.core.RangeAnnotationDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DataSetAnnotationsDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.RangeAnnotationDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "DataSetAnnotations"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _seqRef + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_seqRef", "seqRef", org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSetAnnotations target = (DataSetAnnotations) object; + return target.getSeqRef(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSetAnnotations target = (DataSetAnnotations) object; + target.setSeqRef( (java.lang.Object) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _seqRef + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSetAnnotations target = (DataSetAnnotations) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSetAnnotations target = (DataSetAnnotations) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.DataSetAnnotationsDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.DataSetAnnotations.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/DataSetDescriptor.java b/src/org/vamsas/objects/core/DataSetDescriptor.java new file mode 100644 index 0000000..7e342bc --- /dev/null +++ b/src/org/vamsas/objects/core/DataSetDescriptor.java @@ -0,0 +1,385 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class DataSetDescriptor. + * + * @version $Revision$ $Date$ + */ +public class DataSetDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DataSetDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "DataSet"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _sequenceList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Sequence.class, "_sequenceList", "Sequence", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getSequence(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.addSequence( (org.vamsas.objects.core.Sequence) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Sequence(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _sequenceList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _dataSetAnnotationsList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.DataSetAnnotations.class, "_dataSetAnnotationsList", "DataSetAnnotations", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getDataSetAnnotations(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.addDataSetAnnotations( (org.vamsas.objects.core.DataSetAnnotations) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.DataSetAnnotations(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _dataSetAnnotationsList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _alignmentList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Alignment.class, "_alignmentList", "Alignment", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getAlignment(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.addAlignment( (org.vamsas.objects.core.Alignment) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Alignment(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _alignmentList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getTree(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.addTree( (org.vamsas.objects.core.Tree) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DataSet target = (DataSet) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DataSet target = (DataSet) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.DataSetDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.DataSet.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/DbRef.java b/src/org/vamsas/objects/core/DbRef.java new file mode 100644 index 0000000..3be5671 --- /dev/null +++ b/src/org/vamsas/objects/core/DbRef.java @@ -0,0 +1,806 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Store a list of database references + * for this sequence record - with optional mapping + * from database sequence to the given sequence record + * + * @version $Revision$ $Date$ + */ +public class DbRef extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * TODO Database Naming + * Convention: either start using LSID (so + * change type to URI) or leave this as an + * uncontrolled/unspecified string ID + * + */ + private java.lang.String _source; + + /** + * Version must be specified - + * + */ + private java.lang.String _version; + + /** + * TODO: make some specification + * of the database field from which this + * accessionId is taken from - should that be a + * special property of the dbRef object ? + * + */ + private java.lang.String _accessionId; + + /** + * Primary Key for vamsas object + * referencing + */ + private java.lang.String _id; + + /** + * From: Offset to first + * position in dataset sequence record that + * this database entry maps to To: Offset + * to last position in dataset sequence + * record that this database entry maps to + * Start: Offset to first last position in + * database entry that first (or offset) + * position in sequence maps to End: Offset + * to last position in database entry that + * last (offset) position in sequence maps + * to + */ + private java.util.Vector _mapList; + + /** + * Field _linkList + */ + private java.util.Vector _linkList; + + /** + * Field _propertyList + */ + private java.util.Vector _propertyList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DbRef() + { + super(); + _mapList = new Vector(); + _linkList = new Vector(); + _propertyList = new Vector(); + } //-- org.vamsas.objects.core.DbRef() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addLink + * + * + * + * @param vLink + */ + public void addLink(org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.addElement(vLink); + } //-- void addLink(org.vamsas.objects.core.Link) + + /** + * Method addLink + * + * + * + * @param index + * @param vLink + */ + public void addLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.insertElementAt(vLink, index); + } //-- void addLink(int, org.vamsas.objects.core.Link) + + /** + * Method addMap + * + * + * + * @param vMap + */ + public void addMap(org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + _mapList.addElement(vMap); + } //-- void addMap(org.vamsas.objects.core.Map) + + /** + * Method addMap + * + * + * + * @param index + * @param vMap + */ + public void addMap(int index, org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + _mapList.insertElementAt(vMap, index); + } //-- void addMap(int, org.vamsas.objects.core.Map) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method enumerateLink + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateLink() + { + return _linkList.elements(); + } //-- java.util.Enumeration enumerateLink() + + /** + * Method enumerateMap + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateMap() + { + return _mapList.elements(); + } //-- java.util.Enumeration enumerateMap() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof DbRef) { + + DbRef temp = (DbRef)obj; + if (this._source != null) { + if (temp._source == null) return false; + else if (!(this._source.equals(temp._source))) + return false; + } + else if (temp._source != null) + return false; + if (this._version != null) { + if (temp._version == null) return false; + else if (!(this._version.equals(temp._version))) + return false; + } + else if (temp._version != null) + return false; + if (this._accessionId != null) { + if (temp._accessionId == null) return false; + else if (!(this._accessionId.equals(temp._accessionId))) + return false; + } + else if (temp._accessionId != null) + return false; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._mapList != null) { + if (temp._mapList == null) return false; + else if (!(this._mapList.equals(temp._mapList))) + return false; + } + else if (temp._mapList != null) + return false; + if (this._linkList != null) { + if (temp._linkList == null) return false; + else if (!(this._linkList.equals(temp._linkList))) + return false; + } + else if (temp._linkList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'accessionId'. The field + * 'accessionId' has the following description: TODO: make some + * specification + * of the database field from which this + * accessionId is taken from - should that be a + * special property of the dbRef object ? + * + * + * @return String + * @return the value of field 'accessionId'. + */ + public java.lang.String getAccessionId() + { + return this._accessionId; + } //-- java.lang.String getAccessionId() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Method getLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link getLink(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("getLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + + return (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } //-- org.vamsas.objects.core.Link getLink(int) + + /** + * Method getLink + * + * + * + * @return Link + */ + public org.vamsas.objects.core.Link[] getLink() + { + int size = _linkList.size(); + org.vamsas.objects.core.Link[] mArray = new org.vamsas.objects.core.Link[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Link[] getLink() + + /** + * Method getLinkCount + * + * + * + * @return int + */ + public int getLinkCount() + { + return _linkList.size(); + } //-- int getLinkCount() + + /** + * Method getMap + * + * + * + * @param index + * @return Map + */ + public org.vamsas.objects.core.Map getMap(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mapList.size())) { + throw new IndexOutOfBoundsException("getMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]"); + } + + return (org.vamsas.objects.core.Map) _mapList.elementAt(index); + } //-- org.vamsas.objects.core.Map getMap(int) + + /** + * Method getMap + * + * + * + * @return Map + */ + public org.vamsas.objects.core.Map[] getMap() + { + int size = _mapList.size(); + org.vamsas.objects.core.Map[] mArray = new org.vamsas.objects.core.Map[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Map) _mapList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Map[] getMap() + + /** + * Method getMapCount + * + * + * + * @return int + */ + public int getMapCount() + { + return _mapList.size(); + } //-- int getMapCount() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'source'. The field 'source' has + * the following description: TODO Database Naming + * Convention: either start using LSID (so + * change type to URI) or leave this as an + * uncontrolled/unspecified string ID + * + * + * @return String + * @return the value of field 'source'. + */ + public java.lang.String getSource() + { + return this._source; + } //-- java.lang.String getSource() + + /** + * Returns the value of field 'version'. The field 'version' + * has the following description: Version must be specified - + * + * + * @return String + * @return the value of field 'version'. + */ + public java.lang.String getVersion() + { + return this._version; + } //-- java.lang.String getVersion() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllLink + * + */ + public void removeAllLink() + { + _linkList.removeAllElements(); + } //-- void removeAllLink() + + /** + * Method removeAllMap + * + */ + public void removeAllMap() + { + _mapList.removeAllElements(); + } //-- void removeAllMap() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link removeLink(int index) + { + java.lang.Object obj = _linkList.elementAt(index); + _linkList.removeElementAt(index); + return (org.vamsas.objects.core.Link) obj; + } //-- org.vamsas.objects.core.Link removeLink(int) + + /** + * Method removeMap + * + * + * + * @param index + * @return Map + */ + public org.vamsas.objects.core.Map removeMap(int index) + { + java.lang.Object obj = _mapList.elementAt(index); + _mapList.removeElementAt(index); + return (org.vamsas.objects.core.Map) obj; + } //-- org.vamsas.objects.core.Map removeMap(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Sets the value of field 'accessionId'. The field + * 'accessionId' has the following description: TODO: make some + * specification + * of the database field from which this + * accessionId is taken from - should that be a + * special property of the dbRef object ? + * + * + * @param accessionId the value of field 'accessionId'. + */ + public void setAccessionId(java.lang.String accessionId) + { + this._accessionId = accessionId; + } //-- void setAccessionId(java.lang.String) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Method setLink + * + * + * + * @param index + * @param vLink + */ + public void setLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("setLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + _linkList.setElementAt(vLink, index); + } //-- void setLink(int, org.vamsas.objects.core.Link) + + /** + * Method setLink + * + * + * + * @param linkArray + */ + public void setLink(org.vamsas.objects.core.Link[] linkArray) + { + //-- copy array + _linkList.removeAllElements(); + for (int i = 0; i < linkArray.length; i++) { + _linkList.addElement(linkArray[i]); + } + } //-- void setLink(org.vamsas.objects.core.Link) + + /** + * Method setMap + * + * + * + * @param index + * @param vMap + */ + public void setMap(int index, org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mapList.size())) { + throw new IndexOutOfBoundsException("setMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]"); + } + _mapList.setElementAt(vMap, index); + } //-- void setMap(int, org.vamsas.objects.core.Map) + + /** + * Method setMap + * + * + * + * @param mapArray + */ + public void setMap(org.vamsas.objects.core.Map[] mapArray) + { + //-- copy array + _mapList.removeAllElements(); + for (int i = 0; i < mapArray.length; i++) { + _mapList.addElement(mapArray[i]); + } + } //-- void setMap(org.vamsas.objects.core.Map) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'source'. The field 'source' has the + * following description: TODO Database Naming + * Convention: either start using LSID (so + * change type to URI) or leave this as an + * uncontrolled/unspecified string ID + * + * + * @param source the value of field 'source'. + */ + public void setSource(java.lang.String source) + { + this._source = source; + } //-- void setSource(java.lang.String) + + /** + * Sets the value of field 'version'. The field 'version' has + * the following description: Version must be specified - + * + * + * @param version the value of field 'version'. + */ + public void setVersion(java.lang.String version) + { + this._version = version; + } //-- void setVersion(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return DbRef + */ + public static org.vamsas.objects.core.DbRef unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(org.vamsas.objects.core.DbRef.class, reader); + } //-- org.vamsas.objects.core.DbRef unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/DbRefDescriptor.java b/src/org/vamsas/objects/core/DbRefDescriptor.java new file mode 100644 index 0000000..fdb9238 --- /dev/null +++ b/src/org/vamsas/objects/core/DbRefDescriptor.java @@ -0,0 +1,430 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class DbRefDescriptor. + * + * @version $Revision$ $Date$ + */ +public class DbRefDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public DbRefDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "dbRef"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _source + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_source", "source", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getSource(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.setSource( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _source + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "version", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getVersion(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.setVersion( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _accessionId + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_accessionId", "accessionId", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getAccessionId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.setAccessionId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _accessionId + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _mapList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Map.class, "_mapList", "map", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getMap(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.addMap( (org.vamsas.objects.core.Map) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Map(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _mapList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _linkList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Link.class, "_linkList", "link", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getLink(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.addLink( (org.vamsas.objects.core.Link) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Link(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _linkList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + DbRef target = (DbRef) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + DbRef target = (DbRef) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.DbRefDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.DbRef.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Entry.java b/src/org/vamsas/objects/core/Entry.java new file mode 100644 index 0000000..dcf3c5e --- /dev/null +++ b/src/org/vamsas/objects/core/Entry.java @@ -0,0 +1,803 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Entry. + * + * @version $Revision$ $Date$ + */ +public class Entry extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Who + */ + private java.lang.String _user; + + /** + * With which application + */ + private java.lang.String _app; + + /** + * Did what + */ + private java.lang.String _action; + + /** + * When + */ + private org.exolab.castor.types.Date _date; + + /** + * additional information + */ + private java.util.Vector _propertyList; + + /** + * parameter for the action + */ + private java.util.Vector _paramList; + + /** + * bioinformatic objects input to action + * + */ + private java.util.Vector _inputList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Entry() + { + super(); + _propertyList = new Vector(); + _paramList = new Vector(); + _inputList = new Vector(); + } //-- org.vamsas.objects.core.Entry() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addInput + * + * + * + * @param vInput + */ + public void addInput(org.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException + { + _inputList.addElement(vInput); + } //-- void addInput(org.vamsas.objects.core.Input) + + /** + * Method addInput + * + * + * + * @param index + * @param vInput + */ + public void addInput(int index, org.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException + { + _inputList.insertElementAt(vInput, index); + } //-- void addInput(int, org.vamsas.objects.core.Input) + + /** + * Method addParam + * + * + * + * @param vParam + */ + public void addParam(org.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException + { + _paramList.addElement(vParam); + } //-- void addParam(org.vamsas.objects.core.Param) + + /** + * Method addParam + * + * + * + * @param index + * @param vParam + */ + public void addParam(int index, org.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException + { + _paramList.insertElementAt(vParam, index); + } //-- void addParam(int, org.vamsas.objects.core.Param) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method enumerateInput + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateInput() + { + return _inputList.elements(); + } //-- java.util.Enumeration enumerateInput() + + /** + * Method enumerateParam + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateParam() + { + return _paramList.elements(); + } //-- java.util.Enumeration enumerateParam() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Entry) { + + Entry temp = (Entry)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._user != null) { + if (temp._user == null) return false; + else if (!(this._user.equals(temp._user))) + return false; + } + else if (temp._user != null) + return false; + if (this._app != null) { + if (temp._app == null) return false; + else if (!(this._app.equals(temp._app))) + return false; + } + else if (temp._app != null) + return false; + if (this._action != null) { + if (temp._action == null) return false; + else if (!(this._action.equals(temp._action))) + return false; + } + else if (temp._action != null) + return false; + if (this._date != null) { + if (temp._date == null) return false; + else if (!(this._date.equals(temp._date))) + return false; + } + else if (temp._date != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + if (this._paramList != null) { + if (temp._paramList == null) return false; + else if (!(this._paramList.equals(temp._paramList))) + return false; + } + else if (temp._paramList != null) + return false; + if (this._inputList != null) { + if (temp._inputList == null) return false; + else if (!(this._inputList.equals(temp._inputList))) + return false; + } + else if (temp._inputList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'action'. The field 'action' has + * the following description: Did what + * + * @return String + * @return the value of field 'action'. + */ + public java.lang.String getAction() + { + return this._action; + } //-- java.lang.String getAction() + + /** + * Returns the value of field 'app'. The field 'app' has the + * following description: With which application + * + * @return String + * @return the value of field 'app'. + */ + public java.lang.String getApp() + { + return this._app; + } //-- java.lang.String getApp() + + /** + * Returns the value of field 'date'. The field 'date' has the + * following description: When + * + * @return Date + * @return the value of field 'date'. + */ + public org.exolab.castor.types.Date getDate() + { + return this._date; + } //-- org.exolab.castor.types.Date getDate() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Method getInput + * + * + * + * @param index + * @return Input + */ + public org.vamsas.objects.core.Input getInput(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _inputList.size())) { + throw new IndexOutOfBoundsException("getInput: Index value '"+index+"' not in range [0.."+_inputList.size()+ "]"); + } + + return (org.vamsas.objects.core.Input) _inputList.elementAt(index); + } //-- org.vamsas.objects.core.Input getInput(int) + + /** + * Method getInput + * + * + * + * @return Input + */ + public org.vamsas.objects.core.Input[] getInput() + { + int size = _inputList.size(); + org.vamsas.objects.core.Input[] mArray = new org.vamsas.objects.core.Input[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Input) _inputList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Input[] getInput() + + /** + * Method getInputCount + * + * + * + * @return int + */ + public int getInputCount() + { + return _inputList.size(); + } //-- int getInputCount() + + /** + * Method getParam + * + * + * + * @param index + * @return Param + */ + public org.vamsas.objects.core.Param getParam(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _paramList.size())) { + throw new IndexOutOfBoundsException("getParam: Index value '"+index+"' not in range [0.."+_paramList.size()+ "]"); + } + + return (org.vamsas.objects.core.Param) _paramList.elementAt(index); + } //-- org.vamsas.objects.core.Param getParam(int) + + /** + * Method getParam + * + * + * + * @return Param + */ + public org.vamsas.objects.core.Param[] getParam() + { + int size = _paramList.size(); + org.vamsas.objects.core.Param[] mArray = new org.vamsas.objects.core.Param[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Param) _paramList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Param[] getParam() + + /** + * Method getParamCount + * + * + * + * @return int + */ + public int getParamCount() + { + return _paramList.size(); + } //-- int getParamCount() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'user'. The field 'user' has the + * following description: Who + * + * @return String + * @return the value of field 'user'. + */ + public java.lang.String getUser() + { + return this._user; + } //-- java.lang.String getUser() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllInput + * + */ + public void removeAllInput() + { + _inputList.removeAllElements(); + } //-- void removeAllInput() + + /** + * Method removeAllParam + * + */ + public void removeAllParam() + { + _paramList.removeAllElements(); + } //-- void removeAllParam() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeInput + * + * + * + * @param index + * @return Input + */ + public org.vamsas.objects.core.Input removeInput(int index) + { + java.lang.Object obj = _inputList.elementAt(index); + _inputList.removeElementAt(index); + return (org.vamsas.objects.core.Input) obj; + } //-- org.vamsas.objects.core.Input removeInput(int) + + /** + * Method removeParam + * + * + * + * @param index + * @return Param + */ + public org.vamsas.objects.core.Param removeParam(int index) + { + java.lang.Object obj = _paramList.elementAt(index); + _paramList.removeElementAt(index); + return (org.vamsas.objects.core.Param) obj; + } //-- org.vamsas.objects.core.Param removeParam(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Sets the value of field 'action'. The field 'action' has the + * following description: Did what + * + * @param action the value of field 'action'. + */ + public void setAction(java.lang.String action) + { + this._action = action; + } //-- void setAction(java.lang.String) + + /** + * Sets the value of field 'app'. The field 'app' has the + * following description: With which application + * + * @param app the value of field 'app'. + */ + public void setApp(java.lang.String app) + { + this._app = app; + } //-- void setApp(java.lang.String) + + /** + * Sets the value of field 'date'. The field 'date' has the + * following description: When + * + * @param date the value of field 'date'. + */ + public void setDate(org.exolab.castor.types.Date date) + { + this._date = date; + } //-- void setDate(org.exolab.castor.types.Date) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Method setInput + * + * + * + * @param index + * @param vInput + */ + public void setInput(int index, org.vamsas.objects.core.Input vInput) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _inputList.size())) { + throw new IndexOutOfBoundsException("setInput: Index value '"+index+"' not in range [0.."+_inputList.size()+ "]"); + } + _inputList.setElementAt(vInput, index); + } //-- void setInput(int, org.vamsas.objects.core.Input) + + /** + * Method setInput + * + * + * + * @param inputArray + */ + public void setInput(org.vamsas.objects.core.Input[] inputArray) + { + //-- copy array + _inputList.removeAllElements(); + for (int i = 0; i < inputArray.length; i++) { + _inputList.addElement(inputArray[i]); + } + } //-- void setInput(org.vamsas.objects.core.Input) + + /** + * Method setParam + * + * + * + * @param index + * @param vParam + */ + public void setParam(int index, org.vamsas.objects.core.Param vParam) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _paramList.size())) { + throw new IndexOutOfBoundsException("setParam: Index value '"+index+"' not in range [0.."+_paramList.size()+ "]"); + } + _paramList.setElementAt(vParam, index); + } //-- void setParam(int, org.vamsas.objects.core.Param) + + /** + * Method setParam + * + * + * + * @param paramArray + */ + public void setParam(org.vamsas.objects.core.Param[] paramArray) + { + //-- copy array + _paramList.removeAllElements(); + for (int i = 0; i < paramArray.length; i++) { + _paramList.addElement(paramArray[i]); + } + } //-- void setParam(org.vamsas.objects.core.Param) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'user'. The field 'user' has the + * following description: Who + * + * @param user the value of field 'user'. + */ + public void setUser(java.lang.String user) + { + this._user = user; + } //-- void setUser(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Entry + */ + public static org.vamsas.objects.core.Entry unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Entry) Unmarshaller.unmarshal(org.vamsas.objects.core.Entry.class, reader); + } //-- org.vamsas.objects.core.Entry unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/EntryDescriptor.java b/src/org/vamsas/objects/core/EntryDescriptor.java new file mode 100644 index 0000000..0426fa4 --- /dev/null +++ b/src/org/vamsas/objects/core/EntryDescriptor.java @@ -0,0 +1,471 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class EntryDescriptor. + * + * @version $Revision$ $Date$ + */ +public class EntryDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public EntryDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "entry"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _user + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_user", "User", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getUser(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.setUser( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _user + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _app + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_app", "App", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getApp(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.setApp( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _app + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _action + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_action", "Action", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getAction(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.setAction( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _action + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _date + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.exolab.castor.types.Date.class, "_date", "Date", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getDate(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.setDate( (org.exolab.castor.types.Date) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.exolab.castor.types.Date(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _date + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + DateTimeValidator typeValidator = new DateTimeValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _paramList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Param.class, "_paramList", "param", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getParam(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.addParam( (org.vamsas.objects.core.Param) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Param(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _paramList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _inputList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Input.class, "_inputList", "input", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Entry target = (Entry) object; + return target.getInput(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Entry target = (Entry) object; + target.addInput( (org.vamsas.objects.core.Input) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Input(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _inputList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.EntryDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Entry.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Glyph.java b/src/org/vamsas/objects/core/Glyph.java new file mode 100644 index 0000000..f5d9362 --- /dev/null +++ b/src/org/vamsas/objects/core/Glyph.java @@ -0,0 +1,233 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Discrete symbol - possibly graphically represented + * + * + * @version $Revision$ $Date$ + */ +public class Glyph extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * specifies the symbol dictionary for this + * glyph - eg utf8 (the default), aasecstr_3 or + * kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with + * invalid entries here + */ + private java.lang.String _dict = "utf8"; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Glyph() + { + super(); + setContent(""); + setDict("utf8"); + } //-- org.vamsas.objects.core.Glyph() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Glyph) { + + Glyph temp = (Glyph)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + if (this._dict != null) { + if (temp._dict == null) return false; + else if (!(this._dict.equals(temp._dict))) + return false; + } + else if (temp._dict != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'dict'. The field 'dict' has the + * following description: specifies the symbol dictionary for + * this + * glyph - eg utf8 (the default), aasecstr_3 or + * kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with + * invalid entries here + * + * @return String + * @return the value of field 'dict'. + */ + public java.lang.String getDict() + { + return this._dict; + } //-- java.lang.String getDict() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'dict'. The field 'dict' has the + * following description: specifies the symbol dictionary for + * this + * glyph - eg utf8 (the default), aasecstr_3 or + * kd_hydrophobicity - the content is not validated so + * applications must ensure they gracefully deal with + * invalid entries here + * + * @param dict the value of field 'dict'. + */ + public void setDict(java.lang.String dict) + { + this._dict = dict; + } //-- void setDict(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Glyph + */ + public static org.vamsas.objects.core.Glyph unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Glyph) Unmarshaller.unmarshal(org.vamsas.objects.core.Glyph.class, reader); + } //-- org.vamsas.objects.core.Glyph unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/GlyphDescriptor.java b/src/org/vamsas/objects/core/GlyphDescriptor.java new file mode 100644 index 0000000..e1d6966 --- /dev/null +++ b/src/org/vamsas/objects/core/GlyphDescriptor.java @@ -0,0 +1,244 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class GlyphDescriptor. + * + * @version $Revision$ $Date$ + */ +public class GlyphDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public GlyphDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "glyph"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Glyph target = (Glyph) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Glyph target = (Glyph) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _dict + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dict", "dict", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Glyph target = (Glyph) object; + return target.getDict(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Glyph target = (Glyph) object; + target.setDict( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _dict + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.GlyphDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Glyph.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Input.java b/src/org/vamsas/objects/core/Input.java new file mode 100644 index 0000000..4743d67 --- /dev/null +++ b/src/org/vamsas/objects/core/Input.java @@ -0,0 +1,219 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Input. + * + * @version $Revision$ $Date$ + */ +public class Input extends org.vamsas.objects.core.RangeType +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * Reference Frame for rangeType specfication + * + */ + private java.lang.Object _objRef; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Input() + { + super(); + } //-- org.vamsas.objects.core.Input() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Input) { + + Input temp = (Input)obj; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + if (this._objRef != null) { + if (temp._objRef == null) return false; + else if (!(this._objRef.equals(temp._objRef))) + return false; + } + else if (temp._objRef != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'objRef'. The field 'objRef' has + * the following description: Reference Frame for rangeType + * specfication + * + * + * @return Object + * @return the value of field 'objRef'. + */ + public java.lang.Object getObjRef() + { + return this._objRef; + } //-- java.lang.Object getObjRef() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'objRef'. The field 'objRef' has the + * following description: Reference Frame for rangeType + * specfication + * + * + * @param objRef the value of field 'objRef'. + */ + public void setObjRef(java.lang.Object objRef) + { + this._objRef = objRef; + } //-- void setObjRef(java.lang.Object) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return RangeType + */ + public static org.vamsas.objects.core.RangeType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Input) Unmarshaller.unmarshal(org.vamsas.objects.core.Input.class, reader); + } //-- org.vamsas.objects.core.RangeType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/InputDescriptor.java b/src/org/vamsas/objects/core/InputDescriptor.java new file mode 100644 index 0000000..56cc4b5 --- /dev/null +++ b/src/org/vamsas/objects/core/InputDescriptor.java @@ -0,0 +1,247 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class InputDescriptor. + * + * @version $Revision$ $Date$ + */ +public class InputDescriptor extends org.vamsas.objects.core.RangeTypeDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public InputDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.RangeTypeDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "input"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Input target = (Input) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Input target = (Input) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _objRef + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_objRef", "objRef", org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Input target = (Input) object; + return target.getObjRef(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Input target = (Input) object; + target.setObjRef( (java.lang.Object) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _objRef + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.InputDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Input.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Instance.java b/src/org/vamsas/objects/core/Instance.java new file mode 100644 index 0000000..037d035 --- /dev/null +++ b/src/org/vamsas/objects/core/Instance.java @@ -0,0 +1,179 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Instance. + * + * @version $Revision$ $Date$ + */ +public class Instance extends org.vamsas.objects.core.AppData +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _urn + */ + private java.lang.String _urn; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Instance() + { + super(); + } //-- org.vamsas.objects.core.Instance() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Instance) { + + Instance temp = (Instance)obj; + if (this._urn != null) { + if (temp._urn == null) return false; + else if (!(this._urn.equals(temp._urn))) + return false; + } + else if (temp._urn != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'urn'. + * + * @return String + * @return the value of field 'urn'. + */ + public java.lang.String getUrn() + { + return this._urn; + } //-- java.lang.String getUrn() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'urn'. + * + * @param urn the value of field 'urn'. + */ + public void setUrn(java.lang.String urn) + { + this._urn = urn; + } //-- void setUrn(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Instance) Unmarshaller.unmarshal(org.vamsas.objects.core.Instance.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/InstanceDescriptor.java b/src/org/vamsas/objects/core/InstanceDescriptor.java new file mode 100644 index 0000000..0fdec55 --- /dev/null +++ b/src/org/vamsas/objects/core/InstanceDescriptor.java @@ -0,0 +1,213 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class InstanceDescriptor. + * + * @version $Revision$ $Date$ + */ +public class InstanceDescriptor extends org.vamsas.objects.core.AppDataDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public InstanceDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "Instance"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _urn + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_urn", "urn", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Instance target = (Instance) object; + return target.getUrn(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Instance target = (Instance) object; + target.setUrn( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _urn + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.InstanceDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Instance.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Link.java b/src/org/vamsas/objects/core/Link.java new file mode 100644 index 0000000..1330cff --- /dev/null +++ b/src/org/vamsas/objects/core/Link.java @@ -0,0 +1,217 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Link. + * + * @version $Revision$ $Date$ + */ +public class Link extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * The URI + */ + private java.lang.String _href; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Link() + { + super(); + setContent(""); + } //-- org.vamsas.objects.core.Link() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Link) { + + Link temp = (Link)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + if (this._href != null) { + if (temp._href == null) return false; + else if (!(this._href.equals(temp._href))) + return false; + } + else if (temp._href != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'href'. The field 'href' has the + * following description: The URI + * + * @return String + * @return the value of field 'href'. + */ + public java.lang.String getHref() + { + return this._href; + } //-- java.lang.String getHref() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'href'. The field 'href' has the + * following description: The URI + * + * @param href the value of field 'href'. + */ + public void setHref(java.lang.String href) + { + this._href = href; + } //-- void setHref(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Link + */ + public static org.vamsas.objects.core.Link unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Link) Unmarshaller.unmarshal(org.vamsas.objects.core.Link.class, reader); + } //-- org.vamsas.objects.core.Link unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/LinkDescriptor.java b/src/org/vamsas/objects/core/LinkDescriptor.java new file mode 100644 index 0000000..659278d --- /dev/null +++ b/src/org/vamsas/objects/core/LinkDescriptor.java @@ -0,0 +1,240 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class LinkDescriptor. + * + * @version $Revision$ $Date$ + */ +public class LinkDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public LinkDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "link"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Link target = (Link) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Link target = (Link) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _href + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_href", "href", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Link target = (Link) object; + return target.getHref(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Link target = (Link) object; + target.setHref( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _href + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.LinkDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Link.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/LockFile.java b/src/org/vamsas/objects/core/LockFile.java new file mode 100644 index 0000000..a26bbe2 --- /dev/null +++ b/src/org/vamsas/objects/core/LockFile.java @@ -0,0 +1,182 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class LockFile. + * + * @version $Revision$ $Date$ + */ +public class LockFile extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public LockFile() + { + super(); + setContent(""); + } //-- org.vamsas.objects.core.LockFile() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof LockFile) { + + LockFile temp = (LockFile)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return LockFile + */ + public static org.vamsas.objects.core.LockFile unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.LockFile) Unmarshaller.unmarshal(org.vamsas.objects.core.LockFile.class, reader); + } //-- org.vamsas.objects.core.LockFile unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/LockFileDescriptor.java b/src/org/vamsas/objects/core/LockFileDescriptor.java new file mode 100644 index 0000000..b837f28 --- /dev/null +++ b/src/org/vamsas/objects/core/LockFileDescriptor.java @@ -0,0 +1,207 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class LockFileDescriptor. + * + * @version $Revision$ $Date$ + */ +public class LockFileDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public LockFileDescriptor() + { + super(); + nsURI = "http://www.vamsas.ac.uk/vamsasDocument"; + xmlName = "LockFile"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + LockFile target = (LockFile) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + LockFile target = (LockFile) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.LockFileDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.LockFile.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Map.java b/src/org/vamsas/objects/core/Map.java new file mode 100644 index 0000000..38bab4b --- /dev/null +++ b/src/org/vamsas/objects/core/Map.java @@ -0,0 +1,151 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * From: Offset to first + * position in dataset sequence record that + * this database entry maps to To: Offset + * to last position in dataset sequence + * record that this database entry maps to + * Start: Offset to first last position in + * database entry that first (or offset) + * position in sequence maps to End: Offset + * to last position in database entry that + * last (offset) position in sequence maps + * to + * + * @version $Revision$ $Date$ + */ +public class Map extends org.vamsas.objects.core.MapList +implements java.io.Serializable +{ + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Map() + { + super(); + } //-- org.vamsas.objects.core.Map() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Map) { + + Map temp = (Map)obj; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return MapList + */ + public static org.vamsas.objects.core.MapList unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Map) Unmarshaller.unmarshal(org.vamsas.objects.core.Map.class, reader); + } //-- org.vamsas.objects.core.MapList unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/MapDescriptor.java b/src/org/vamsas/objects/core/MapDescriptor.java new file mode 100644 index 0000000..a4c5123 --- /dev/null +++ b/src/org/vamsas/objects/core/MapDescriptor.java @@ -0,0 +1,167 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class MapDescriptor. + * + * @version $Revision$ $Date$ + */ +public class MapDescriptor extends org.vamsas.objects.core.MapListDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public MapDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.MapListDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "map"; + } //-- org.vamsas.objects.core.MapDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Map.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/MapList.java b/src/org/vamsas/objects/core/MapList.java new file mode 100644 index 0000000..608ee58 --- /dev/null +++ b/src/org/vamsas/objects/core/MapList.java @@ -0,0 +1,404 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class MapList. + * + * @version $Revision$ $Date$ + */ +public class MapList extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Offset to first position in dataset sequence record that + * start + * position on 'onto' maps to + */ + private int _from = 0; + + /** + * keeps track of state for field: _from + */ + private boolean _has_from; + + /** + * Offset to last position in dataset sequence record that end + * position on 'onto' maps to + */ + private int _to = 0; + + /** + * keeps track of state for field: _to + */ + private boolean _has_to; + + /** + * Offset to first position in database entry that first (or + * offset) + * position in sequence maps to + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Offset to last position in database entry that last (offset) + * position in sequence maps to + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public MapList() + { + super(); + } //-- org.vamsas.objects.core.MapList() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteEnd + * + */ + public void deleteEnd() + { + this._has_end= false; + } //-- void deleteEnd() + + /** + * Method deleteFrom + * + */ + public void deleteFrom() + { + this._has_from= false; + } //-- void deleteFrom() + + /** + * Method deleteStart + * + */ + public void deleteStart() + { + this._has_start= false; + } //-- void deleteStart() + + /** + * Method deleteTo + * + */ + public void deleteTo() + { + this._has_to= false; + } //-- void deleteTo() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof MapList) { + + MapList temp = (MapList)obj; + if (this._from != temp._from) + return false; + if (this._has_from != temp._has_from) + return false; + if (this._to != temp._to) + return false; + if (this._has_to != temp._has_to) + return false; + if (this._start != temp._start) + return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'end'. The field 'end' has the + * following description: Offset to last position in database + * entry that last (offset) + * position in sequence maps to + * + * @return int + * @return the value of field 'end'. + */ + public int getEnd() + { + return this._end; + } //-- int getEnd() + + /** + * Returns the value of field 'from'. The field 'from' has the + * following description: Offset to first position in dataset + * sequence record that start + * position on 'onto' maps to + * + * @return int + * @return the value of field 'from'. + */ + public int getFrom() + { + return this._from; + } //-- int getFrom() + + /** + * Returns the value of field 'start'. The field 'start' has + * the following description: Offset to first position in + * database entry that first (or offset) + * position in sequence maps to + * + * @return int + * @return the value of field 'start'. + */ + public int getStart() + { + return this._start; + } //-- int getStart() + + /** + * Returns the value of field 'to'. The field 'to' has the + * following description: Offset to last position in dataset + * sequence record that end + * position on 'onto' maps to + * + * @return int + * @return the value of field 'to'. + */ + public int getTo() + { + return this._to; + } //-- int getTo() + + /** + * Method hasEnd + * + * + * + * @return boolean + */ + public boolean hasEnd() + { + return this._has_end; + } //-- boolean hasEnd() + + /** + * Method hasFrom + * + * + * + * @return boolean + */ + public boolean hasFrom() + { + return this._has_from; + } //-- boolean hasFrom() + + /** + * Method hasStart + * + * + * + * @return boolean + */ + public boolean hasStart() + { + return this._has_start; + } //-- boolean hasStart() + + /** + * Method hasTo + * + * + * + * @return boolean + */ + public boolean hasTo() + { + return this._has_to; + } //-- boolean hasTo() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'end'. The field 'end' has the + * following description: Offset to last position in database + * entry that last (offset) + * position in sequence maps to + * + * @param end the value of field 'end'. + */ + public void setEnd(int end) + { + this._end = end; + this._has_end = true; + } //-- void setEnd(int) + + /** + * Sets the value of field 'from'. The field 'from' has the + * following description: Offset to first position in dataset + * sequence record that start + * position on 'onto' maps to + * + * @param from the value of field 'from'. + */ + public void setFrom(int from) + { + this._from = from; + this._has_from = true; + } //-- void setFrom(int) + + /** + * Sets the value of field 'start'. The field 'start' has the + * following description: Offset to first position in database + * entry that first (or offset) + * position in sequence maps to + * + * @param start the value of field 'start'. + */ + public void setStart(int start) + { + this._start = start; + this._has_start = true; + } //-- void setStart(int) + + /** + * Sets the value of field 'to'. The field 'to' has the + * following description: Offset to last position in dataset + * sequence record that end + * position on 'onto' maps to + * + * @param to the value of field 'to'. + */ + public void setTo(int to) + { + this._to = to; + this._has_to = true; + } //-- void setTo(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return MapList + */ + public static org.vamsas.objects.core.MapList unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.MapList) Unmarshaller.unmarshal(org.vamsas.objects.core.MapList.class, reader); + } //-- org.vamsas.objects.core.MapList unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/MapListDescriptor.java b/src/org/vamsas/objects/core/MapListDescriptor.java new file mode 100644 index 0000000..4d46e41 --- /dev/null +++ b/src/org/vamsas/objects/core/MapListDescriptor.java @@ -0,0 +1,339 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class MapListDescriptor. + * + * @version $Revision$ $Date$ + */ +public class MapListDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public MapListDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "mapList"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _from + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_from", "from", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + MapList target = (MapList) object; + if(!target.hasFrom()) + return null; + return new java.lang.Integer(target.getFrom()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + MapList target = (MapList) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteFrom(); + return; + } + target.setFrom( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _from + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _to + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_to", "to", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + MapList target = (MapList) object; + if(!target.hasTo()) + return null; + return new java.lang.Integer(target.getTo()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + MapList target = (MapList) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteTo(); + return; + } + target.setTo( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _to + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + MapList target = (MapList) object; + if(!target.hasStart()) + return null; + return new java.lang.Integer(target.getStart()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + MapList target = (MapList) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setStart( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + MapList target = (MapList) object; + if(!target.hasEnd()) + return null; + return new java.lang.Integer(target.getEnd()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + MapList target = (MapList) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setEnd( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.MapListDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.MapList.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Mapping.java b/src/org/vamsas/objects/core/Mapping.java new file mode 100644 index 0000000..e68ad1d --- /dev/null +++ b/src/org/vamsas/objects/core/Mapping.java @@ -0,0 +1,186 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Mapping. + * + * @version $Revision$ $Date$ + */ +public class Mapping extends org.vamsas.objects.core.MapList +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * object to which the mapping is being mapped + * + */ + private java.lang.Object _onto; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Mapping() + { + super(); + } //-- org.vamsas.objects.core.Mapping() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Mapping) { + + Mapping temp = (Mapping)obj; + if (this._onto != null) { + if (temp._onto == null) return false; + else if (!(this._onto.equals(temp._onto))) + return false; + } + else if (temp._onto != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'onto'. The field 'onto' has the + * following description: object to which the mapping is being + * mapped + * + * + * @return Object + * @return the value of field 'onto'. + */ + public java.lang.Object getOnto() + { + return this._onto; + } //-- java.lang.Object getOnto() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'onto'. The field 'onto' has the + * following description: object to which the mapping is being + * mapped + * + * + * @param onto the value of field 'onto'. + */ + public void setOnto(java.lang.Object onto) + { + this._onto = onto; + } //-- void setOnto(java.lang.Object) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return MapList + */ + public static org.vamsas.objects.core.MapList unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Mapping) Unmarshaller.unmarshal(org.vamsas.objects.core.Mapping.class, reader); + } //-- org.vamsas.objects.core.MapList unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/MappingDescriptor.java b/src/org/vamsas/objects/core/MappingDescriptor.java new file mode 100644 index 0000000..95a6cbb --- /dev/null +++ b/src/org/vamsas/objects/core/MappingDescriptor.java @@ -0,0 +1,210 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class MappingDescriptor. + * + * @version $Revision$ $Date$ + */ +public class MappingDescriptor extends org.vamsas.objects.core.MapListDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public MappingDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.MapListDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "mapping"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _onto + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Object.class, "_onto", "onto", org.exolab.castor.xml.NodeType.Attribute); + desc.setReference(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Mapping target = (Mapping) object; + return target.getOnto(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Mapping target = (Mapping) object; + target.setOnto( (java.lang.Object) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.Object(); + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _onto + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.MappingDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Mapping.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Newick.java b/src/org/vamsas/objects/core/Newick.java new file mode 100644 index 0000000..2c60f61 --- /dev/null +++ b/src/org/vamsas/objects/core/Newick.java @@ -0,0 +1,288 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Newick. + * + * @version $Revision$ $Date$ + */ +public class Newick extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * Field _title + */ + private java.lang.String _title; + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Field _modifiable + */ + private java.lang.String _modifiable; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Newick() + { + super(); + setContent(""); + } //-- org.vamsas.objects.core.Newick() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Newick) { + + Newick temp = (Newick)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + if (this._title != null) { + if (temp._title == null) return false; + else if (!(this._title.equals(temp._title))) + return false; + } + else if (temp._title != null) + return false; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) return false; + else if (!(this._modifiable.equals(temp._modifiable))) + return false; + } + else if (temp._modifiable != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'modifiable'. + * + * @return String + * @return the value of field 'modifiable'. + */ + public java.lang.String getModifiable() + { + return this._modifiable; + } //-- java.lang.String getModifiable() + + /** + * Returns the value of field 'title'. + * + * @return String + * @return the value of field 'title'. + */ + public java.lang.String getTitle() + { + return this._title; + } //-- java.lang.String getTitle() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable the value of field 'modifiable'. + */ + public void setModifiable(java.lang.String modifiable) + { + this._modifiable = modifiable; + } //-- void setModifiable(java.lang.String) + + /** + * Sets the value of field 'title'. + * + * @param title the value of field 'title'. + */ + public void setTitle(java.lang.String title) + { + this._title = title; + } //-- void setTitle(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Newick + */ + public static org.vamsas.objects.core.Newick unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Newick) Unmarshaller.unmarshal(org.vamsas.objects.core.Newick.class, reader); + } //-- org.vamsas.objects.core.Newick unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/NewickDescriptor.java b/src/org/vamsas/objects/core/NewickDescriptor.java new file mode 100644 index 0000000..d56a141 --- /dev/null +++ b/src/org/vamsas/objects/core/NewickDescriptor.java @@ -0,0 +1,315 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class NewickDescriptor. + * + * @version $Revision$ $Date$ + */ +public class NewickDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public NewickDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "newick"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Newick target = (Newick) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Newick target = (Newick) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _title + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_title", "title", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Newick target = (Newick) object; + return target.getTitle(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Newick target = (Newick) object; + target.setTitle( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _title + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Newick target = (Newick) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Newick target = (Newick) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Newick target = (Newick) object; + return target.getModifiable(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Newick target = (Newick) object; + target.setModifiable( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.NewickDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Newick.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Param.java b/src/org/vamsas/objects/core/Param.java new file mode 100644 index 0000000..b7c2ab5 --- /dev/null +++ b/src/org/vamsas/objects/core/Param.java @@ -0,0 +1,261 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Param. + * + * @version $Revision$ $Date$ + */ +public class Param extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * The type specifies how the property will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + */ + private java.lang.String _type; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Param() + { + super(); + setContent(""); + } //-- org.vamsas.objects.core.Param() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Param) { + + Param temp = (Param)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + if (this._type != null) { + if (temp._type == null) return false; + else if (!(this._type.equals(temp._type))) + return false; + } + else if (temp._type != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'type'. The field 'type' has the + * following description: The type specifies how the property + * will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'type'. The field 'type' has the + * following description: The type specifies how the property + * will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Param + */ + public static org.vamsas.objects.core.Param unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Param) Unmarshaller.unmarshal(org.vamsas.objects.core.Param.class, reader); + } //-- org.vamsas.objects.core.Param unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/ParamDescriptor.java b/src/org/vamsas/objects/core/ParamDescriptor.java new file mode 100644 index 0000000..d049192 --- /dev/null +++ b/src/org/vamsas/objects/core/ParamDescriptor.java @@ -0,0 +1,285 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class ParamDescriptor. + * + * @version $Revision$ $Date$ + */ +public class ParamDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public ParamDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "param"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Param target = (Param) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Param target = (Param) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Param target = (Param) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Param target = (Param) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Param target = (Param) object; + return target.getType(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Param target = (Param) object; + target.setType( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.ParamDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Param.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Pos.java b/src/org/vamsas/objects/core/Pos.java new file mode 100644 index 0000000..5053f98 --- /dev/null +++ b/src/org/vamsas/objects/core/Pos.java @@ -0,0 +1,204 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * a position within the associated object's coordinate system + * + * + * @version $Revision$ $Date$ + */ +public class Pos extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _i + */ + private int _i; + + /** + * keeps track of state for field: _i + */ + private boolean _has_i; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Pos() + { + super(); + } //-- org.vamsas.objects.core.Pos() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteI + * + */ + public void deleteI() + { + this._has_i= false; + } //-- void deleteI() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Pos) { + + Pos temp = (Pos)obj; + if (this._i != temp._i) + return false; + if (this._has_i != temp._has_i) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'i'. + * + * @return int + * @return the value of field 'i'. + */ + public int getI() + { + return this._i; + } //-- int getI() + + /** + * Method hasI + * + * + * + * @return boolean + */ + public boolean hasI() + { + return this._has_i; + } //-- boolean hasI() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'i'. + * + * @param i the value of field 'i'. + */ + public void setI(int i) + { + this._i = i; + this._has_i = true; + } //-- void setI(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Pos + */ + public static org.vamsas.objects.core.Pos unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Pos) Unmarshaller.unmarshal(org.vamsas.objects.core.Pos.class, reader); + } //-- org.vamsas.objects.core.Pos unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/PosDescriptor.java b/src/org/vamsas/objects/core/PosDescriptor.java new file mode 100644 index 0000000..fdfffc7 --- /dev/null +++ b/src/org/vamsas/objects/core/PosDescriptor.java @@ -0,0 +1,213 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class PosDescriptor. + * + * @version $Revision$ $Date$ + */ +public class PosDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public PosDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "pos"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _i + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_i", "i", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Pos target = (Pos) object; + if(!target.hasI()) + return null; + return new java.lang.Integer(target.getI()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Pos target = (Pos) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setI( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _i + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.PosDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Pos.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Property.java b/src/org/vamsas/objects/core/Property.java new file mode 100644 index 0000000..fb4aacc --- /dev/null +++ b/src/org/vamsas/objects/core/Property.java @@ -0,0 +1,261 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Property. + * + * @version $Revision$ $Date$ + */ +public class Property extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * The type specifies how the property will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + */ + private java.lang.String _type; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Property() + { + super(); + setContent(""); + } //-- org.vamsas.objects.core.Property() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Property) { + + Property temp = (Property)obj; + if (this._content != null) { + if (temp._content == null) return false; + else if (!(this._content.equals(temp._content))) + return false; + } + else if (temp._content != null) + return false; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + if (this._type != null) { + if (temp._type == null) return false; + else if (!(this._type.equals(temp._type))) + return false; + } + else if (temp._type != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'type'. The field 'type' has the + * following description: The type specifies how the property + * will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'type'. The field 'type' has the + * following description: The type specifies how the property + * will be parsed. + * Empty property strings are allowed, and can be used to + * prototype the + * input to a document. TODO: specify allowed types + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Property + */ + public static org.vamsas.objects.core.Property unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Property) Unmarshaller.unmarshal(org.vamsas.objects.core.Property.class, reader); + } //-- org.vamsas.objects.core.Property unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/PropertyDescriptor.java b/src/org/vamsas/objects/core/PropertyDescriptor.java new file mode 100644 index 0000000..bb80022 --- /dev/null +++ b/src/org/vamsas/objects/core/PropertyDescriptor.java @@ -0,0 +1,285 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class PropertyDescriptor. + * + * @version $Revision$ $Date$ + */ +public class PropertyDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public PropertyDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "property"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Property target = (Property) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Property target = (Property) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Property target = (Property) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Property target = (Property) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Property target = (Property) object; + return target.getType(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Property target = (Property) object; + target.setType( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.PropertyDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Property.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Provenance.java b/src/org/vamsas/objects/core/Provenance.java new file mode 100644 index 0000000..e1f6b85 --- /dev/null +++ b/src/org/vamsas/objects/core/Provenance.java @@ -0,0 +1,306 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Provenance. + * + * @version $Revision$ $Date$ + */ +public class Provenance extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _entryList + */ + private java.util.Vector _entryList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Provenance() + { + super(); + _entryList = new Vector(); + } //-- org.vamsas.objects.core.Provenance() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addEntry + * + * + * + * @param vEntry + */ + public void addEntry(org.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException + { + _entryList.addElement(vEntry); + } //-- void addEntry(org.vamsas.objects.core.Entry) + + /** + * Method addEntry + * + * + * + * @param index + * @param vEntry + */ + public void addEntry(int index, org.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException + { + _entryList.insertElementAt(vEntry, index); + } //-- void addEntry(int, org.vamsas.objects.core.Entry) + + /** + * Method enumerateEntry + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateEntry() + { + return _entryList.elements(); + } //-- java.util.Enumeration enumerateEntry() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Provenance) { + + Provenance temp = (Provenance)obj; + if (this._entryList != null) { + if (temp._entryList == null) return false; + else if (!(this._entryList.equals(temp._entryList))) + return false; + } + else if (temp._entryList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getEntry + * + * + * + * @param index + * @return Entry + */ + public org.vamsas.objects.core.Entry getEntry(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _entryList.size())) { + throw new IndexOutOfBoundsException("getEntry: Index value '"+index+"' not in range [0.."+_entryList.size()+ "]"); + } + + return (org.vamsas.objects.core.Entry) _entryList.elementAt(index); + } //-- org.vamsas.objects.core.Entry getEntry(int) + + /** + * Method getEntry + * + * + * + * @return Entry + */ + public org.vamsas.objects.core.Entry[] getEntry() + { + int size = _entryList.size(); + org.vamsas.objects.core.Entry[] mArray = new org.vamsas.objects.core.Entry[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Entry) _entryList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Entry[] getEntry() + + /** + * Method getEntryCount + * + * + * + * @return int + */ + public int getEntryCount() + { + return _entryList.size(); + } //-- int getEntryCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllEntry + * + */ + public void removeAllEntry() + { + _entryList.removeAllElements(); + } //-- void removeAllEntry() + + /** + * Method removeEntry + * + * + * + * @param index + * @return Entry + */ + public org.vamsas.objects.core.Entry removeEntry(int index) + { + java.lang.Object obj = _entryList.elementAt(index); + _entryList.removeElementAt(index); + return (org.vamsas.objects.core.Entry) obj; + } //-- org.vamsas.objects.core.Entry removeEntry(int) + + /** + * Method setEntry + * + * + * + * @param index + * @param vEntry + */ + public void setEntry(int index, org.vamsas.objects.core.Entry vEntry) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _entryList.size())) { + throw new IndexOutOfBoundsException("setEntry: Index value '"+index+"' not in range [0.."+_entryList.size()+ "]"); + } + _entryList.setElementAt(vEntry, index); + } //-- void setEntry(int, org.vamsas.objects.core.Entry) + + /** + * Method setEntry + * + * + * + * @param entryArray + */ + public void setEntry(org.vamsas.objects.core.Entry[] entryArray) + { + //-- copy array + _entryList.removeAllElements(); + for (int i = 0; i < entryArray.length; i++) { + _entryList.addElement(entryArray[i]); + } + } //-- void setEntry(org.vamsas.objects.core.Entry) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Provenance + */ + public static org.vamsas.objects.core.Provenance unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Provenance) Unmarshaller.unmarshal(org.vamsas.objects.core.Provenance.class, reader); + } //-- org.vamsas.objects.core.Provenance unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/ProvenanceDescriptor.java b/src/org/vamsas/objects/core/ProvenanceDescriptor.java new file mode 100644 index 0000000..a76c8ab --- /dev/null +++ b/src/org/vamsas/objects/core/ProvenanceDescriptor.java @@ -0,0 +1,210 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class ProvenanceDescriptor. + * + * @version $Revision$ $Date$ + */ +public class ProvenanceDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public ProvenanceDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "Provenance"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- initialize element descriptors + + //-- _entryList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Entry.class, "_entryList", "entry", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Provenance target = (Provenance) object; + return target.getEntry(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Provenance target = (Provenance) object; + target.addEntry( (org.vamsas.objects.core.Entry) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Entry(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _entryList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.ProvenanceDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Provenance.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/RangeAnnotation.java b/src/org/vamsas/objects/core/RangeAnnotation.java new file mode 100644 index 0000000..0dda140 --- /dev/null +++ b/src/org/vamsas/objects/core/RangeAnnotation.java @@ -0,0 +1,1093 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Annotation for a rangeSpec - values can be attached for the + * whole + * specification, and to each position within the spec. following + * the orientation + * specified by the ordered set of rangeSpec (pos, seg) elements. + * + * @version $Revision$ $Date$ + */ +public class RangeAnnotation extends org.vamsas.objects.core.RangeType +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * Field _modifiable + */ + private java.lang.String _modifiable; + + /** + * Annotation with the same non-empty group name are grouped + * together + */ + private java.lang.String _group = ""; + + /** + * A Das Feature has both a type and a Type ID. We go the + * route of requiring the type string to be taken from a + * controlled + * vocabulary if an application expects others to make sense + * of it. The + * type may qualified - so uniprot:CHAIN is a valid type name, + * and + * considered distinct from someotherDB:CHAIN + */ + private java.lang.String _type; + + /** + * Short, meaningful name for the annotation - if this + * is absent, then the type string should be used in its + * place. + * + */ + private java.lang.String _label; + + /** + * Human readable description of the annotation + * + */ + private java.lang.String _description; + + /** + * TODO: specify this - we have considered taking the GO + * evidence codes as a model for assessing a measure of + * quality to an + * annotation. + */ + private java.lang.String _status; + + /** + * Annotation Element position maps to ordered positions + * defined by the sequence of rangeType pos positions or + * concatenated + * seg start/end segments. + */ + private java.util.Vector _annotationElementList; + + /** + * Ordered set of optionally named float values for the + * whole annotation + */ + private java.util.Vector _scoreList; + + /** + * Field _linkList + */ + private java.util.Vector _linkList; + + /** + * Note:These are mutable so an application should check + * them each time. + */ + private java.util.Vector _propertyList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public RangeAnnotation() + { + super(); + setGroup(""); + _annotationElementList = new Vector(); + _scoreList = new Vector(); + _linkList = new Vector(); + _propertyList = new Vector(); + } //-- org.vamsas.objects.core.RangeAnnotation() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAnnotationElement + * + * + * + * @param vAnnotationElement + */ + public void addAnnotationElement(org.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + _annotationElementList.addElement(vAnnotationElement); + } //-- void addAnnotationElement(org.vamsas.objects.core.AnnotationElement) + + /** + * Method addAnnotationElement + * + * + * + * @param index + * @param vAnnotationElement + */ + public void addAnnotationElement(int index, org.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + _annotationElementList.insertElementAt(vAnnotationElement, index); + } //-- void addAnnotationElement(int, org.vamsas.objects.core.AnnotationElement) + + /** + * Method addLink + * + * + * + * @param vLink + */ + public void addLink(org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.addElement(vLink); + } //-- void addLink(org.vamsas.objects.core.Link) + + /** + * Method addLink + * + * + * + * @param index + * @param vLink + */ + public void addLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.insertElementAt(vLink, index); + } //-- void addLink(int, org.vamsas.objects.core.Link) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method addScore + * + * + * + * @param vScore + */ + public void addScore(org.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException + { + _scoreList.addElement(vScore); + } //-- void addScore(org.vamsas.objects.core.Score) + + /** + * Method addScore + * + * + * + * @param index + * @param vScore + */ + public void addScore(int index, org.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException + { + _scoreList.insertElementAt(vScore, index); + } //-- void addScore(int, org.vamsas.objects.core.Score) + + /** + * Method enumerateAnnotationElement + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAnnotationElement() + { + return _annotationElementList.elements(); + } //-- java.util.Enumeration enumerateAnnotationElement() + + /** + * Method enumerateLink + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateLink() + { + return _linkList.elements(); + } //-- java.util.Enumeration enumerateLink() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Method enumerateScore + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateScore() + { + return _scoreList.elements(); + } //-- java.util.Enumeration enumerateScore() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof RangeAnnotation) { + + RangeAnnotation temp = (RangeAnnotation)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) return false; + else if (!(this._modifiable.equals(temp._modifiable))) + return false; + } + else if (temp._modifiable != null) + return false; + if (this._group != null) { + if (temp._group == null) return false; + else if (!(this._group.equals(temp._group))) + return false; + } + else if (temp._group != null) + return false; + if (this._type != null) { + if (temp._type == null) return false; + else if (!(this._type.equals(temp._type))) + return false; + } + else if (temp._type != null) + return false; + if (this._label != null) { + if (temp._label == null) return false; + else if (!(this._label.equals(temp._label))) + return false; + } + else if (temp._label != null) + return false; + if (this._description != null) { + if (temp._description == null) return false; + else if (!(this._description.equals(temp._description))) + return false; + } + else if (temp._description != null) + return false; + if (this._status != null) { + if (temp._status == null) return false; + else if (!(this._status.equals(temp._status))) + return false; + } + else if (temp._status != null) + return false; + if (this._annotationElementList != null) { + if (temp._annotationElementList == null) return false; + else if (!(this._annotationElementList.equals(temp._annotationElementList))) + return false; + } + else if (temp._annotationElementList != null) + return false; + if (this._scoreList != null) { + if (temp._scoreList == null) return false; + else if (!(this._scoreList.equals(temp._scoreList))) + return false; + } + else if (temp._scoreList != null) + return false; + if (this._linkList != null) { + if (temp._linkList == null) return false; + else if (!(this._linkList.equals(temp._linkList))) + return false; + } + else if (temp._linkList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getAnnotationElement + * + * + * + * @param index + * @return AnnotationElement + */ + public org.vamsas.objects.core.AnnotationElement getAnnotationElement(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _annotationElementList.size())) { + throw new IndexOutOfBoundsException("getAnnotationElement: Index value '"+index+"' not in range [0.."+_annotationElementList.size()+ "]"); + } + + return (org.vamsas.objects.core.AnnotationElement) _annotationElementList.elementAt(index); + } //-- org.vamsas.objects.core.AnnotationElement getAnnotationElement(int) + + /** + * Method getAnnotationElement + * + * + * + * @return AnnotationElement + */ + public org.vamsas.objects.core.AnnotationElement[] getAnnotationElement() + { + int size = _annotationElementList.size(); + org.vamsas.objects.core.AnnotationElement[] mArray = new org.vamsas.objects.core.AnnotationElement[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.AnnotationElement) _annotationElementList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.AnnotationElement[] getAnnotationElement() + + /** + * Method getAnnotationElementCount + * + * + * + * @return int + */ + public int getAnnotationElementCount() + { + return _annotationElementList.size(); + } //-- int getAnnotationElementCount() + + /** + * Returns the value of field 'description'. The field + * 'description' has the following description: Human readable + * description of the annotation + * + * + * @return String + * @return the value of field 'description'. + */ + public java.lang.String getDescription() + { + return this._description; + } //-- java.lang.String getDescription() + + /** + * Returns the value of field 'group'. The field 'group' has + * the following description: Annotation with the same + * non-empty group name are grouped + * together + * + * @return String + * @return the value of field 'group'. + */ + public java.lang.String getGroup() + { + return this._group; + } //-- java.lang.String getGroup() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'label'. The field 'label' has + * the following description: Short, meaningful name for the + * annotation - if this + * is absent, then the type string should be used in its + * place. + * + * + * @return String + * @return the value of field 'label'. + */ + public java.lang.String getLabel() + { + return this._label; + } //-- java.lang.String getLabel() + + /** + * Method getLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link getLink(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("getLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + + return (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } //-- org.vamsas.objects.core.Link getLink(int) + + /** + * Method getLink + * + * + * + * @return Link + */ + public org.vamsas.objects.core.Link[] getLink() + { + int size = _linkList.size(); + org.vamsas.objects.core.Link[] mArray = new org.vamsas.objects.core.Link[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Link[] getLink() + + /** + * Method getLinkCount + * + * + * + * @return int + */ + public int getLinkCount() + { + return _linkList.size(); + } //-- int getLinkCount() + + /** + * Returns the value of field 'modifiable'. + * + * @return String + * @return the value of field 'modifiable'. + */ + public java.lang.String getModifiable() + { + return this._modifiable; + } //-- java.lang.String getModifiable() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Method getScore + * + * + * + * @param index + * @return Score + */ + public org.vamsas.objects.core.Score getScore(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _scoreList.size())) { + throw new IndexOutOfBoundsException("getScore: Index value '"+index+"' not in range [0.."+_scoreList.size()+ "]"); + } + + return (org.vamsas.objects.core.Score) _scoreList.elementAt(index); + } //-- org.vamsas.objects.core.Score getScore(int) + + /** + * Method getScore + * + * + * + * @return Score + */ + public org.vamsas.objects.core.Score[] getScore() + { + int size = _scoreList.size(); + org.vamsas.objects.core.Score[] mArray = new org.vamsas.objects.core.Score[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Score) _scoreList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Score[] getScore() + + /** + * Method getScoreCount + * + * + * + * @return int + */ + public int getScoreCount() + { + return _scoreList.size(); + } //-- int getScoreCount() + + /** + * Returns the value of field 'status'. The field 'status' has + * the following description: TODO: specify this - we have + * considered taking the GO + * evidence codes as a model for assessing a measure of + * quality to an + * annotation. + * + * @return String + * @return the value of field 'status'. + */ + public java.lang.String getStatus() + { + return this._status; + } //-- java.lang.String getStatus() + + /** + * Returns the value of field 'type'. The field 'type' has the + * following description: A Das Feature has both a type and a + * Type ID. We go the + * route of requiring the type string to be taken from a + * controlled + * vocabulary if an application expects others to make sense + * of it. The + * type may qualified - so uniprot:CHAIN is a valid type name, + * and + * considered distinct from someotherDB:CHAIN + * + * @return String + * @return the value of field 'type'. + */ + public java.lang.String getType() + { + return this._type; + } //-- java.lang.String getType() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllAnnotationElement + * + */ + public void removeAllAnnotationElement() + { + _annotationElementList.removeAllElements(); + } //-- void removeAllAnnotationElement() + + /** + * Method removeAllLink + * + */ + public void removeAllLink() + { + _linkList.removeAllElements(); + } //-- void removeAllLink() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeAllScore + * + */ + public void removeAllScore() + { + _scoreList.removeAllElements(); + } //-- void removeAllScore() + + /** + * Method removeAnnotationElement + * + * + * + * @param index + * @return AnnotationElement + */ + public org.vamsas.objects.core.AnnotationElement removeAnnotationElement(int index) + { + java.lang.Object obj = _annotationElementList.elementAt(index); + _annotationElementList.removeElementAt(index); + return (org.vamsas.objects.core.AnnotationElement) obj; + } //-- org.vamsas.objects.core.AnnotationElement removeAnnotationElement(int) + + /** + * Method removeLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link removeLink(int index) + { + java.lang.Object obj = _linkList.elementAt(index); + _linkList.removeElementAt(index); + return (org.vamsas.objects.core.Link) obj; + } //-- org.vamsas.objects.core.Link removeLink(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Method removeScore + * + * + * + * @param index + * @return Score + */ + public org.vamsas.objects.core.Score removeScore(int index) + { + java.lang.Object obj = _scoreList.elementAt(index); + _scoreList.removeElementAt(index); + return (org.vamsas.objects.core.Score) obj; + } //-- org.vamsas.objects.core.Score removeScore(int) + + /** + * Method setAnnotationElement + * + * + * + * @param index + * @param vAnnotationElement + */ + public void setAnnotationElement(int index, org.vamsas.objects.core.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _annotationElementList.size())) { + throw new IndexOutOfBoundsException("setAnnotationElement: Index value '"+index+"' not in range [0.."+_annotationElementList.size()+ "]"); + } + _annotationElementList.setElementAt(vAnnotationElement, index); + } //-- void setAnnotationElement(int, org.vamsas.objects.core.AnnotationElement) + + /** + * Method setAnnotationElement + * + * + * + * @param annotationElementArray + */ + public void setAnnotationElement(org.vamsas.objects.core.AnnotationElement[] annotationElementArray) + { + //-- copy array + _annotationElementList.removeAllElements(); + for (int i = 0; i < annotationElementArray.length; i++) { + _annotationElementList.addElement(annotationElementArray[i]); + } + } //-- void setAnnotationElement(org.vamsas.objects.core.AnnotationElement) + + /** + * Sets the value of field 'description'. The field + * 'description' has the following description: Human readable + * description of the annotation + * + * + * @param description the value of field 'description'. + */ + public void setDescription(java.lang.String description) + { + this._description = description; + } //-- void setDescription(java.lang.String) + + /** + * Sets the value of field 'group'. The field 'group' has the + * following description: Annotation with the same non-empty + * group name are grouped + * together + * + * @param group the value of field 'group'. + */ + public void setGroup(java.lang.String group) + { + this._group = group; + } //-- void setGroup(java.lang.String) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'label'. The field 'label' has the + * following description: Short, meaningful name for the + * annotation - if this + * is absent, then the type string should be used in its + * place. + * + * + * @param label the value of field 'label'. + */ + public void setLabel(java.lang.String label) + { + this._label = label; + } //-- void setLabel(java.lang.String) + + /** + * Method setLink + * + * + * + * @param index + * @param vLink + */ + public void setLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("setLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + _linkList.setElementAt(vLink, index); + } //-- void setLink(int, org.vamsas.objects.core.Link) + + /** + * Method setLink + * + * + * + * @param linkArray + */ + public void setLink(org.vamsas.objects.core.Link[] linkArray) + { + //-- copy array + _linkList.removeAllElements(); + for (int i = 0; i < linkArray.length; i++) { + _linkList.addElement(linkArray[i]); + } + } //-- void setLink(org.vamsas.objects.core.Link) + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable the value of field 'modifiable'. + */ + public void setModifiable(java.lang.String modifiable) + { + this._modifiable = modifiable; + } //-- void setModifiable(java.lang.String) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Method setScore + * + * + * + * @param index + * @param vScore + */ + public void setScore(int index, org.vamsas.objects.core.Score vScore) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _scoreList.size())) { + throw new IndexOutOfBoundsException("setScore: Index value '"+index+"' not in range [0.."+_scoreList.size()+ "]"); + } + _scoreList.setElementAt(vScore, index); + } //-- void setScore(int, org.vamsas.objects.core.Score) + + /** + * Method setScore + * + * + * + * @param scoreArray + */ + public void setScore(org.vamsas.objects.core.Score[] scoreArray) + { + //-- copy array + _scoreList.removeAllElements(); + for (int i = 0; i < scoreArray.length; i++) { + _scoreList.addElement(scoreArray[i]); + } + } //-- void setScore(org.vamsas.objects.core.Score) + + /** + * Sets the value of field 'status'. The field 'status' has the + * following description: TODO: specify this - we have + * considered taking the GO + * evidence codes as a model for assessing a measure of + * quality to an + * annotation. + * + * @param status the value of field 'status'. + */ + public void setStatus(java.lang.String status) + { + this._status = status; + } //-- void setStatus(java.lang.String) + + /** + * Sets the value of field 'type'. The field 'type' has the + * following description: A Das Feature has both a type and a + * Type ID. We go the + * route of requiring the type string to be taken from a + * controlled + * vocabulary if an application expects others to make sense + * of it. The + * type may qualified - so uniprot:CHAIN is a valid type name, + * and + * considered distinct from someotherDB:CHAIN + * + * @param type the value of field 'type'. + */ + public void setType(java.lang.String type) + { + this._type = type; + } //-- void setType(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return RangeType + */ + public static org.vamsas.objects.core.RangeType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.RangeAnnotation) Unmarshaller.unmarshal(org.vamsas.objects.core.RangeAnnotation.class, reader); + } //-- org.vamsas.objects.core.RangeType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/RangeAnnotationDescriptor.java b/src/org/vamsas/objects/core/RangeAnnotationDescriptor.java new file mode 100644 index 0000000..39bb29a --- /dev/null +++ b/src/org/vamsas/objects/core/RangeAnnotationDescriptor.java @@ -0,0 +1,578 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class RangeAnnotationDescriptor. + * + * @version $Revision$ $Date$ + */ +public class RangeAnnotationDescriptor extends org.vamsas.objects.core.RangeTypeDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public RangeAnnotationDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.RangeTypeDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "rangeAnnotation"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getModifiable(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setModifiable( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _group + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_group", "group", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getGroup(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setGroup( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _group + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _type + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_type", "type", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getType(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setType( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _type + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _label + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_label", "label", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getLabel(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setLabel( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _label + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getDescription(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setDescription( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _status + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_status", "status", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getStatus(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.setStatus( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _status + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _annotationElementList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.AnnotationElement.class, "_annotationElementList", "annotationElement", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getAnnotationElement(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addAnnotationElement( (org.vamsas.objects.core.AnnotationElement) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.AnnotationElement(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _annotationElementList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _scoreList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Score.class, "_scoreList", "score", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getScore(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addScore( (org.vamsas.objects.core.Score) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Score(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _scoreList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _linkList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Link.class, "_linkList", "link", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getLink(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addLink( (org.vamsas.objects.core.Link) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Link(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _linkList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeAnnotation target = (RangeAnnotation) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeAnnotation target = (RangeAnnotation) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.RangeAnnotationDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.RangeAnnotation.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/RangeType.java b/src/org/vamsas/objects/core/RangeType.java new file mode 100644 index 0000000..c0d6571 --- /dev/null +++ b/src/org/vamsas/objects/core/RangeType.java @@ -0,0 +1,452 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; + +/** + * Specify an ordered set of positions and/or regions on the + * principle + * dimension of some associated vamsas object Keeping to jaxb-1.0 + * specification for the moment - this choice should + * become a substitution group when we use jaxb-2.0 capable + * bindings + * + * + * @version $Revision$ $Date$ + */ +public abstract class RangeType extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Internal choice value storage + */ + private java.lang.Object _choiceValue; + + /** + * a position within the associated object's coordinate system + * + */ + private java.util.Vector _posList; + + /** + * a region from start to end, with flag for inclusivity of + * terminii + */ + private java.util.Vector _segList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public RangeType() + { + super(); + _posList = new Vector(); + _segList = new Vector(); + } //-- org.vamsas.objects.core.RangeType() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addPos + * + * + * + * @param vPos + */ + public void addPos(org.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException + { + _posList.addElement(vPos); + } //-- void addPos(org.vamsas.objects.core.Pos) + + /** + * Method addPos + * + * + * + * @param index + * @param vPos + */ + public void addPos(int index, org.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException + { + _posList.insertElementAt(vPos, index); + } //-- void addPos(int, org.vamsas.objects.core.Pos) + + /** + * Method addSeg + * + * + * + * @param vSeg + */ + public void addSeg(org.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException + { + _segList.addElement(vSeg); + } //-- void addSeg(org.vamsas.objects.core.Seg) + + /** + * Method addSeg + * + * + * + * @param index + * @param vSeg + */ + public void addSeg(int index, org.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException + { + _segList.insertElementAt(vSeg, index); + } //-- void addSeg(int, org.vamsas.objects.core.Seg) + + /** + * Method enumeratePos + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumeratePos() + { + return _posList.elements(); + } //-- java.util.Enumeration enumeratePos() + + /** + * Method enumerateSeg + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateSeg() + { + return _segList.elements(); + } //-- java.util.Enumeration enumerateSeg() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof RangeType) { + + RangeType temp = (RangeType)obj; + if (this._choiceValue != null) { + if (temp._choiceValue == null) return false; + else if (!(this._choiceValue.equals(temp._choiceValue))) + return false; + } + else if (temp._choiceValue != null) + return false; + if (this._posList != null) { + if (temp._posList == null) return false; + else if (!(this._posList.equals(temp._posList))) + return false; + } + else if (temp._posList != null) + return false; + if (this._segList != null) { + if (temp._segList == null) return false; + else if (!(this._segList.equals(temp._segList))) + return false; + } + else if (temp._segList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'choiceValue'. The field + * 'choiceValue' has the following description: Internal choice + * value storage + * + * @return Object + * @return the value of field 'choiceValue'. + */ + public java.lang.Object getChoiceValue() + { + return this._choiceValue; + } //-- java.lang.Object getChoiceValue() + + /** + * Method getPos + * + * + * + * @param index + * @return Pos + */ + public org.vamsas.objects.core.Pos getPos(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _posList.size())) { + throw new IndexOutOfBoundsException("getPos: Index value '"+index+"' not in range [0.."+_posList.size()+ "]"); + } + + return (org.vamsas.objects.core.Pos) _posList.elementAt(index); + } //-- org.vamsas.objects.core.Pos getPos(int) + + /** + * Method getPos + * + * + * + * @return Pos + */ + public org.vamsas.objects.core.Pos[] getPos() + { + int size = _posList.size(); + org.vamsas.objects.core.Pos[] mArray = new org.vamsas.objects.core.Pos[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Pos) _posList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Pos[] getPos() + + /** + * Method getPosCount + * + * + * + * @return int + */ + public int getPosCount() + { + return _posList.size(); + } //-- int getPosCount() + + /** + * Method getSeg + * + * + * + * @param index + * @return Seg + */ + public org.vamsas.objects.core.Seg getSeg(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _segList.size())) { + throw new IndexOutOfBoundsException("getSeg: Index value '"+index+"' not in range [0.."+_segList.size()+ "]"); + } + + return (org.vamsas.objects.core.Seg) _segList.elementAt(index); + } //-- org.vamsas.objects.core.Seg getSeg(int) + + /** + * Method getSeg + * + * + * + * @return Seg + */ + public org.vamsas.objects.core.Seg[] getSeg() + { + int size = _segList.size(); + org.vamsas.objects.core.Seg[] mArray = new org.vamsas.objects.core.Seg[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Seg) _segList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Seg[] getSeg() + + /** + * Method getSegCount + * + * + * + * @return int + */ + public int getSegCount() + { + return _segList.size(); + } //-- int getSegCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method removeAllPos + * + */ + public void removeAllPos() + { + _posList.removeAllElements(); + } //-- void removeAllPos() + + /** + * Method removeAllSeg + * + */ + public void removeAllSeg() + { + _segList.removeAllElements(); + } //-- void removeAllSeg() + + /** + * Method removePos + * + * + * + * @param index + * @return Pos + */ + public org.vamsas.objects.core.Pos removePos(int index) + { + java.lang.Object obj = _posList.elementAt(index); + _posList.removeElementAt(index); + return (org.vamsas.objects.core.Pos) obj; + } //-- org.vamsas.objects.core.Pos removePos(int) + + /** + * Method removeSeg + * + * + * + * @param index + * @return Seg + */ + public org.vamsas.objects.core.Seg removeSeg(int index) + { + java.lang.Object obj = _segList.elementAt(index); + _segList.removeElementAt(index); + return (org.vamsas.objects.core.Seg) obj; + } //-- org.vamsas.objects.core.Seg removeSeg(int) + + /** + * Method setPos + * + * + * + * @param index + * @param vPos + */ + public void setPos(int index, org.vamsas.objects.core.Pos vPos) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _posList.size())) { + throw new IndexOutOfBoundsException("setPos: Index value '"+index+"' not in range [0.."+_posList.size()+ "]"); + } + _posList.setElementAt(vPos, index); + } //-- void setPos(int, org.vamsas.objects.core.Pos) + + /** + * Method setPos + * + * + * + * @param posArray + */ + public void setPos(org.vamsas.objects.core.Pos[] posArray) + { + //-- copy array + _posList.removeAllElements(); + for (int i = 0; i < posArray.length; i++) { + _posList.addElement(posArray[i]); + } + } //-- void setPos(org.vamsas.objects.core.Pos) + + /** + * Method setSeg + * + * + * + * @param index + * @param vSeg + */ + public void setSeg(int index, org.vamsas.objects.core.Seg vSeg) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _segList.size())) { + throw new IndexOutOfBoundsException("setSeg: Index value '"+index+"' not in range [0.."+_segList.size()+ "]"); + } + _segList.setElementAt(vSeg, index); + } //-- void setSeg(int, org.vamsas.objects.core.Seg) + + /** + * Method setSeg + * + * + * + * @param segArray + */ + public void setSeg(org.vamsas.objects.core.Seg[] segArray) + { + //-- copy array + _segList.removeAllElements(); + for (int i = 0; i < segArray.length; i++) { + _segList.addElement(segArray[i]); + } + } //-- void setSeg(org.vamsas.objects.core.Seg) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/RangeTypeDescriptor.java b/src/org/vamsas/objects/core/RangeTypeDescriptor.java new file mode 100644 index 0000000..20f0de9 --- /dev/null +++ b/src/org/vamsas/objects/core/RangeTypeDescriptor.java @@ -0,0 +1,246 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class RangeTypeDescriptor. + * + * @version $Revision$ $Date$ + */ +public class RangeTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public RangeTypeDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "rangeType"; + + //-- set grouping compositor + setCompositorAsChoice(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- initialize element descriptors + + //-- _posList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Pos.class, "_posList", "pos", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeType target = (RangeType) object; + return target.getPos(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeType target = (RangeType) object; + target.addPos( (org.vamsas.objects.core.Pos) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _posList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _segList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Seg.class, "_segList", "seg", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + RangeType target = (RangeType) object; + return target.getSeg(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + RangeType target = (RangeType) object; + target.addSeg( (org.vamsas.objects.core.Seg) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _segList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.RangeTypeDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.RangeType.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Score.java b/src/org/vamsas/objects/core/Score.java new file mode 100644 index 0000000..cb294f3 --- /dev/null +++ b/src/org/vamsas/objects/core/Score.java @@ -0,0 +1,240 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Ordered set of optionally named float values for the + * whole annotation + * + * @version $Revision$ $Date$ + */ +public class Score extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private float _content; + + /** + * keeps track of state for field: _content + */ + private boolean _has_content; + + /** + * Field _name + */ + private java.lang.String _name = "score"; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Score() + { + super(); + setName("score"); + } //-- org.vamsas.objects.core.Score() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteContent + * + */ + public void deleteContent() + { + this._has_content= false; + } //-- void deleteContent() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Score) { + + Score temp = (Score)obj; + if (this._content != temp._content) + return false; + if (this._has_content != temp._has_content) + return false; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return float + * @return the value of field 'content'. + */ + public float getContent() + { + return this._content; + } //-- float getContent() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Method hasContent + * + * + * + * @return boolean + */ + public boolean hasContent() + { + return this._has_content; + } //-- boolean hasContent() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(float content) + { + this._content = content; + this._has_content = true; + } //-- void setContent(float) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Score + */ + public static org.vamsas.objects.core.Score unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Score) Unmarshaller.unmarshal(org.vamsas.objects.core.Score.class, reader); + } //-- org.vamsas.objects.core.Score unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/ScoreDescriptor.java b/src/org/vamsas/objects/core/ScoreDescriptor.java new file mode 100644 index 0000000..c9c1eda --- /dev/null +++ b/src/org/vamsas/objects/core/ScoreDescriptor.java @@ -0,0 +1,249 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class ScoreDescriptor. + * + * @version $Revision$ $Date$ + */ +public class ScoreDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public ScoreDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "score"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(float.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Score target = (Score) object; + if(!target.hasContent()) + return null; + return new java.lang.Float(target.getContent()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Score target = (Score) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteContent(); + return; + } + target.setContent( ((java.lang.Float)value).floatValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + FloatValidator typeValidator = new FloatValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Score target = (Score) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Score target = (Score) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.ScoreDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Score.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Seg.java b/src/org/vamsas/objects/core/Seg.java new file mode 100644 index 0000000..5e36703 --- /dev/null +++ b/src/org/vamsas/objects/core/Seg.java @@ -0,0 +1,331 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * a region from start to end, with flag for inclusivity of + * terminii + * + * @version $Revision$ $Date$ + */ +public class Seg extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _start + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * when false, a consecutive range like 'start=1, end=2' + * means the region lying after position 1 and before position + * 2 + * + */ + private boolean _inclusive; + + /** + * keeps track of state for field: _inclusive + */ + private boolean _has_inclusive; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Seg() + { + super(); + } //-- org.vamsas.objects.core.Seg() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteEnd + * + */ + public void deleteEnd() + { + this._has_end= false; + } //-- void deleteEnd() + + /** + * Method deleteInclusive + * + */ + public void deleteInclusive() + { + this._has_inclusive= false; + } //-- void deleteInclusive() + + /** + * Method deleteStart + * + */ + public void deleteStart() + { + this._has_start= false; + } //-- void deleteStart() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Seg) { + + Seg temp = (Seg)obj; + if (this._start != temp._start) + return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + if (this._inclusive != temp._inclusive) + return false; + if (this._has_inclusive != temp._has_inclusive) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'end'. + * + * @return int + * @return the value of field 'end'. + */ + public int getEnd() + { + return this._end; + } //-- int getEnd() + + /** + * Returns the value of field 'inclusive'. The field + * 'inclusive' has the following description: when false, a + * consecutive range like 'start=1, end=2' + * means the region lying after position 1 and before position + * 2 + * + * + * @return boolean + * @return the value of field 'inclusive'. + */ + public boolean getInclusive() + { + return this._inclusive; + } //-- boolean getInclusive() + + /** + * Returns the value of field 'start'. + * + * @return int + * @return the value of field 'start'. + */ + public int getStart() + { + return this._start; + } //-- int getStart() + + /** + * Method hasEnd + * + * + * + * @return boolean + */ + public boolean hasEnd() + { + return this._has_end; + } //-- boolean hasEnd() + + /** + * Method hasInclusive + * + * + * + * @return boolean + */ + public boolean hasInclusive() + { + return this._has_inclusive; + } //-- boolean hasInclusive() + + /** + * Method hasStart + * + * + * + * @return boolean + */ + public boolean hasStart() + { + return this._has_start; + } //-- boolean hasStart() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'end'. + * + * @param end the value of field 'end'. + */ + public void setEnd(int end) + { + this._end = end; + this._has_end = true; + } //-- void setEnd(int) + + /** + * Sets the value of field 'inclusive'. The field 'inclusive' + * has the following description: when false, a consecutive + * range like 'start=1, end=2' + * means the region lying after position 1 and before position + * 2 + * + * + * @param inclusive the value of field 'inclusive'. + */ + public void setInclusive(boolean inclusive) + { + this._inclusive = inclusive; + this._has_inclusive = true; + } //-- void setInclusive(boolean) + + /** + * Sets the value of field 'start'. + * + * @param start the value of field 'start'. + */ + public void setStart(int start) + { + this._start = start; + this._has_start = true; + } //-- void setStart(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Seg + */ + public static org.vamsas.objects.core.Seg unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Seg) Unmarshaller.unmarshal(org.vamsas.objects.core.Seg.class, reader); + } //-- org.vamsas.objects.core.Seg unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/SegDescriptor.java b/src/org/vamsas/objects/core/SegDescriptor.java new file mode 100644 index 0000000..41a423c --- /dev/null +++ b/src/org/vamsas/objects/core/SegDescriptor.java @@ -0,0 +1,297 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class SegDescriptor. + * + * @version $Revision$ $Date$ + */ +public class SegDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SegDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "seg"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Seg target = (Seg) object; + if(!target.hasStart()) + return null; + return new java.lang.Integer(target.getStart()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setStart( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Seg target = (Seg) object; + if(!target.hasEnd()) + return null; + return new java.lang.Integer(target.getEnd()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setEnd( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _inclusive + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_inclusive", "inclusive", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Seg target = (Seg) object; + if(!target.hasInclusive()) + return null; + return (target.getInclusive() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Seg target = (Seg) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setInclusive( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _inclusive + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.SegDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Seg.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Sequence.java b/src/org/vamsas/objects/core/Sequence.java new file mode 100644 index 0000000..66dc569 --- /dev/null +++ b/src/org/vamsas/objects/core/Sequence.java @@ -0,0 +1,387 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Sequence. + * + * @version $Revision$ $Date$ + */ +public class Sequence extends org.vamsas.objects.core.SequenceType +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + * + */ + private java.lang.String _id; + + /** + * symbol class for sequence + * + */ + private java.lang.String _dictionary; + + /** + * Store a list of database references + * for this sequence record - with optional mapping + * from database sequence to the given sequence record + */ + private java.util.Vector _dbRefList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Sequence() + { + super(); + _dbRefList = new Vector(); + } //-- org.vamsas.objects.core.Sequence() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addDbRef + * + * + * + * @param vDbRef + */ + public void addDbRef(org.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException + { + _dbRefList.addElement(vDbRef); + } //-- void addDbRef(org.vamsas.objects.core.DbRef) + + /** + * Method addDbRef + * + * + * + * @param index + * @param vDbRef + */ + public void addDbRef(int index, org.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException + { + _dbRefList.insertElementAt(vDbRef, index); + } //-- void addDbRef(int, org.vamsas.objects.core.DbRef) + + /** + * Method enumerateDbRef + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateDbRef() + { + return _dbRefList.elements(); + } //-- java.util.Enumeration enumerateDbRef() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Sequence) { + + Sequence temp = (Sequence)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._dictionary != null) { + if (temp._dictionary == null) return false; + else if (!(this._dictionary.equals(temp._dictionary))) + return false; + } + else if (temp._dictionary != null) + return false; + if (this._dbRefList != null) { + if (temp._dbRefList == null) return false; + else if (!(this._dbRefList.equals(temp._dbRefList))) + return false; + } + else if (temp._dbRefList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getDbRef + * + * + * + * @param index + * @return DbRef + */ + public org.vamsas.objects.core.DbRef getDbRef(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dbRefList.size())) { + throw new IndexOutOfBoundsException("getDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]"); + } + + return (org.vamsas.objects.core.DbRef) _dbRefList.elementAt(index); + } //-- org.vamsas.objects.core.DbRef getDbRef(int) + + /** + * Method getDbRef + * + * + * + * @return DbRef + */ + public org.vamsas.objects.core.DbRef[] getDbRef() + { + int size = _dbRefList.size(); + org.vamsas.objects.core.DbRef[] mArray = new org.vamsas.objects.core.DbRef[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.DbRef) _dbRefList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.DbRef[] getDbRef() + + /** + * Method getDbRefCount + * + * + * + * @return int + */ + public int getDbRefCount() + { + return _dbRefList.size(); + } //-- int getDbRefCount() + + /** + * Returns the value of field 'dictionary'. The field + * 'dictionary' has the following description: symbol class for + * sequence + * + * + * @return String + * @return the value of field 'dictionary'. + */ + public java.lang.String getDictionary() + { + return this._dictionary; + } //-- java.lang.String getDictionary() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllDbRef + * + */ + public void removeAllDbRef() + { + _dbRefList.removeAllElements(); + } //-- void removeAllDbRef() + + /** + * Method removeDbRef + * + * + * + * @param index + * @return DbRef + */ + public org.vamsas.objects.core.DbRef removeDbRef(int index) + { + java.lang.Object obj = _dbRefList.elementAt(index); + _dbRefList.removeElementAt(index); + return (org.vamsas.objects.core.DbRef) obj; + } //-- org.vamsas.objects.core.DbRef removeDbRef(int) + + /** + * Method setDbRef + * + * + * + * @param index + * @param vDbRef + */ + public void setDbRef(int index, org.vamsas.objects.core.DbRef vDbRef) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dbRefList.size())) { + throw new IndexOutOfBoundsException("setDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]"); + } + _dbRefList.setElementAt(vDbRef, index); + } //-- void setDbRef(int, org.vamsas.objects.core.DbRef) + + /** + * Method setDbRef + * + * + * + * @param dbRefArray + */ + public void setDbRef(org.vamsas.objects.core.DbRef[] dbRefArray) + { + //-- copy array + _dbRefList.removeAllElements(); + for (int i = 0; i < dbRefArray.length; i++) { + _dbRefList.addElement(dbRefArray[i]); + } + } //-- void setDbRef(org.vamsas.objects.core.DbRef) + + /** + * Sets the value of field 'dictionary'. The field 'dictionary' + * has the following description: symbol class for sequence + * + * + * @param dictionary the value of field 'dictionary'. + */ + public void setDictionary(java.lang.String dictionary) + { + this._dictionary = dictionary; + } //-- void setDictionary(java.lang.String) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return SequenceType + */ + public static org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Sequence) Unmarshaller.unmarshal(org.vamsas.objects.core.Sequence.class, reader); + } //-- org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/SequenceDescriptor.java b/src/org/vamsas/objects/core/SequenceDescriptor.java new file mode 100644 index 0000000..440d8e0 --- /dev/null +++ b/src/org/vamsas/objects/core/SequenceDescriptor.java @@ -0,0 +1,285 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class SequenceDescriptor. + * + * @version $Revision$ $Date$ + */ +public class SequenceDescriptor extends org.vamsas.objects.core.SequenceTypeDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.SequenceTypeDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "Sequence"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Sequence target = (Sequence) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Sequence target = (Sequence) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _dictionary + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_dictionary", "dictionary", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Sequence target = (Sequence) object; + return target.getDictionary(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Sequence target = (Sequence) object; + target.setDictionary( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _dictionary + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _dbRefList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.DbRef.class, "_dbRefList", "dbRef", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Sequence target = (Sequence) object; + return target.getDbRef(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Sequence target = (Sequence) object; + target.addDbRef( (org.vamsas.objects.core.DbRef) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.DbRef(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _dbRefList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.SequenceDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Sequence.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/SequenceType.java b/src/org/vamsas/objects/core/SequenceType.java new file mode 100644 index 0000000..96fba5b --- /dev/null +++ b/src/org/vamsas/objects/core/SequenceType.java @@ -0,0 +1,677 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class SequenceType. + * + * @version $Revision$ $Date$ + */ +public class SequenceType extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _start + */ + private int _start; + + /** + * keeps track of state for field: _start + */ + private boolean _has_start; + + /** + * Field _end + */ + private int _end; + + /** + * keeps track of state for field: _end + */ + private boolean _has_end; + + /** + * Field _sequence + */ + private java.lang.String _sequence; + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * Field _description + */ + private java.lang.String _description; + + /** + * additional typed properties + */ + private java.util.Vector _propertyList; + + /** + * Field _mappingList + */ + private java.util.Vector _mappingList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceType() + { + super(); + _propertyList = new Vector(); + _mappingList = new Vector(); + } //-- org.vamsas.objects.core.SequenceType() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addMapping + * + * + * + * @param vMapping + */ + public void addMapping(org.vamsas.objects.core.Mapping vMapping) + throws java.lang.IndexOutOfBoundsException + { + _mappingList.addElement(vMapping); + } //-- void addMapping(org.vamsas.objects.core.Mapping) + + /** + * Method addMapping + * + * + * + * @param index + * @param vMapping + */ + public void addMapping(int index, org.vamsas.objects.core.Mapping vMapping) + throws java.lang.IndexOutOfBoundsException + { + _mappingList.insertElementAt(vMapping, index); + } //-- void addMapping(int, org.vamsas.objects.core.Mapping) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method deleteEnd + * + */ + public void deleteEnd() + { + this._has_end= false; + } //-- void deleteEnd() + + /** + * Method deleteStart + * + */ + public void deleteStart() + { + this._has_start= false; + } //-- void deleteStart() + + /** + * Method enumerateMapping + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateMapping() + { + return _mappingList.elements(); + } //-- java.util.Enumeration enumerateMapping() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof SequenceType) { + + SequenceType temp = (SequenceType)obj; + if (this._start != temp._start) + return false; + if (this._has_start != temp._has_start) + return false; + if (this._end != temp._end) + return false; + if (this._has_end != temp._has_end) + return false; + if (this._sequence != null) { + if (temp._sequence == null) return false; + else if (!(this._sequence.equals(temp._sequence))) + return false; + } + else if (temp._sequence != null) + return false; + if (this._name != null) { + if (temp._name == null) return false; + else if (!(this._name.equals(temp._name))) + return false; + } + else if (temp._name != null) + return false; + if (this._description != null) { + if (temp._description == null) return false; + else if (!(this._description.equals(temp._description))) + return false; + } + else if (temp._description != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + if (this._mappingList != null) { + if (temp._mappingList == null) return false; + else if (!(this._mappingList.equals(temp._mappingList))) + return false; + } + else if (temp._mappingList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'description'. + * + * @return String + * @return the value of field 'description'. + */ + public java.lang.String getDescription() + { + return this._description; + } //-- java.lang.String getDescription() + + /** + * Returns the value of field 'end'. + * + * @return int + * @return the value of field 'end'. + */ + public int getEnd() + { + return this._end; + } //-- int getEnd() + + /** + * Method getMapping + * + * + * + * @param index + * @return Mapping + */ + public org.vamsas.objects.core.Mapping getMapping(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mappingList.size())) { + throw new IndexOutOfBoundsException("getMapping: Index value '"+index+"' not in range [0.."+_mappingList.size()+ "]"); + } + + return (org.vamsas.objects.core.Mapping) _mappingList.elementAt(index); + } //-- org.vamsas.objects.core.Mapping getMapping(int) + + /** + * Method getMapping + * + * + * + * @return Mapping + */ + public org.vamsas.objects.core.Mapping[] getMapping() + { + int size = _mappingList.size(); + org.vamsas.objects.core.Mapping[] mArray = new org.vamsas.objects.core.Mapping[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Mapping) _mappingList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Mapping[] getMapping() + + /** + * Method getMappingCount + * + * + * + * @return int + */ + public int getMappingCount() + { + return _mappingList.size(); + } //-- int getMappingCount() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'sequence'. + * + * @return String + * @return the value of field 'sequence'. + */ + public java.lang.String getSequence() + { + return this._sequence; + } //-- java.lang.String getSequence() + + /** + * Returns the value of field 'start'. + * + * @return int + * @return the value of field 'start'. + */ + public int getStart() + { + return this._start; + } //-- int getStart() + + /** + * Method hasEnd + * + * + * + * @return boolean + */ + public boolean hasEnd() + { + return this._has_end; + } //-- boolean hasEnd() + + /** + * Method hasStart + * + * + * + * @return boolean + */ + public boolean hasStart() + { + return this._has_start; + } //-- boolean hasStart() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllMapping + * + */ + public void removeAllMapping() + { + _mappingList.removeAllElements(); + } //-- void removeAllMapping() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeMapping + * + * + * + * @param index + * @return Mapping + */ + public org.vamsas.objects.core.Mapping removeMapping(int index) + { + java.lang.Object obj = _mappingList.elementAt(index); + _mappingList.removeElementAt(index); + return (org.vamsas.objects.core.Mapping) obj; + } //-- org.vamsas.objects.core.Mapping removeMapping(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Sets the value of field 'description'. + * + * @param description the value of field 'description'. + */ + public void setDescription(java.lang.String description) + { + this._description = description; + } //-- void setDescription(java.lang.String) + + /** + * Sets the value of field 'end'. + * + * @param end the value of field 'end'. + */ + public void setEnd(int end) + { + this._end = end; + this._has_end = true; + } //-- void setEnd(int) + + /** + * Method setMapping + * + * + * + * @param index + * @param vMapping + */ + public void setMapping(int index, org.vamsas.objects.core.Mapping vMapping) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mappingList.size())) { + throw new IndexOutOfBoundsException("setMapping: Index value '"+index+"' not in range [0.."+_mappingList.size()+ "]"); + } + _mappingList.setElementAt(vMapping, index); + } //-- void setMapping(int, org.vamsas.objects.core.Mapping) + + /** + * Method setMapping + * + * + * + * @param mappingArray + */ + public void setMapping(org.vamsas.objects.core.Mapping[] mappingArray) + { + //-- copy array + _mappingList.removeAllElements(); + for (int i = 0; i < mappingArray.length; i++) { + _mappingList.addElement(mappingArray[i]); + } + } //-- void setMapping(org.vamsas.objects.core.Mapping) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'sequence'. + * + * @param sequence the value of field 'sequence'. + */ + public void setSequence(java.lang.String sequence) + { + this._sequence = sequence; + } //-- void setSequence(java.lang.String) + + /** + * Sets the value of field 'start'. + * + * @param start the value of field 'start'. + */ + public void setStart(int start) + { + this._start = start; + this._has_start = true; + } //-- void setStart(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return SequenceType + */ + public static org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(org.vamsas.objects.core.SequenceType.class, reader); + } //-- org.vamsas.objects.core.SequenceType unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/SequenceTypeDescriptor.java b/src/org/vamsas/objects/core/SequenceTypeDescriptor.java new file mode 100644 index 0000000..0cb00aa --- /dev/null +++ b/src/org/vamsas/objects/core/SequenceTypeDescriptor.java @@ -0,0 +1,446 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class SequenceTypeDescriptor. + * + * @version $Revision$ $Date$ + */ +public class SequenceTypeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceTypeDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "SequenceType"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _start + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_start", "start", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + if(!target.hasStart()) + return null; + return new java.lang.Integer(target.getStart()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setStart( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _start + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _end + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_end", "end", org.exolab.castor.xml.NodeType.Attribute); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + if(!target.hasEnd()) + return null; + return new java.lang.Integer(target.getEnd()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + // ignore null values for non optional primitives + if (value == null) return; + + target.setEnd( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _end + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + IntegerValidator typeValidator = new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _sequence + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_sequence", "sequence", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + return target.getSequence(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + target.setSequence( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _sequence + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _name + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_name", "name", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + return target.getName(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + target.setName( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _name + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _description + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_description", "description", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + return target.getDescription(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + target.setDescription( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _description + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _mappingList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Mapping.class, "_mappingList", "mapping", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + SequenceType target = (SequenceType) object; + return target.getMapping(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + SequenceType target = (SequenceType) object; + target.addMapping( (org.vamsas.objects.core.Mapping) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Mapping(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _mappingList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.SequenceTypeDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.SequenceType.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/Tree.java b/src/org/vamsas/objects/core/Tree.java new file mode 100644 index 0000000..5b9ea99 --- /dev/null +++ b/src/org/vamsas/objects/core/Tree.java @@ -0,0 +1,600 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class Tree. + * + * @version $Revision$ $Date$ + */ +public class Tree extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _modifiable + */ + private java.lang.String _modifiable; + + /** + * Field _title + */ + private java.lang.String _title; + + /** + * Field _newickList + */ + private java.util.Vector _newickList; + + /** + * Field _propertyList + */ + private java.util.Vector _propertyList; + + /** + * Field _provenance + */ + private org.vamsas.objects.core.Provenance _provenance; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public Tree() + { + super(); + _newickList = new Vector(); + _propertyList = new Vector(); + } //-- org.vamsas.objects.core.Tree() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addNewick + * + * + * + * @param vNewick + */ + public void addNewick(org.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException + { + _newickList.addElement(vNewick); + } //-- void addNewick(org.vamsas.objects.core.Newick) + + /** + * Method addNewick + * + * + * + * @param index + * @param vNewick + */ + public void addNewick(int index, org.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException + { + _newickList.insertElementAt(vNewick, index); + } //-- void addNewick(int, org.vamsas.objects.core.Newick) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method enumerateNewick + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateNewick() + { + return _newickList.elements(); + } //-- java.util.Enumeration enumerateNewick() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof Tree) { + + Tree temp = (Tree)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) return false; + else if (!(this._modifiable.equals(temp._modifiable))) + return false; + } + else if (temp._modifiable != null) + return false; + if (this._title != null) { + if (temp._title == null) return false; + else if (!(this._title.equals(temp._title))) + return false; + } + else if (temp._title != null) + return false; + if (this._newickList != null) { + if (temp._newickList == null) return false; + else if (!(this._newickList.equals(temp._newickList))) + return false; + } + else if (temp._newickList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'modifiable'. + * + * @return String + * @return the value of field 'modifiable'. + */ + public java.lang.String getModifiable() + { + return this._modifiable; + } //-- java.lang.String getModifiable() + + /** + * Method getNewick + * + * + * + * @param index + * @return Newick + */ + public org.vamsas.objects.core.Newick getNewick(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _newickList.size())) { + throw new IndexOutOfBoundsException("getNewick: Index value '"+index+"' not in range [0.."+_newickList.size()+ "]"); + } + + return (org.vamsas.objects.core.Newick) _newickList.elementAt(index); + } //-- org.vamsas.objects.core.Newick getNewick(int) + + /** + * Method getNewick + * + * + * + * @return Newick + */ + public org.vamsas.objects.core.Newick[] getNewick() + { + int size = _newickList.size(); + org.vamsas.objects.core.Newick[] mArray = new org.vamsas.objects.core.Newick[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Newick) _newickList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Newick[] getNewick() + + /** + * Method getNewickCount + * + * + * + * @return int + */ + public int getNewickCount() + { + return _newickList.size(); + } //-- int getNewickCount() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public org.vamsas.objects.core.Provenance getProvenance() + { + return this._provenance; + } //-- org.vamsas.objects.core.Provenance getProvenance() + + /** + * Returns the value of field 'title'. + * + * @return String + * @return the value of field 'title'. + */ + public java.lang.String getTitle() + { + return this._title; + } //-- java.lang.String getTitle() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllNewick + * + */ + public void removeAllNewick() + { + _newickList.removeAllElements(); + } //-- void removeAllNewick() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeNewick + * + * + * + * @param index + * @return Newick + */ + public org.vamsas.objects.core.Newick removeNewick(int index) + { + java.lang.Object obj = _newickList.elementAt(index); + _newickList.removeElementAt(index); + return (org.vamsas.objects.core.Newick) obj; + } //-- org.vamsas.objects.core.Newick removeNewick(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable the value of field 'modifiable'. + */ + public void setModifiable(java.lang.String modifiable) + { + this._modifiable = modifiable; + } //-- void setModifiable(java.lang.String) + + /** + * Method setNewick + * + * + * + * @param index + * @param vNewick + */ + public void setNewick(int index, org.vamsas.objects.core.Newick vNewick) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _newickList.size())) { + throw new IndexOutOfBoundsException("setNewick: Index value '"+index+"' not in range [0.."+_newickList.size()+ "]"); + } + _newickList.setElementAt(vNewick, index); + } //-- void setNewick(int, org.vamsas.objects.core.Newick) + + /** + * Method setNewick + * + * + * + * @param newickArray + */ + public void setNewick(org.vamsas.objects.core.Newick[] newickArray) + { + //-- copy array + _newickList.removeAllElements(); + for (int i = 0; i < newickArray.length; i++) { + _newickList.addElement(newickArray[i]); + } + } //-- void setNewick(org.vamsas.objects.core.Newick) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(org.vamsas.objects.core.Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(org.vamsas.objects.core.Provenance) + + /** + * Sets the value of field 'title'. + * + * @param title the value of field 'title'. + */ + public void setTitle(java.lang.String title) + { + this._title = title; + } //-- void setTitle(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Tree + */ + public static org.vamsas.objects.core.Tree unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.Tree) Unmarshaller.unmarshal(org.vamsas.objects.core.Tree.class, reader); + } //-- org.vamsas.objects.core.Tree unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/TreeDescriptor.java b/src/org/vamsas/objects/core/TreeDescriptor.java new file mode 100644 index 0000000..1ca69de --- /dev/null +++ b/src/org/vamsas/objects/core/TreeDescriptor.java @@ -0,0 +1,390 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class TreeDescriptor. + * + * @version $Revision$ $Date$ + */ +public class TreeDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public TreeDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "Tree"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getModifiable(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.setModifiable( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _title + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_title", "title", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getTitle(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.setTitle( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _title + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _newickList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Newick.class, "_newickList", "newick", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getNewick(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.addNewick( (org.vamsas.objects.core.Newick) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Newick(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _newickList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _propertyList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Property.class, "_propertyList", "property", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getProperty(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.addProperty( (org.vamsas.objects.core.Property) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Property(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _propertyList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Tree target = (Tree) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Tree target = (Tree) object; + target.setProvenance( (org.vamsas.objects.core.Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.TreeDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.Tree.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/User.java b/src/org/vamsas/objects/core/User.java new file mode 100644 index 0000000..6efdd05 --- /dev/null +++ b/src/org/vamsas/objects/core/User.java @@ -0,0 +1,212 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class User. + * + * @version $Revision$ $Date$ + */ +public class User extends org.vamsas.objects.core.AppData +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _fullname + */ + private java.lang.String _fullname; + + /** + * Field _organization + */ + private java.lang.String _organization; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public User() + { + super(); + } //-- org.vamsas.objects.core.User() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof User) { + + User temp = (User)obj; + if (this._fullname != null) { + if (temp._fullname == null) return false; + else if (!(this._fullname.equals(temp._fullname))) + return false; + } + else if (temp._fullname != null) + return false; + if (this._organization != null) { + if (temp._organization == null) return false; + else if (!(this._organization.equals(temp._organization))) + return false; + } + else if (temp._organization != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Returns the value of field 'fullname'. + * + * @return String + * @return the value of field 'fullname'. + */ + public java.lang.String getFullname() + { + return this._fullname; + } //-- java.lang.String getFullname() + + /** + * Returns the value of field 'organization'. + * + * @return String + * @return the value of field 'organization'. + */ + public java.lang.String getOrganization() + { + return this._organization; + } //-- java.lang.String getOrganization() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'fullname'. + * + * @param fullname the value of field 'fullname'. + */ + public void setFullname(java.lang.String fullname) + { + this._fullname = fullname; + } //-- void setFullname(java.lang.String) + + /** + * Sets the value of field 'organization'. + * + * @param organization the value of field 'organization'. + */ + public void setOrganization(java.lang.String organization) + { + this._organization = organization; + } //-- void setOrganization(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return AppData + */ + public static org.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.User) Unmarshaller.unmarshal(org.vamsas.objects.core.User.class, reader); + } //-- org.vamsas.objects.core.AppData unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/UserDescriptor.java b/src/org/vamsas/objects/core/UserDescriptor.java new file mode 100644 index 0000000..a90dbb1 --- /dev/null +++ b/src/org/vamsas/objects/core/UserDescriptor.java @@ -0,0 +1,252 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class UserDescriptor. + * + * @version $Revision$ $Date$ + */ +public class UserDescriptor extends org.vamsas.objects.core.AppDataDescriptor { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public UserDescriptor() + { + super(); + setExtendsWithoutFlatten(new org.vamsas.objects.core.AppDataDescriptor()); + nsURI = "http://www.vamsas.org"; + xmlName = "User"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _fullname + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_fullname", "fullname", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + User target = (User) object; + return target.getFullname(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + User target = (User) object; + target.setFullname( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _fullname + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _organization + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_organization", "organization", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + User target = (User) object; + return target.getOrganization(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + User target = (User) object; + target.setOrganization( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _organization + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- org.vamsas.objects.core.UserDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return super.getExtends(); + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + if (identity == null) + return super.getIdentity(); + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.User.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/VAMSAS.java b/src/org/vamsas/objects/core/VAMSAS.java new file mode 100644 index 0000000..c359593 --- /dev/null +++ b/src/org/vamsas/objects/core/VAMSAS.java @@ -0,0 +1,535 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * contains unassociated trees and a number of analysis sets + * + * + * @version $Revision$ $Date$ + */ +public class VAMSAS extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Primary Key for vamsas object referencing + */ + private java.lang.String _id; + + /** + * Field _modifiable + */ + private java.lang.String _modifiable; + + /** + * Field _treeList + */ + private java.util.Vector _treeList; + + /** + * Field _dataSetList + */ + private java.util.Vector _dataSetList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public VAMSAS() + { + super(); + _treeList = new Vector(); + _dataSetList = new Vector(); + } //-- org.vamsas.objects.core.VAMSAS() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addDataSet + * + * + * + * @param vDataSet + */ + public void addDataSet(org.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException + { + _dataSetList.addElement(vDataSet); + } //-- void addDataSet(org.vamsas.objects.core.DataSet) + + /** + * Method addDataSet + * + * + * + * @param index + * @param vDataSet + */ + public void addDataSet(int index, org.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException + { + _dataSetList.insertElementAt(vDataSet, index); + } //-- void addDataSet(int, org.vamsas.objects.core.DataSet) + + /** + * Method addTree + * + * + * + * @param vTree + */ + public void addTree(org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.addElement(vTree); + } //-- void addTree(org.vamsas.objects.core.Tree) + + /** + * Method addTree + * + * + * + * @param index + * @param vTree + */ + public void addTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.insertElementAt(vTree, index); + } //-- void addTree(int, org.vamsas.objects.core.Tree) + + /** + * Method enumerateDataSet + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateDataSet() + { + return _dataSetList.elements(); + } //-- java.util.Enumeration enumerateDataSet() + + /** + * Method enumerateTree + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateTree() + { + return _treeList.elements(); + } //-- java.util.Enumeration enumerateTree() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof VAMSAS) { + + VAMSAS temp = (VAMSAS)obj; + if (this._id != null) { + if (temp._id == null) return false; + else if (!(this._id.equals(temp._id))) + return false; + } + else if (temp._id != null) + return false; + if (this._modifiable != null) { + if (temp._modifiable == null) return false; + else if (!(this._modifiable.equals(temp._modifiable))) + return false; + } + else if (temp._modifiable != null) + return false; + if (this._treeList != null) { + if (temp._treeList == null) return false; + else if (!(this._treeList.equals(temp._treeList))) + return false; + } + else if (temp._treeList != null) + return false; + if (this._dataSetList != null) { + if (temp._dataSetList == null) return false; + else if (!(this._dataSetList.equals(temp._dataSetList))) + return false; + } + else if (temp._dataSetList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getDataSet + * + * + * + * @param index + * @return DataSet + */ + public org.vamsas.objects.core.DataSet getDataSet(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dataSetList.size())) { + throw new IndexOutOfBoundsException("getDataSet: Index value '"+index+"' not in range [0.."+_dataSetList.size()+ "]"); + } + + return (org.vamsas.objects.core.DataSet) _dataSetList.elementAt(index); + } //-- org.vamsas.objects.core.DataSet getDataSet(int) + + /** + * Method getDataSet + * + * + * + * @return DataSet + */ + public org.vamsas.objects.core.DataSet[] getDataSet() + { + int size = _dataSetList.size(); + org.vamsas.objects.core.DataSet[] mArray = new org.vamsas.objects.core.DataSet[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.DataSet) _dataSetList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.DataSet[] getDataSet() + + /** + * Method getDataSetCount + * + * + * + * @return int + */ + public int getDataSetCount() + { + return _dataSetList.size(); + } //-- int getDataSetCount() + + /** + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'modifiable'. + * + * @return String + * @return the value of field 'modifiable'. + */ + public java.lang.String getModifiable() + { + return this._modifiable; + } //-- java.lang.String getModifiable() + + /** + * Method getTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree getTree(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("getTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + + return (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } //-- org.vamsas.objects.core.Tree getTree(int) + + /** + * Method getTree + * + * + * + * @return Tree + */ + public org.vamsas.objects.core.Tree[] getTree() + { + int size = _treeList.size(); + org.vamsas.objects.core.Tree[] mArray = new org.vamsas.objects.core.Tree[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Tree) _treeList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Tree[] getTree() + + /** + * Method getTreeCount + * + * + * + * @return int + */ + public int getTreeCount() + { + return _treeList.size(); + } //-- int getTreeCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllDataSet + * + */ + public void removeAllDataSet() + { + _dataSetList.removeAllElements(); + } //-- void removeAllDataSet() + + /** + * Method removeAllTree + * + */ + public void removeAllTree() + { + _treeList.removeAllElements(); + } //-- void removeAllTree() + + /** + * Method removeDataSet + * + * + * + * @param index + * @return DataSet + */ + public org.vamsas.objects.core.DataSet removeDataSet(int index) + { + java.lang.Object obj = _dataSetList.elementAt(index); + _dataSetList.removeElementAt(index); + return (org.vamsas.objects.core.DataSet) obj; + } //-- org.vamsas.objects.core.DataSet removeDataSet(int) + + /** + * Method removeTree + * + * + * + * @param index + * @return Tree + */ + public org.vamsas.objects.core.Tree removeTree(int index) + { + java.lang.Object obj = _treeList.elementAt(index); + _treeList.removeElementAt(index); + return (org.vamsas.objects.core.Tree) obj; + } //-- org.vamsas.objects.core.Tree removeTree(int) + + /** + * Method setDataSet + * + * + * + * @param index + * @param vDataSet + */ + public void setDataSet(int index, org.vamsas.objects.core.DataSet vDataSet) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _dataSetList.size())) { + throw new IndexOutOfBoundsException("setDataSet: Index value '"+index+"' not in range [0.."+_dataSetList.size()+ "]"); + } + _dataSetList.setElementAt(vDataSet, index); + } //-- void setDataSet(int, org.vamsas.objects.core.DataSet) + + /** + * Method setDataSet + * + * + * + * @param dataSetArray + */ + public void setDataSet(org.vamsas.objects.core.DataSet[] dataSetArray) + { + //-- copy array + _dataSetList.removeAllElements(); + for (int i = 0; i < dataSetArray.length; i++) { + _dataSetList.addElement(dataSetArray[i]); + } + } //-- void setDataSet(org.vamsas.objects.core.DataSet) + + /** + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for vamsas object + * referencing + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'modifiable'. + * + * @param modifiable the value of field 'modifiable'. + */ + public void setModifiable(java.lang.String modifiable) + { + this._modifiable = modifiable; + } //-- void setModifiable(java.lang.String) + + /** + * Method setTree + * + * + * + * @param index + * @param vTree + */ + public void setTree(int index, org.vamsas.objects.core.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _treeList.size())) { + throw new IndexOutOfBoundsException("setTree: Index value '"+index+"' not in range [0.."+_treeList.size()+ "]"); + } + _treeList.setElementAt(vTree, index); + } //-- void setTree(int, org.vamsas.objects.core.Tree) + + /** + * Method setTree + * + * + * + * @param treeArray + */ + public void setTree(org.vamsas.objects.core.Tree[] treeArray) + { + //-- copy array + _treeList.removeAllElements(); + for (int i = 0; i < treeArray.length; i++) { + _treeList.addElement(treeArray[i]); + } + } //-- void setTree(org.vamsas.objects.core.Tree) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return VAMSAS + */ + public static org.vamsas.objects.core.VAMSAS unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.VAMSAS) Unmarshaller.unmarshal(org.vamsas.objects.core.VAMSAS.class, reader); + } //-- org.vamsas.objects.core.VAMSAS unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/VAMSASDescriptor.java b/src/org/vamsas/objects/core/VAMSASDescriptor.java new file mode 100644 index 0000000..9eb4e29 --- /dev/null +++ b/src/org/vamsas/objects/core/VAMSASDescriptor.java @@ -0,0 +1,315 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class VAMSASDescriptor. + * + * @version $Revision$ $Date$ + */ +public class VAMSASDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public VAMSASDescriptor() + { + super(); + nsURI = "http://www.vamsas.org"; + xmlName = "VAMSAS"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- _id + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_id", "id", org.exolab.castor.xml.NodeType.Attribute); + this.identity = desc; + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VAMSAS target = (VAMSAS) object; + return target.getId(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VAMSAS target = (VAMSAS) object; + target.setId( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new java.lang.String(); + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _id + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _modifiable + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_modifiable", "modifiable", org.exolab.castor.xml.NodeType.Attribute); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VAMSAS target = (VAMSAS) object; + return target.getModifiable(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VAMSAS target = (VAMSAS) object; + target.setModifiable( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _modifiable + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + //-- _treeList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.Tree.class, "_treeList", "Tree", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VAMSAS target = (VAMSAS) object; + return target.getTree(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VAMSAS target = (VAMSAS) object; + target.addTree( (org.vamsas.objects.core.Tree) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.Tree(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _treeList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _dataSetList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.DataSet.class, "_dataSetList", "DataSet", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VAMSAS target = (VAMSAS) object; + return target.getDataSet(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VAMSAS target = (VAMSAS) object; + target.addDataSet( (org.vamsas.objects.core.DataSet) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.DataSet(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _dataSetList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.VAMSASDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.VAMSAS.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/core/VamsasDocument.java b/src/org/vamsas/objects/core/VamsasDocument.java new file mode 100644 index 0000000..f8df822 --- /dev/null +++ b/src/org/vamsas/objects/core/VamsasDocument.java @@ -0,0 +1,725 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; +import java.util.Enumeration; +import java.util.Vector; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +/** + * Class VamsasDocument. + * + * @version $Revision$ $Date$ + */ +public class VamsasDocument extends org.vamsas.client.Vobject +implements java.io.Serializable +{ + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Vamsas Document Version Number + */ + private java.lang.String _version; + + /** + * Field _lockFile + */ + private org.vamsas.objects.core.LockFile _lockFile; + + /** + * Field _provenance + */ + private Provenance _provenance; + + /** + * contains unassociated trees and a number of analysis sets + * + */ + private java.util.Vector _VAMSASList; + + /** + * Field _applicationDataList + */ + private java.util.Vector _applicationDataList; + + /** + * Field _attachmentList + */ + private java.util.Vector _attachmentList; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public VamsasDocument() + { + super(); + _VAMSASList = new Vector(); + _applicationDataList = new Vector(); + _attachmentList = new Vector(); + } //-- org.vamsas.objects.core.VamsasDocument() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addApplicationData + * + * + * + * @param vApplicationData + */ + public void addApplicationData(ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException + { + _applicationDataList.addElement(vApplicationData); + } //-- void addApplicationData(ApplicationData) + + /** + * Method addApplicationData + * + * + * + * @param index + * @param vApplicationData + */ + public void addApplicationData(int index, ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException + { + _applicationDataList.insertElementAt(vApplicationData, index); + } //-- void addApplicationData(int, ApplicationData) + + /** + * Method addAttachment + * + * + * + * @param vAttachment + */ + public void addAttachment(Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException + { + _attachmentList.addElement(vAttachment); + } //-- void addAttachment(Attachment) + + /** + * Method addAttachment + * + * + * + * @param index + * @param vAttachment + */ + public void addAttachment(int index, Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException + { + _attachmentList.insertElementAt(vAttachment, index); + } //-- void addAttachment(int, Attachment) + + /** + * Method addVAMSAS + * + * + * + * @param vVAMSAS + */ + public void addVAMSAS(VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException + { + _VAMSASList.addElement(vVAMSAS); + } //-- void addVAMSAS(VAMSAS) + + /** + * Method addVAMSAS + * + * + * + * @param index + * @param vVAMSAS + */ + public void addVAMSAS(int index, VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException + { + _VAMSASList.insertElementAt(vVAMSAS, index); + } //-- void addVAMSAS(int, VAMSAS) + + /** + * Method enumerateApplicationData + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateApplicationData() + { + return _applicationDataList.elements(); + } //-- java.util.Enumeration enumerateApplicationData() + + /** + * Method enumerateAttachment + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAttachment() + { + return _attachmentList.elements(); + } //-- java.util.Enumeration enumerateAttachment() + + /** + * Method enumerateVAMSAS + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateVAMSAS() + { + return _VAMSASList.elements(); + } //-- java.util.Enumeration enumerateVAMSAS() + + /** + * Note: hashCode() has not been overriden + * + * @param obj + * @return boolean + */ + public boolean equals(java.lang.Object obj) + { + if ( this == obj ) + return true; + + if (super.equals(obj)==false) + return false; + + if (obj instanceof VamsasDocument) { + + VamsasDocument temp = (VamsasDocument)obj; + if (this._version != null) { + if (temp._version == null) return false; + else if (!(this._version.equals(temp._version))) + return false; + } + else if (temp._version != null) + return false; + if (this._lockFile != null) { + if (temp._lockFile == null) return false; + else if (!(this._lockFile.equals(temp._lockFile))) + return false; + } + else if (temp._lockFile != null) + return false; + if (this._provenance != null) { + if (temp._provenance == null) return false; + else if (!(this._provenance.equals(temp._provenance))) + return false; + } + else if (temp._provenance != null) + return false; + if (this._VAMSASList != null) { + if (temp._VAMSASList == null) return false; + else if (!(this._VAMSASList.equals(temp._VAMSASList))) + return false; + } + else if (temp._VAMSASList != null) + return false; + if (this._applicationDataList != null) { + if (temp._applicationDataList == null) return false; + else if (!(this._applicationDataList.equals(temp._applicationDataList))) + return false; + } + else if (temp._applicationDataList != null) + return false; + if (this._attachmentList != null) { + if (temp._attachmentList == null) return false; + else if (!(this._attachmentList.equals(temp._attachmentList))) + return false; + } + else if (temp._attachmentList != null) + return false; + return true; + } + return false; + } //-- boolean equals(java.lang.Object) + + /** + * Method getApplicationData + * + * + * + * @param index + * @return ApplicationData + */ + public ApplicationData getApplicationData(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _applicationDataList.size())) { + throw new IndexOutOfBoundsException("getApplicationData: Index value '"+index+"' not in range [0.."+_applicationDataList.size()+ "]"); + } + + return (ApplicationData) _applicationDataList.elementAt(index); + } //-- ApplicationData getApplicationData(int) + + /** + * Method getApplicationData + * + * + * + * @return ApplicationData + */ + public ApplicationData[] getApplicationData() + { + int size = _applicationDataList.size(); + ApplicationData[] mArray = new ApplicationData[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (ApplicationData) _applicationDataList.elementAt(index); + } + return mArray; + } //-- ApplicationData[] getApplicationData() + + /** + * Method getApplicationDataCount + * + * + * + * @return int + */ + public int getApplicationDataCount() + { + return _applicationDataList.size(); + } //-- int getApplicationDataCount() + + /** + * Method getAttachment + * + * + * + * @param index + * @return Attachment + */ + public Attachment getAttachment(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _attachmentList.size())) { + throw new IndexOutOfBoundsException("getAttachment: Index value '"+index+"' not in range [0.."+_attachmentList.size()+ "]"); + } + + return (Attachment) _attachmentList.elementAt(index); + } //-- Attachment getAttachment(int) + + /** + * Method getAttachment + * + * + * + * @return Attachment + */ + public Attachment[] getAttachment() + { + int size = _attachmentList.size(); + Attachment[] mArray = new Attachment[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (Attachment) _attachmentList.elementAt(index); + } + return mArray; + } //-- Attachment[] getAttachment() + + /** + * Method getAttachmentCount + * + * + * + * @return int + */ + public int getAttachmentCount() + { + return _attachmentList.size(); + } //-- int getAttachmentCount() + + /** + * Returns the value of field 'lockFile'. + * + * @return LockFile + * @return the value of field 'lockFile'. + */ + public org.vamsas.objects.core.LockFile getLockFile() + { + return this._lockFile; + } //-- org.vamsas.objects.core.LockFile getLockFile() + + /** + * Returns the value of field 'provenance'. + * + * @return Provenance + * @return the value of field 'provenance'. + */ + public Provenance getProvenance() + { + return this._provenance; + } //-- Provenance getProvenance() + + /** + * Method getVAMSAS + * + * + * + * @param index + * @return VAMSAS + */ + public VAMSAS getVAMSAS(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _VAMSASList.size())) { + throw new IndexOutOfBoundsException("getVAMSAS: Index value '"+index+"' not in range [0.."+_VAMSASList.size()+ "]"); + } + + return (VAMSAS) _VAMSASList.elementAt(index); + } //-- VAMSAS getVAMSAS(int) + + /** + * Method getVAMSAS + * + * + * + * @return VAMSAS + */ + public VAMSAS[] getVAMSAS() + { + int size = _VAMSASList.size(); + VAMSAS[] mArray = new VAMSAS[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (VAMSAS) _VAMSASList.elementAt(index); + } + return mArray; + } //-- VAMSAS[] getVAMSAS() + + /** + * Method getVAMSASCount + * + * + * + * @return int + */ + public int getVAMSASCount() + { + return _VAMSASList.size(); + } //-- int getVAMSASCount() + + /** + * Returns the value of field 'version'. The field 'version' + * has the following description: Vamsas Document Version + * Number + * + * @return String + * @return the value of field 'version'. + */ + public java.lang.String getVersion() + { + return this._version; + } //-- java.lang.String getVersion() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllApplicationData + * + */ + public void removeAllApplicationData() + { + _applicationDataList.removeAllElements(); + } //-- void removeAllApplicationData() + + /** + * Method removeAllAttachment + * + */ + public void removeAllAttachment() + { + _attachmentList.removeAllElements(); + } //-- void removeAllAttachment() + + /** + * Method removeAllVAMSAS + * + */ + public void removeAllVAMSAS() + { + _VAMSASList.removeAllElements(); + } //-- void removeAllVAMSAS() + + /** + * Method removeApplicationData + * + * + * + * @param index + * @return ApplicationData + */ + public ApplicationData removeApplicationData(int index) + { + java.lang.Object obj = _applicationDataList.elementAt(index); + _applicationDataList.removeElementAt(index); + return (ApplicationData) obj; + } //-- ApplicationData removeApplicationData(int) + + /** + * Method removeAttachment + * + * + * + * @param index + * @return Attachment + */ + public Attachment removeAttachment(int index) + { + java.lang.Object obj = _attachmentList.elementAt(index); + _attachmentList.removeElementAt(index); + return (Attachment) obj; + } //-- Attachment removeAttachment(int) + + /** + * Method removeVAMSAS + * + * + * + * @param index + * @return VAMSAS + */ + public VAMSAS removeVAMSAS(int index) + { + java.lang.Object obj = _VAMSASList.elementAt(index); + _VAMSASList.removeElementAt(index); + return (VAMSAS) obj; + } //-- VAMSAS removeVAMSAS(int) + + /** + * Method setApplicationData + * + * + * + * @param index + * @param vApplicationData + */ + public void setApplicationData(int index, ApplicationData vApplicationData) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _applicationDataList.size())) { + throw new IndexOutOfBoundsException("setApplicationData: Index value '"+index+"' not in range [0.."+_applicationDataList.size()+ "]"); + } + _applicationDataList.setElementAt(vApplicationData, index); + } //-- void setApplicationData(int, ApplicationData) + + /** + * Method setApplicationData + * + * + * + * @param applicationDataArray + */ + public void setApplicationData(ApplicationData[] applicationDataArray) + { + //-- copy array + _applicationDataList.removeAllElements(); + for (int i = 0; i < applicationDataArray.length; i++) { + _applicationDataList.addElement(applicationDataArray[i]); + } + } //-- void setApplicationData(ApplicationData) + + /** + * Method setAttachment + * + * + * + * @param index + * @param vAttachment + */ + public void setAttachment(int index, Attachment vAttachment) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _attachmentList.size())) { + throw new IndexOutOfBoundsException("setAttachment: Index value '"+index+"' not in range [0.."+_attachmentList.size()+ "]"); + } + _attachmentList.setElementAt(vAttachment, index); + } //-- void setAttachment(int, Attachment) + + /** + * Method setAttachment + * + * + * + * @param attachmentArray + */ + public void setAttachment(Attachment[] attachmentArray) + { + //-- copy array + _attachmentList.removeAllElements(); + for (int i = 0; i < attachmentArray.length; i++) { + _attachmentList.addElement(attachmentArray[i]); + } + } //-- void setAttachment(Attachment) + + /** + * Sets the value of field 'lockFile'. + * + * @param lockFile the value of field 'lockFile'. + */ + public void setLockFile(org.vamsas.objects.core.LockFile lockFile) + { + this._lockFile = lockFile; + } //-- void setLockFile(org.vamsas.objects.core.LockFile) + + /** + * Sets the value of field 'provenance'. + * + * @param provenance the value of field 'provenance'. + */ + public void setProvenance(Provenance provenance) + { + this._provenance = provenance; + } //-- void setProvenance(Provenance) + + /** + * Method setVAMSAS + * + * + * + * @param index + * @param vVAMSAS + */ + public void setVAMSAS(int index, VAMSAS vVAMSAS) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _VAMSASList.size())) { + throw new IndexOutOfBoundsException("setVAMSAS: Index value '"+index+"' not in range [0.."+_VAMSASList.size()+ "]"); + } + _VAMSASList.setElementAt(vVAMSAS, index); + } //-- void setVAMSAS(int, VAMSAS) + + /** + * Method setVAMSAS + * + * + * + * @param VAMSASArray + */ + public void setVAMSAS(VAMSAS[] VAMSASArray) + { + //-- copy array + _VAMSASList.removeAllElements(); + for (int i = 0; i < VAMSASArray.length; i++) { + _VAMSASList.addElement(VAMSASArray[i]); + } + } //-- void setVAMSAS(VAMSAS) + + /** + * Sets the value of field 'version'. The field 'version' has + * the following description: Vamsas Document Version Number + * + * @param version the value of field 'version'. + */ + public void setVersion(java.lang.String version) + { + this._version = version; + } //-- void setVersion(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return VamsasDocument + */ + public static org.vamsas.objects.core.VamsasDocument unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (org.vamsas.objects.core.VamsasDocument) Unmarshaller.unmarshal(org.vamsas.objects.core.VamsasDocument.class, reader); + } //-- org.vamsas.objects.core.VamsasDocument unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/org/vamsas/objects/core/VamsasDocumentDescriptor.java b/src/org/vamsas/objects/core/VamsasDocumentDescriptor.java new file mode 100644 index 0000000..425e16a --- /dev/null +++ b/src/org/vamsas/objects/core/VamsasDocumentDescriptor.java @@ -0,0 +1,388 @@ +/* + * This class was automatically generated with + * Castor 0.9.9M2, using an XML + * Schema. + * $Id$ + */ + +package org.vamsas.objects.core; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class VamsasDocumentDescriptor. + * + * @version $Revision$ $Date$ + */ +public class VamsasDocumentDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public VamsasDocumentDescriptor() + { + super(); + nsURI = "http://www.vamsas.ac.uk/vamsasDocument"; + xmlName = "VamsasDocument"; + + //-- set grouping compositor + setCompositorAsSequence(); + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.mapping.FieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- initialize attribute descriptors + + //-- initialize element descriptors + + //-- _version + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_version", "Version", org.exolab.castor.xml.NodeType.Element); + desc.setImmutable(true); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getVersion(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.setVersion( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/vamsasDocument"); + desc.setRequired(true); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _version + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _lockFile + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(org.vamsas.objects.core.LockFile.class, "_lockFile", "LockFile", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getLockFile(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.setLockFile( (org.vamsas.objects.core.LockFile) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new org.vamsas.objects.core.LockFile(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.ac.uk/vamsasDocument"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _lockFile + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _provenance + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(Provenance.class, "_provenance", "Provenance", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getProvenance(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.setProvenance( (Provenance) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new Provenance(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(false); + addFieldDescriptor(desc); + + //-- validation code for: _provenance + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _VAMSASList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(VAMSAS.class, "_VAMSASList", "VAMSAS", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getVAMSAS(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.addVAMSAS( (VAMSAS) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new VAMSAS(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setRequired(true); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _VAMSASList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(1); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _applicationDataList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(ApplicationData.class, "_applicationDataList", "ApplicationData", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getApplicationData(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.addApplicationData( (ApplicationData) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new ApplicationData(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _applicationDataList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + //-- _attachmentList + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(Attachment.class, "_attachmentList", "Attachment", org.exolab.castor.xml.NodeType.Element); + handler = new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + VamsasDocument target = (VamsasDocument) object; + return target.getAttachment(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + VamsasDocument target = (VamsasDocument) object; + target.addAttachment( (Attachment) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return new Attachment(); + } + }; + desc.setHandler(handler); + desc.setNameSpaceURI("http://www.vamsas.org"); + desc.setMultivalued(true); + addFieldDescriptor(desc); + + //-- validation code for: _attachmentList + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + fieldValidator.setMinOccurs(0); + { //-- local scope + } + desc.setValidator(fieldValidator); + } //-- org.vamsas.objects.core.VamsasDocumentDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return org.vamsas.objects.core.VamsasDocument.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} diff --git a/src/org/vamsas/objects/utils/AppDataReference.java b/src/org/vamsas/objects/utils/AppDataReference.java new file mode 100644 index 0000000..414c8da --- /dev/null +++ b/src/org/vamsas/objects/utils/AppDataReference.java @@ -0,0 +1,160 @@ +/** + * + */ +package org.vamsas.objects.utils; +import java.util.Vector; + +import org.vamsas.client.ClientHandle; +import org.vamsas.client.UserHandle; +import org.vamsas.client.simpleclient.VamsasArchive; +import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.objects.core.*; +/** + * Form, accessors and validation for ApplicationData references in + * vamsas document. + * TODO: LATER:extend XML Schema to properly validate against the same forms required by this class + * TODO: VAMSAS: URNS for appDatas are supposed to be unique, aren't they ? + */ +public class AppDataReference { + /** + * search interface for collecting particular types of AppDatas in a vamsas document + * @author jimp + * + */ + interface IAppDSearch { + /** + * process the appData Vobject d + * @param d + * @return true if appData should be collected + */ + public boolean process(AppData d); + } + /** + * collect all appData reference strings in a vamsas document + * @param doc + * @return vector of String objects + */ + static public Vector getAppDataReferences(VamsasDocument doc) { + if ((doc!=null) && (doc.getApplicationDataCount()>0)) { + Vector apdrefs = new Vector(); + ApplicationData[] appdatas = doc.getApplicationData(); + for (int q=0; q0) + return apdrefs; + } + return null; + } + /** + * General search through the set of AppData objects for a particular profile of Client and User handle. + * @param doc + * @param test interface implemented by the filter selecting particular AppDatas. + * @param cascade if true only User objects for ApplicationData objects that test.process returned true will be tested. + * @return set of org.vamsas.objects.core.AppData objects for which test.process returned true + */ + static public Vector searchAppDatas(VamsasDocument doc, IAppDSearch test, boolean cascade) { + if ((doc!=null) && (doc.getApplicationDataCount()>0)) { + Vector apdrefs = new Vector(); + ApplicationData[] appdatas = doc.getApplicationData(); + for (int q=0; q0) + return apdrefs; + } + return null; + } + static public boolean equals(User p, UserHandle u) { + if (p.getFullname().equals(u.getFullName()) + && p.getOrganization().equals(u.getOrganization())) + return true; + return false; + } + /** + * returns true if Name matches in c and p, and Urn's match (or c.getUrn()==null) and Version's match (or c.getVersion()==null) + * @param p + * @param c + * @return match of p on template c. + */ + static public boolean equals(ApplicationData p, ClientHandle c) { + if ( + //((c.getClientUrn()==null) || p.getUrn().equals(c.getClientUrn())) + //&& + (p.getName().equals(c.getClientName())) + && + ((c.getVersion()==null) || (p.getVersion().equals(c.getVersion()))) + ) + return true; + return false; + } + /** + * Searches document appData structure for particular combinations of client and user data + * @param doc the data + * @param user template user data to match against + * @see AppDataReference.equals(org.vamsas.objects.core.User, org.vamsas.client.UserHandle) + * @param app + * @see AppDataReference.equals(org.vamsas.objects.core.ApplicationData, org.vamsas.client.ClientHandle) + * @return set of matching client app datas for this client and user combination + */ + static public Vector getUserandApplicationsData(VamsasDocument doc, UserHandle user, ClientHandle app) { + if (doc==null) { + return null; + } + final UserHandle u = user; + final ClientHandle c = app; + + IAppDSearch match = new IAppDSearch() { + public boolean process(AppData p) { + if (p instanceof User) { + if (AppDataReference.equals((User) p, u)) + return true; + } else + if (p instanceof ApplicationData) { + if (AppDataReference.equals((ApplicationData) p, c)) + return true; + } + return false; + } + }; + + return searchAppDatas(doc, match, true); // only return AppDatas belonging to appdata app. + } + /** + * safely creates a new appData reference + * @param dest destination document Vobject + * @param entry base application reference to make unique + */ + public static String uniqueAppDataReference(VamsasDocument dest,String base) { + String urn = new String(base); + + for (int i=0, j=dest.getApplicationDataCount(); i + *
  • a % (required) + *
  • a modifier (optional) + *
    + *
    +
    forces display of + for positive numbers + *
    0
    show leading zeroes + *
    -
    align left in the field + *
    space
    prepend a space in front of positive numbers + *
    #
    use "alternate" format. Add 0 or 0x for octal or hexadecimal numbers. Don't suppress trailing zeroes in general floating point format. + *
    + *
  • an integer denoting field width (optional) + *
  • a period followed by an integer denoting precision (optional) + *
  • a format descriptor (required) + *
    + *
    f
    floating point number in fixed format + *
    e, E
    floating point number in exponential notation (scientific format). The E format results in an uppercase E for the exponent (1.14130E+003), the e format in a lowercase e. + *
    g, G
    floating point number in general format (fixed format for small numbers, exponential format for large numbers). Trailing zeroes are suppressed. The G format results in an uppercase E for the exponent (if any), the g format in a lowercase e. + *
    d, i
    integer in decimal + *
    x
    integer in hexadecimal + *
    o
    integer in octal + *
    s
    string + *
    c
    character + *
    + * + * @exception IllegalArgumentException if bad format + */ + + public Format(String s) { + width = 0; + precision = -1; + pre = ""; + post = ""; + leading_zeroes = false; + show_plus = false; + alternate = false; + show_space = false; + left_align = false; + fmt = ' '; + + int state = 0; + int length = s.length(); + int parse_state = 0; + // 0 = prefix, 1 = flags, 2 = width, 3 = precision, + // 4 = format, 5 = end + int i = 0; + + while (parse_state == 0) { + if (i >= length) + parse_state = 5; + else if (s.charAt(i) == '%') { + if (i < length - 1) { + if (s.charAt(i + 1) == '%') { + pre = pre + '%'; + i++; + } else + parse_state = 1; + } else + throw new java.lang.IllegalArgumentException(); + } else + pre = pre + s.charAt(i); + i++; + } + while (parse_state == 1) { + if (i >= length) + parse_state = 5; + else if (s.charAt(i) == ' ') + show_space = true; + else if (s.charAt(i) == '-') + left_align = true; + else if (s.charAt(i) == '+') + show_plus = true; + else if (s.charAt(i) == '0') + leading_zeroes = true; + else if (s.charAt(i) == '#') + alternate = true; + else { + parse_state = 2; + i--; + } + i++; + } + while (parse_state == 2) { + if (i >= length) + parse_state = 5; + else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { + width = width * 10 + s.charAt(i) - '0'; + i++; + } else if (s.charAt(i) == '.') { + parse_state = 3; + precision = 0; + i++; + } else + parse_state = 4; + } + while (parse_state == 3) { + if (i >= length) + parse_state = 5; + else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { + precision = precision * 10 + s.charAt(i) - '0'; + i++; + } else + parse_state = 4; + } + if (parse_state == 4) { + if (i >= length) + parse_state = 5; + else + fmt = s.charAt(i); + i++; + } + if (i < length) + post = s.substring(i, length); + } + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the double to print + */ + + public static void print(java.io.PrintStream s, String fmt, double x) { + s.print(new Format(fmt).form(x)); + } + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the long to print + */ + public static void print(java.io.PrintStream s, String fmt, long x) { + s.print(new Format(fmt).form(x)); + } + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the character to + */ + + public static void print(java.io.PrintStream s, String fmt, char x) { + s.print(new Format(fmt).form(x)); + } + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream, fmt the format string + * @param x a string that represents the digits to print + */ + + public static void print(java.io.PrintStream s, String fmt, String x) { + s.print(new Format(fmt).form(x)); + } + + /** + * Converts a string of digits (decimal, octal or hex) to an integer + * @param s a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ + + public static int atoi(String s) { + return (int)atol(s); + } + + /** + * Converts a string of digits (decimal, octal or hex) to a long integer + * @param s a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ + + public static long atol(String s) { + int i = 0; + + while (i < s.length() && Character.isWhitespace(s.charAt(i))) + i++; + if (i < s.length() && s.charAt(i) == '0') { + if (i + 1 < s.length() && (s.charAt(i + 1) == 'x' || s.charAt(i + 1) == 'X')) + return parseLong(s.substring(i + 2), 16); + else + return parseLong(s, 8); + } else + return parseLong(s, 10); + } + + private static long parseLong(String s, int base) { + int i = 0; + int sign = 1; + long r = 0; + + while (i < s.length() && Character.isWhitespace(s.charAt(i))) + i++; + if (i < s.length() && s.charAt(i) == '-') { + sign = -1; + i++; + } else if (i < s.length() && s.charAt(i) == '+') { + i++; + } + while (i < s.length()) { + char ch = s.charAt(i); + if ('0' <= ch && ch < '0' + base) + r = r * base + ch - '0'; + else if ('A' <= ch && ch < 'A' + base - 10) + r = r * base + ch - 'A' + 10 ; + else if ('a' <= ch && ch < 'a' + base - 10) + r = r * base + ch - 'a' + 10 ; + else + return r * sign; + i++; + } + return r * sign; + } + + /** + * Converts a string of digits to an double + * @param s a string + */ + + public static double atof(String s) { + int i = 0; + int sign = 1; + double r = 0; // integer part + double f = 0; // fractional part + double p = 1; // exponent of fractional part + int state = 0; // 0 = int part, 1 = frac part + + while (i < s.length() && Character.isWhitespace(s.charAt(i))) + i++; + if (i < s.length() && s.charAt(i) == '-') { + sign = -1; + i++; + } else if (i < s.length() && s.charAt(i) == '+') { + i++; + } + while (i < s.length()) { + char ch = s.charAt(i); + if ('0' <= ch && ch <= '9') { + if (state == 0) + r = r * 10 + ch - '0'; + else if (state == 1) { + p = p / 10; + r = r + p * (ch - '0'); + } + } else if (ch == '.') { + if (state == 0) + state = 1; + else + return sign * r; + } else if (ch == 'e' || ch == 'E') { + long e = (int)parseLong(s.substring(i + 1), 10); + return sign * r * Math.pow(10, e); + } else + return sign * r; + i++; + } + return sign * r; + } + + /** + * Formats a double into a string (like sprintf in C) + * @param x the number to format + * @return the formatted string + * @exception IllegalArgumentException if bad argument + */ + + public String form(double x) { + String r; + if (precision < 0) + precision = 6; + int s = 1; + if (x < 0) { + x = -x; + s = -1; + } + if (fmt == 'f') + r = fixed_format(x); + else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G') + r = exp_format(x); + else + throw new java.lang.IllegalArgumentException(); + + return pad(sign(s, r)); + } + + /** + * Formats a long integer into a string (like sprintf in C) + * @param x the number to format + * @return the formatted string + */ + + public String form(long x) { + String r; + int s = 0; + if (fmt == 'd' || fmt == 'i') { + if (x < 0) { + r = ("" + x).substring(1); + s = -1; + } else { + r = "" + x; + s = 1; + } + } else if (fmt == 'o') + r = convert(x, 3, 7, "01234567"); + else if (fmt == 'x') + r = convert(x, 4, 15, "0123456789abcdef"); + else if (fmt == 'X') + r = convert(x, 4, 15, "0123456789ABCDEF"); + else + throw new java.lang.IllegalArgumentException(); + + return pad(sign(s, r)); + } + + /** + * Formats a character into a string (like sprintf in C) + * @param x the value to format + * @return the formatted string + */ + + public String form(char c) { + if (fmt != 'c') + throw new java.lang.IllegalArgumentException(); + + String r = "" + c; + return pad(r); + } + + /** + * Formats a string into a larger string (like sprintf in C) + * @param x the value to format + * @return the formatted string + */ + + public String form(String s) { + if (fmt != 's') + throw new java.lang.IllegalArgumentException(); + if (precision >= 0) + s = s.substring(0, precision); + return pad(s); + } + + + /** + * a test stub for the format class + */ + + public static void main(String[] a) { + double x = 1.23456789012; + double y = 123; + double z = 1.2345e30; + double w = 1.02; + double u = 1.234e-5; + int d = 0xCAFE; + Format.print(System.out, "x = |%f|\n", x); + Format.print(System.out, "u = |%20f|\n", u); + Format.print(System.out, "x = |% .5f|\n", x); + Format.print(System.out, "w = |%20.5f|\n", w); + Format.print(System.out, "x = |%020.5f|\n", x); + Format.print(System.out, "x = |%+20.5f|\n", x); + Format.print(System.out, "x = |%+020.5f|\n", x); + Format.print(System.out, "x = |% 020.5f|\n", x); + Format.print(System.out, "y = |%#+20.5f|\n", y); + Format.print(System.out, "y = |%-+20.5f|\n", y); + Format.print(System.out, "z = |%20.5f|\n", z); + + Format.print(System.out, "x = |%e|\n", x); + Format.print(System.out, "u = |%20e|\n", u); + Format.print(System.out, "x = |% .5e|\n", x); + Format.print(System.out, "w = |%20.5e|\n", w); + Format.print(System.out, "x = |%020.5e|\n", x); + Format.print(System.out, "x = |%+20.5e|\n", x); + Format.print(System.out, "x = |%+020.5e|\n", x); + Format.print(System.out, "x = |% 020.5e|\n", x); + Format.print(System.out, "y = |%#+20.5e|\n", y); + Format.print(System.out, "y = |%-+20.5e|\n", y); + + Format.print(System.out, "x = |%g|\n", x); + Format.print(System.out, "z = |%g|\n", z); + Format.print(System.out, "w = |%g|\n", w); + Format.print(System.out, "u = |%g|\n", u); + Format.print(System.out, "y = |%.2g|\n", y); + Format.print(System.out, "y = |%#.2g|\n", y); + + Format.print(System.out, "d = |%d|\n", d); + Format.print(System.out, "d = |%20d|\n", d); + Format.print(System.out, "d = |%020d|\n", d); + Format.print(System.out, "d = |%+20d|\n", d); + Format.print(System.out, "d = |% 020d|\n", d); + Format.print(System.out, "d = |%-20d|\n", d); + Format.print(System.out, "d = |%20.8d|\n", d); + Format.print(System.out, "d = |%x|\n", d); + Format.print(System.out, "d = |%20X|\n", d); + Format.print(System.out, "d = |%#20x|\n", d); + Format.print(System.out, "d = |%020X|\n", d); + Format.print(System.out, "d = |%20.8x|\n", d); + Format.print(System.out, "d = |%o|\n", d); + Format.print(System.out, "d = |%020o|\n", d); + Format.print(System.out, "d = |%#20o|\n", d); + Format.print(System.out, "d = |%#020o|\n", d); + Format.print(System.out, "d = |%20.12o|\n", d); + + Format.print(System.out, "s = |%-20s|\n", "Hello"); + Format.print(System.out, "s = |%-20c|\n", '!'); + + // regression test to confirm fix of reported bugs + + Format.print(System.out, "|%i|\n", Long.MIN_VALUE); + + Format.print(System.out, "|%6.2e|\n", 0.0); + Format.print(System.out, "|%6.2g|\n", 0.0); + + Format.print(System.out, "|%6.2f|\n", 9.99); + Format.print(System.out, "|%6.2f|\n", 9.999); + + Format.print(System.out, "|%6.0f|\n", 9.999); + } + + private static String repeat(char c, int n) { + if (n <= 0) + return ""; + StringBuffer s = new StringBuffer(n); + for (int i = 0; i < n; i++) + s.append(c); + return s.toString(); + } + + private static String convert(long x, int n, int m, String d) { + if (x == 0) + return "0"; + String r = ""; + while (x != 0) { + r = d.charAt((int)(x & m)) + r; + x = x >>> n; + } + return r; + } + + private String pad(String r) { + String p = repeat(' ', width - r.length()); + if (left_align) + return pre + r + p + post; + else + return pre + p + r + post; + } + + private String sign(int s, String r) { + String p = ""; + if (s < 0) + p = "-"; + else if (s > 0) { + if (show_plus) + p = "+"; + else if (show_space) + p = " "; + } else { + if (fmt == 'o' && alternate && r.length() > 0 && r.charAt(0) != '0') + p = "0"; + else if (fmt == 'x' && alternate) + p = "0x"; + else if (fmt == 'X' && alternate) + p = "0X"; + } + int w = 0; + if (leading_zeroes) + w = width; + else if ((fmt == 'd' || fmt == 'i' || fmt == 'x' || fmt == 'X' || fmt == 'o') + && precision > 0) + w = precision; + + return p + repeat('0', w - p.length() - r.length()) + r; + } + + private String fixed_format(double d) { + boolean removeTrailing + = (fmt == 'G' || fmt == 'g') && !alternate; + // remove trailing zeroes and decimal point + + if (d > 0x7FFFFFFFFFFFFFFFL) + return exp_format(d); + if (precision == 0) + return (long)(d + 0.5) + (removeTrailing ? "" : "."); + + long whole = (long)d; + double fr = d - whole; // fractional part + if (fr >= 1 || fr < 0) + return exp_format(d); + + double factor = 1; + String leading_zeroes = ""; + for (int i = 1; i <= precision && factor <= 0x7FFFFFFFFFFFFFFFL; i++) { + factor *= 10; + leading_zeroes = leading_zeroes + "0"; + } + long l = (long) (factor * fr + 0.5); + if (l >= factor) { + l = 0; + whole++; + } // CSH 10-25-97 + + String z = leading_zeroes + l; + z = "." + z.substring(z.length() - precision, z.length()); + + if (removeTrailing) { + int t = z.length() - 1; + while (t >= 0 && z.charAt(t) == '0') + t--; + if (t >= 0 && z.charAt(t) == '.') + t--; + z = z.substring(0, t + 1); + } + + return whole + z; + } + + private String exp_format(double d) { + String f = ""; + int e = 0; + double dd = d; + double factor = 1; + if (d != 0) { + while (dd > 10) { + e++; + factor /= 10; + dd = dd / 10; + } + while (dd < 1) { + e--; + factor *= 10; + dd = dd * 10; + } + } + if ((fmt == 'g' || fmt == 'G') && e >= -4 && e < precision) + return fixed_format(d); + + d = d * factor; + f = f + fixed_format(d); + + if (fmt == 'e' || fmt == 'g') + f = f + "e"; + else + f = f + "E"; + + String p = "000"; + if (e >= 0) { + f = f + "+"; + p = p + e; + } else { + f = f + "-"; + p = p + (-e); + } + + return f + p.substring(p.length() - 3, p.length()); + } + + private int width; + private int precision; + private String pre; + private String post; + private boolean leading_zeroes; + private boolean show_plus; + private boolean alternate; + private boolean show_space; + private boolean left_align; + private char fmt; // one of cdeEfgGiosxXos +} + + + + + diff --git a/src/org/vamsas/objects/utils/GlyphDictionary.java b/src/org/vamsas/objects/utils/GlyphDictionary.java new file mode 100644 index 0000000..1ed7b20 --- /dev/null +++ b/src/org/vamsas/objects/utils/GlyphDictionary.java @@ -0,0 +1,23 @@ +package org.vamsas.objects.utils; + +/** + * dict attribute values for glyph symbol sets found in org.vamsas.objects.core.AnnotationElement + * TODO: add validators and multilength symbols. + * @author JimP + * + */ +public class GlyphDictionary { + /** + * standard H, E, or C three state secondary structure assignment. + */ + static final public String PROTEIN_SS_3STATE="aasecstr_3"; // HE, blank or C + /** + * default glyph type attribute indicates a UTF8 character + */ + static final public String DEFAULT="utf8"; + /** + * kyte and doolittle hydrophobicity + * TODO: specify this glyph set. + */ + static final public String PROTEIN_HD_HYDRO="kd_hydrophobicity"; +} diff --git a/src/org/vamsas/objects/utils/ProvenanceStuff.java b/src/org/vamsas/objects/utils/ProvenanceStuff.java new file mode 100644 index 0000000..2e813f7 --- /dev/null +++ b/src/org/vamsas/objects/utils/ProvenanceStuff.java @@ -0,0 +1,45 @@ +package org.vamsas.objects.utils; + +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.objects.core.Entry; +import org.vamsas.objects.core.Provenance; + +public class ProvenanceStuff { + + /** + * stuff for making and doing things with provenance objects. + */ + static Log log = LogFactory.getLog(ProvenanceStuff.class); + + /** + * @param app TODO + * @param action + * text for action entry + * @return new Provenance entry for ArchiveWriter created docs. + * TODO: Verify and move to SimpleClient class for provenance handling + */ + public static Entry newProvenanceEntry(String app, String user, String action) { + log.debug("Adding ProvenanceEntry("+user+","+action+")"); + Entry e = new Entry(); + e.setApp(app); + e.setAction(action); + e.setUser(user); + e.setDate(new org.exolab.castor.types.Date(new Date())); + return e; + } + public static Provenance newProvenance(Entry entry) { + Provenance list = new Provenance(); + list.addEntry(entry); + return list; + } + public static Provenance newProvenance(String user, String action) { + return newProvenance(ProvenanceStuff.newProvenanceEntry("vamsasApp:ExampleVamsasClient/alpha", user, action)); + } + public static Provenance newProvenance(String app, String user, String action) { + return newProvenance(ProvenanceStuff.newProvenanceEntry(app, user, action)); + } + +} diff --git a/src/org/vamsas/objects/utils/Seq.java b/src/org/vamsas/objects/utils/Seq.java new file mode 100644 index 0000000..b1955a1 --- /dev/null +++ b/src/org/vamsas/objects/utils/Seq.java @@ -0,0 +1,131 @@ +/* + * Created on 17-May-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.objects.utils; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.regex.Pattern; + +import org.vamsas.objects.core.AlignmentSequence; +import org.vamsas.objects.core.Sequence; +import org.vamsas.objects.core.SequenceType; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class Seq { + + public static void write_PirSeq(OutputStream os, SequenceType seq, int wid) throws IOException { + BufferedWriter pir_out = new BufferedWriter(new OutputStreamWriter(os)); + pir_out.write(">P1;"+seq.getName()+"\n"); + int width = (wid<1) ? 80 : wid; + for (int j=0,k=seq.getSequence().length(); j"+seq.getName()+"\n"); + fasta_out.write(seq.getSequence()+"\n"); + fasta_out.flush(); + } + + public static void write_FastaSeq(OutputStream os, SequenceType seq, int wid) throws IOException { + BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); + fasta_out.write(">"+seq.getName()+"\n"); + int width = (wid<1) ? 80 : wid; + for (int j=0,k=seq.getSequence().length(); jend on Sequence Vobject + if ((start-end)!=Sequence.length()) + seq.setEnd(end+Sequence.length()); + } + return seq; + } + public static AlignmentSequence newAlignmentSequence(String name, String alSequence, Sequence refseq, int start, int end) { + if (refseq!=null) { + AlignmentSequence asq = new AlignmentSequence(); + asq.setName(name); + asq.setSequence(alSequence); + asq.setRefid(refseq); + if (startrefseq.getEnd()) + end = refseq.getEnd(); + asq.setEnd(end); + return asq; + } + return null; + } + public static boolean is_valid_aa_seq(SequenceType s) { + Sequence q; + boolean validref=false; + if (s instanceof Sequence) { + q=(Sequence) s; + if (q.getDictionary()!=null + + && q.getDictionary().length()>0 + || !q.getDictionary().equals(SymbolDictionary.STANDARD_AA)) + return false; + return valid_aadictionary_string(q.getSequence(), SymbolDictionary.STANDARD_AA); + } + + // follow references + if (s instanceof AlignmentSequence) { + Object w = (((AlignmentSequence) s).getRefid()); + if (w!=null && w!=s && w instanceof SequenceType) + return is_valid_aa_seq((SequenceType) w) + && valid_aadictionary_string(((AlignmentSequence) s).getSequence(), SymbolDictionary.STANDARD_AA); + } + + return false; + } +} diff --git a/src/org/vamsas/objects/utils/SeqAln.java b/src/org/vamsas/objects/utils/SeqAln.java new file mode 100644 index 0000000..5e351f9 --- /dev/null +++ b/src/org/vamsas/objects/utils/SeqAln.java @@ -0,0 +1,238 @@ +/* + * Created on 17-May-2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.objects.utils; + +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Hashtable; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.regex.Pattern; + +import org.vamsas.objects.core.*; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Style - Code Templates + */ +public class SeqAln extends org.vamsas.objects.core.Alignment { + + public static Sequence[] ReadClustalFile(InputStream os) throws Exception { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); + String gapchars = ""; + char gapchar = '-'; + + int i = 0; + boolean flag = false; + + Vector headers = new Vector(); + Hashtable seqhash = new Hashtable(); + Sequence[] seqs = null; + int noSeqs = 0; + String line; + + try { + BufferedReader ins = new BufferedReader(new InputStreamReader(os)); + while ((line = ins.readLine()) != null) { + if (line.indexOf(" ") != 0) { + java.util.StringTokenizer str = new StringTokenizer(line, " "); + String id = ""; + + if (str.hasMoreTokens()) { + id = str.nextToken(); + if (id.equals("CLUSTAL")) { + flag = true; + } else { + if (flag) { + StringBuffer tempseq; + if (seqhash.containsKey(id)) { + tempseq = (StringBuffer) seqhash.get(id); + } else { + tempseq = new StringBuffer(); + seqhash.put(id, tempseq); + } + + if (!(headers.contains(id))) { + headers.addElement(id); + } + + tempseq.append(str.nextToken()); + } + } + } + } + } + + } catch (IOException e) { + throw (new Exception("Exception parsing clustal file ", e)); + } + + if (flag) { + noSeqs = headers.size(); + + // Add sequences to the hash + seqs = new Sequence[headers.size()]; + for (i = 0; i < headers.size(); i++) { + if (seqhash.get(headers.elementAt(i)) != null) { + // TODO: develop automatic dictionary typing for sequences + Sequence newSeq = Seq.newSequence(headers.elementAt(i).toString(), + seqhash.get(headers.elementAt(i).toString()).toString(), + SymbolDictionary.STANDARD_AA,0,0); + + seqs[i] = newSeq; + + } else { + throw (new Exception("Bizarreness! Can't find sequence for " + + headers.elementAt(i))); + } + } + } + return seqs; + } + + public static void WriteClustalWAlignment(java.io.OutputStream os, + Alignment seqAl) throws IOException { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + AlignmentSequence[] s = seqAl.getAlignmentSequence(); + + java.io.BufferedWriter out = new BufferedWriter( + new java.io.OutputStreamWriter(os)); + + out.write("CLUSTAL\n\n"); + + int max = 0; + int maxid = 0; + + int i = 0; + + while (i < s.length && s[i] != null) { + String tmp = s[i].getId(); + + if (s[i].getSequence().length() > max) { + max = s[i].getSequence().length(); + } + if (tmp.length() > maxid) { + maxid = tmp.length(); + } + i++; + } + + if (maxid < 15) { + maxid = 15; + } + maxid++; + int len = 60; + int nochunks = max / len + 1; + + for (i = 0; i < nochunks; i++) { + int j = 0; + while (j < s.length && s[j] != null) { + out.write(new Format("%-" + maxid + "s").form(s[j].getId() + " ")); + int start = i * len; + int end = start + len; + + if (end < s[j].getSequence().length() && start < s[j].getSequence().length()) { + out.write(s[j].getSequence().substring(start, end) + "\n"); + } else { + if (start < s[j].getSequence().length()) { + out.write(s[j].getSequence().substring(start) + "\n"); + } + } + j++; + } + out.write("\n"); + + } + } + /** + * manufacture an alignment/dataset from an array of sequences + * @param origin + * @param seqs + * @return + * @throws Exception + */ + public static Alignment make_Alignment(Entry origin, + Sequence[] seqs) throws Exception { + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + Alignment al = new Alignment(); + al.setProvenance(ProvenanceStuff.newProvenance(origin)); + + Pattern nonGap = Pattern.compile("[A-Z*0-9]", Pattern.CASE_INSENSITIVE); + boolean gapsset = false; + char gapchar = '-'; + int seqLength = 0; + + for (int i = 0, nseq = seqs.length; i < nseq; i++) { + String seq = seqs[i].getSequence(); + String gaps = nonGap.matcher(seq).replaceAll(""); + if (seqLength == 0) { + seqLength = seq.length(); + } else if (seqLength != seq.length()) + throw (new Exception(i + "th Sequence (>" + seqs[i].getId() + + ") is not aligned.\n"));// TODO: move this to assertions part of + // Alignment + + // common check for any sequence... + if (gaps != null && gaps.length() > 0) { + if (!gapsset) + gapchar = gaps.charAt(0); + for (int c = 0, gc = gaps.length(); c < gc; c++) { + if (gapchar != gaps.charAt(c)) { + throw (new IOException("Inconsistent gap characters in sequence " + + i + ": '" + seq + "'")); + } + } + } + AlignmentSequence sq = new AlignmentSequence(); + // TODO: use as basis of default AlignSequence(Sequence) constructor. + sq.setSequence(seq); + sq.setName(seqs[i].getId()); + sq.setRefid(seqs[i].getVorbaId()); + sq.setStart(seqs[i].getStart()); + sq.setEnd(seqs[i].getEnd()); + al.addAlignmentSequence(sq); + } + al.setGapChar(String.valueOf(gapchar)); + return al; + } + + public static Alignment read_FastaAlignment(InputStream os, Entry entry) + throws Exception { + Sequence[] seqs; + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + try { + seqs = SeqSet.read_SeqFasta(os); + if (seqs == null) + throw (new Exception("Empty alignment stream!\n")); + } catch (Exception e) { + throw new Exception("Invalid fasta alignment\n", e); + } + + return make_Alignment(entry, seqs); + } + + public static Alignment read_ClustalAlignment(InputStream os, Entry entry) + throws Exception { + Sequence[] seqs; + try { + seqs = SeqAln.ReadClustalFile(os); + if (seqs == null) + throw (new Exception("Empty alignment stream!\n")); + } catch (Exception e) { + throw new Exception("Invalid fasta alignment\n", e); + } + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + return make_Alignment(entry, seqs); + } +} diff --git a/src/org/vamsas/objects/utils/SeqSet.java b/src/org/vamsas/objects/utils/SeqSet.java new file mode 100644 index 0000000..294ce43 --- /dev/null +++ b/src/org/vamsas/objects/utils/SeqSet.java @@ -0,0 +1,138 @@ +/* + * Created on 17-May-2005 + * Slurped into VamsasClient object set on 12th Jan 2006 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.vamsas.objects.utils; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.Hashtable; +import java.util.Vector; +import java.util.regex.Pattern; + +import org.vamsas.objects.core.*; + +/** + * @author jimp + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class SeqSet { + + public static void write_Fasta(OutputStream os, SequenceType[] seqs) throws IOException { + write_Fasta(os, seqs, 80); + } + + public static void write_Fasta(OutputStream os, SequenceType[] seqs, boolean width80) throws IOException { + write_Fasta(os, seqs, (width80) ? 80 : 0); + } + + public static void write_Fasta(OutputStream os, SequenceType[] seqs, int width) throws IOException { + int i, nseq = seqs.length; + BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + for (i=0; i"+seqs[i].getName()+"\n"); + if (width<=0) { + fasta_out.write(seqs[i].getSequence()+"\n"); + } else { + // TODO: adapt to SymbolDictionary labelwidths + String tempseq = seqs[i].getSequence(); + int j=0, k=tempseq.length(); + while (j=width) { + fasta_out.write(tempseq, j, width); + } else { + fasta_out.write(tempseq, j, d); + } + fasta_out.write("\n"); + j+=width; + } + } + } + fasta_out.flush(); + } + /** + * TODO: introduce a dictionary parameter for qualified sequence symbols + * Reads a sequence set from a stream - will only read prescribed amino acid + * symbols. + * @param os + * @return + * @throws IOException + */ + public static Sequence[] read_SeqFasta(InputStream os) throws IOException { + Vector seqs = new Vector(); + int nseq = 0; + BufferedReader infasta = new BufferedReader(new InputStreamReader(os)); + System.err.println("NOT FULLY IMPLEMENTED!"); // TODO: Finish adapting this method + // TODO: decide on return type - SequenceType is a partly complete vamsas Vobject - either for a dataset or alignment sequence + // so could go in either! + String line; + Sequence seq = null; + Pattern aaMatch = Pattern.compile("[ARNDCQEGHILKMFPSTUWYV]", Pattern.CASE_INSENSITIVE); + String sname = "", seqstr=null; + do { + line = infasta.readLine(); + if (line==null || line.startsWith(">")) { + if (seqstr!=null) + seqs.add((Object) Seq.newSequence(sname.substring(1), seqstr, SymbolDictionary.STANDARD_AA, 0,0)); + sname = line; // remove > + seqstr=""; + } else { + String subseq = Pattern.compile("//s+").matcher(line).replaceAll(""); + seqstr += subseq; + } + } while (line!=null); + nseq = seqs.size(); + if (nseq>0) { + // TODO:POSS: should really return a sequence if there's only one in the file. + Sequence[] seqset = new Sequence[nseq]; + for (int i=0; i is one of :\n\tsave,update,close,watch"; + + private static boolean parseArgs(String args[]) { + return true; // incorrect arguments. + } + public static void main(String[] args) { + if ((args.length<=2) || !parseArgs(args)) { + System.err.print(Usage); + } + + // get IClientFactory + try { + clientfactory = new org.vamsas.client.simpleclient.SimpleClientFactory(args[0]); + } catch (IOException e) { + System.err.println(e+"\n"+Usage); + System.exit(1); + } + + // get an Iclient with session data + app = new ClientHandle("org.vamsas.test.ExampleApplication","0.1"); + user = new UserHandle("arnolduser","deathsdoor"); + try { + vorbaclient = clientfactory.getIClient(app, user); + } catch (NoDefaultSessionException e) { + System.err.println("There appear to be several sessions to choose from :"); + String[] sessions = clientfactory.getCurrentSessions(); + for (int s=0;sSystem.currentTimeMillis())); // tuning. + if (doclock==null) + return null; + else { + return getUpdateable(vsess.getLock(doclock)); + /*VamsasArchiveReader varc = new VamsasArchiveReader(vsess.getVamsasFile()); + return _getReadonly(varc);*/ + } + } catch (Exception e) { + log.error("Whilst watching file "+vsess.getVamsasFile(), e); + } + return null; + } + + // from ClientDocument.getClientAppdata + private AppData[] getAppData(VamsasDocument doc) { + if (doc==null) { + log.debug("extractAppData called for null document object"); + return null; + } + AppData appsGlobal=null, usersData=null; + Vector apldataset = AppDataReference.getUserandApplicationsData( + doc, this.getUserHandle(), this.getClientHandle()); + if (apldataset!=null) { + if (apldataset.size()>0) { + AppData clientdat = (AppData) apldataset.get(0); + if (clientdat instanceof ApplicationData) { + appsGlobal = (ApplicationData) clientdat; + if (apldataset.size()>1) { + clientdat = (AppData) apldataset.get(1); + if (clientdat instanceof User) { + usersData = (User) clientdat; + } + if (apldataset.size()>2) + log.info("Ignoring additional ("+(apldataset.size()-2)+") AppDatas returned by document appdata query."); + } + } else { + log.warn("Unexpected entry in AppDataReference query: id="+clientdat.getVorbaId()+" type="+clientdat.getClass().getName()); + } + apldataset.removeAllElements(); // destroy references. + } + } + return new AppData[] { appsGlobal, usersData}; + } + + protected ClientDoc _getReadonly(VamsasArchiveReader vreader) throws IOException, ValidationException, MarshalException { + valid(); + if (vreader!=null) { + SimpleDocBinding docb = new SimpleDocBinding(); + docb.setVorba(this); + VamsasDocument d; + d = docb.getVamsasDocument(vreader); + + if (d!=null) { + ClientDoc creader = new ClientDoc(d, null, vreader, getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash()); + return creader; + } + } + return null; + } + /** + * from SimpleClient + * @return user field for a provenance entry + */ + protected String getProvenanceUser() { + return new String(getUserHandle().getFullName()+" ["+getClientHandle().getClientUrn()+"]"); + } + + public ClientDoc getUpdateable() { + return getUpdateable(null); + } + public ClientDoc getUpdateable(org.vamsas.client.simpleclient.Lock lock) { + getVorbaIdHash().clear(); + valid(); + try { + // patiently wait for a lock on the document. + long tries=5000; + while (lock==null && ((lock=vsess.getLock())==null || !lock.isLocked()) && --tries>0) { +// Thread.sleep(1); + log.debug("Trying to get a document lock for the "+tries+"'th time."); + } + VamsasArchive varc = new VamsasArchive(vsess, true, false); // read archive, write as vamsasDocument, don't erase original contents. + varc.setVorba(this); + VamsasDocument d = varc.getVamsasDocument(getProvenanceUser(), "Created new document.", VersionEntries.latestVersion()); // VAMSAS: provenance user and client combined + + if (d==null) { + log.warn("Backing out from opening a VamsasArchive writable IO session"); + varc.cancelArchive(); + return null; + } + ClientDoc cdoc = new ClientDoc(d, varc, varc.getOriginalArchiveReader(), getClientHandle().getClientUrn(), getProvenanceUser(), getVorbaIdHash()); + return cdoc; + // do appHandle? + } catch (Exception e) { + log.error("Failed to get Updateable version of "+vsess.getVamsasFile(), e); + } + return null; + } + /** + * trust client to not do anything stupid to the document roots which will now be written to the archive. + * @param cdoc + * @return true if write was a success. + */ + public boolean doUpdate(ClientDoc cdoc) { + valid(); + if (cdoc==null) { + log.warn("Invalid ClientDoc passed to org.vamsas.test.simpleclient.doUpdate()"); + return false; + } + if (cdoc.iohandler==null) { + log.warn("Read only ClientDoc object passed to org.vamsas.test.simpleclient.doUpdate()"); + return false; + } + if (cdoc.iohandler.getVorba()!=this) { + log.error("Mismatch between ClientDoc instances and ArchiveClient instances!"); + return false; + } + try { + // do any appDatas first. + if (cdoc.iohandler.transferRemainingAppDatas()) + log.debug("Remaining appdatas were transfered."); + cdoc.updateDocumentRoots(); + cdoc.iohandler.putVamsasDocument(cdoc.doc); + cdoc.iohandler.closeArchive(); + this.extantids.clear();// we forget our ids after we close the document. + cdoc.iohandler=null; + cdoc = null; + vsess.unLock(); + } catch (Exception e) { + log.warn("While updating archive in "+vsess.getVamsasFile(),e); + return false; + } + return true; + } + /** + * @param args + */ + public static void usage() { + throw new Error("Usage: Username Organization VamsasFile [command,args]*"); + } + public static void main(String[] args) { + // really simple. + if (args.length<3) + usage(); + + ArchiveClient client = new ArchiveClient(args[0],args[1], new File(args[2])); + ClientDoc cdoc=null; + // sanity test. + try { + cdoc = client.getUpdateable(); + // ArchiveReports.reportDocument(cdoc.doc, cdoc.getReader(), true, System.out); + System.out.println("Report Roots :"); + ArchiveReports.rootReport(cdoc.getVamsasRoots(), true, System.out); + cdoc.addVamsasRoot(Core.getDemoVamsas()); + System.out.println("Doing update."); + client.doUpdate(cdoc); + cdoc.closeDoc(); + cdoc = null; + int u=5; + while (--u>0) { + System.out.println("Watch for more... ("+u+" left)"); + ClientDoc ucdoc = client.watch(0000); + if (ucdoc!=null) { + System.out.println("****\nUpdate detected at "+new Date()); + ArchiveReports.reportDocument(ucdoc.doc, ucdoc.getReader(), true, System.out); + ucdoc.closeDoc(); + ucdoc=null; + } else { + System.out.println("!!!! Null document update detected at "+new Date()); + } + } + } + catch (Exception e) { + client.log.error("Broken!", e); + } + System.out.println("Finished at "+new Date()); + } + public org.vamsas.client.Vobject getObject(VorbaId id) { + Hashtable idhash = this.getVorbaIdHash(); + if (idhash!=null && idhash.containsKey(id)) + return (Vobject) idhash.get(id); + return null; + } +} diff --git a/src/org/vamsas/test/simpleclient/ArchiveReader.java b/src/org/vamsas/test/simpleclient/ArchiveReader.java new file mode 100644 index 0000000..d7959b4 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/ArchiveReader.java @@ -0,0 +1,50 @@ +package org.vamsas.test.simpleclient; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; + +public class ArchiveReader { + /** + * tests VamsasArchiveReader archive reader on a vamsas jar file + * @param args + */ + public static void main(String args[]) { + + try { + File av = new File(args[0]); + VamsasArchiveReader var = new VamsasArchiveReader(av); + VAMSAS roots[]=null; + if (var.isValid()) { + InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream()); + VamsasDocument doc = VamsasDocument.unmarshal(vdoc); + if (ArchiveReports.reportDocument(doc, var, true, System.out)) { + roots = doc.getVAMSAS(); + } + } else { + InputStream vxmlis = var.getVamsasXmlStream(); + + if (vxmlis!=null) { // Might be an old vamsas file. + BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream()); + InputStreamReader vxml = new InputStreamReader(ixml); + VAMSAS root; + // unmarshal seems to always close the stream (should check this) + if ((root = VAMSAS.unmarshal(vxml))!=null) { + System.out.println("Read a root."); + roots = new VAMSAS[1]; + roots[0] = root; + } + } + } + if (!ArchiveReports.rootReport(roots, true, System.out)) + System.err.print(args[0]+" is not a valid vamsas archive."); + } catch (Exception e) { + e.printStackTrace(System.err); + } + } +} diff --git a/src/org/vamsas/test/simpleclient/ArchiveReports.java b/src/org/vamsas/test/simpleclient/ArchiveReports.java new file mode 100644 index 0000000..4a3a284 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/ArchiveReports.java @@ -0,0 +1,186 @@ +package org.vamsas.test.simpleclient; + +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; + +import org.vamsas.client.ClientDocument; +import org.vamsas.client.Vobject; +import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.objects.core.Alignment; +import org.vamsas.objects.core.AppData; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.DataSet; +import org.vamsas.objects.core.Entry; +import org.vamsas.objects.core.Instance; +import org.vamsas.objects.core.Provenance; +import org.vamsas.objects.core.Tree; +import org.vamsas.objects.core.User; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; +/** + * this class contains static methods for writing info to stdout about a vamsas document + * Methods have a 'cascade' switch to indicate if sub-objects should have info printed on them. + * Methods return true or false - indicating if the Vobject was valid or not + * TODO: LATER: propagate true/false return so that an invalid vamsas Vobject invalidates the whole document + * @author jimp + * + */ +public class ArchiveReports { + /** + * print an informative summary on a VamsasDocument + * @param outstr TODO + * @param document - the document itself + * @param archive - document source archive for resolving any appData refs + * @return + */ + public static boolean reportProvenance(Provenance p, PrintStream outstr) { + if (p==null) { + outstr.println("No Provenance"); + return false; + } + Entry[] pe = p.getEntry(); + for (int i=0; i1) { + outstr.print("a reference ("+appData+")"); + InputStream jstrm; + if ((jstrm=archive.getAppdataStream(appData))!=null) + outstr.println(" which resolves to a JarEntry."); + else { + outstr.println(" which does not resolve to a JarEntry."); + outstr.println("Unresolved appdata reference '"+appData+"'"); + } + } else { + nulldata=true; + } + } else { + if (appD.getData()==null) + nulldata &= true; + else + outstr.println("an embedded chunk of "+appD.getData().length+" bytes."); + } + if (nulldata) + outstr.println("Null AppData reference/data chunk."); + } + return true; + } + + public static boolean appDataReport(ApplicationData appD, VamsasArchiveReader archive, boolean cascade, PrintStream outstr) { + if (appD!=null) { + // Report on root appData + appDataEntryReport(appD, archive, cascade, outstr); + if (appD.getInstanceCount()>0) { + Instance inst[] = appD.getInstance(); + for (int i=0,j=inst.hashCode(); i0) { + User users[] = appD.getUser(); + for (int i=0,j=users.length; i0 && cascade) + rootReport(document.getVAMSAS(), true, outstr); + if (document.getApplicationDataCount()>0) { + outstr.print("There are "+document.getApplicationDataCount()+" ApplicationData references.\n"); + ApplicationData appd[] = document.getApplicationData(); + for (int i=0,j=appd.length; i") + +") contains "+(ds=r.getDataSetCount())+" DataSets, " + + (tr=r.getTreeCount())+" Global trees\n"); + if (cascade) { + for (int j=0; j0) { + for (int i=0; i0) { + File archive = new File(args[0]); + log.info("Watching file "+args[0]); + int argc=1; + while (argc < args.length) { + // vars needed for operations + ClientHandle ch; + int com = cproc.getCommand(args, argc); + argc++; + switch (com) { + case 0: + // new + log.info("Doing locked deletion and new-file creation."); + { + if (!archive.exists()) + archive.createNewFile(); + VamsasFile sf = new VamsasFile(archive); + Lock l = sf.getLock(); + archive.delete(); + archive.createNewFile(); + sf.unLock(); + } + break; + case 1: + // delete + log.info("Deleting "+archive+" without locking it first."); + archive.delete(); + break; + case 2: + // watch + log.info("Endlessly Watching file "+archive); + /* if (!archive.exists()) + archive.createNewFile(); + */ // watch the new file... - taken straight from ClientsFileTest + FileWatcher w = new FileWatcher(archive); + while (true) { + // get watcher's lock to ensure state change is fixed for retrieval + Lock chlock = w.getChangedState(); + if (chlock != null) { + log.info("Got lock on "+archive+(archive.exists() ? " exists l="+archive.length() : "(non existant)")); + if (archive.length()>0) { + VamsasArchiveReader vreader = new VamsasArchiveReader(archive); + SimpleDocument sdoc = new SimpleDocument("testing vamsas watcher"); + try { + VamsasDocument d = sdoc.getVamsasDocument(vreader); + if (d!=null) { + ArchiveReports.reportDocument(d, vreader, false, System.out); + } + System.out.println("Update at "+System.currentTimeMillis()+"\n\n********************************************************\n"); + } catch (Exception e) { + log.error("Unmarshalling failed.",e); + } + vreader.close(); + w.setState(); + } + } + } + // break; + case 3: // set file + archive = new File(args[argc++]); + break; + case 4: + break; + default: + log.warn("Unknown command + "+args[argc++]); + } + } + } + } catch (Exception e) { + log.error(e); + } + + } +} diff --git a/src/org/vamsas/test/simpleclient/ArchiveWriter.java b/src/org/vamsas/test/simpleclient/ArchiveWriter.java new file mode 100644 index 0000000..d6f8ee9 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/ArchiveWriter.java @@ -0,0 +1,180 @@ +package org.vamsas.test.simpleclient; + +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.text.DateFormat; +import java.util.Date; +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.simpleclient.VamsasArchive; +import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.objects.core.Alignment; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.Entry; +import org.vamsas.objects.core.Instance; +import org.vamsas.objects.core.Provenance; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.objects.utils.ProvenanceStuff; + +public class ArchiveWriter { + + /** + * Test program for writing archive files. + * form is ArchiveWriter new/modified argive command list + */ + + static Log log = LogFactory.getLog(ArchiveWriter.class); + + private static void mergeVecs(Object[] destvec, Object[] svec1, Object[] svec2) { + int i; + for (i=0; i0) { + ApplicationData[] newdat = new ApplicationData[source.getApplicationDataCount()+dest.getApplicationDataCount()]; + ApplicationData[] sappd = source.getApplicationData(); + // check refs and update/modify if necessary + for (int i=0; i [(commands)]"); + return; + } + File newarch = new File(argv[0]); + int argpos = 0; + try { + // test fully fledged doc construction + VamsasArchive varc = new VamsasArchive(newarch, true); + VamsasDocument docroot; + docroot = new VamsasDocument(); + docroot.setProvenance(ProvenanceStuff.newProvenance("ArchiveWriter", "user", "Created new Vamsas Document")); + while (++argpos-1) { + if (isValidUpdate(newr[k], original[i])) { + modified=true; + rts.add(newr[k]); + newr[k]=null; + } else { + // LATER: try harder to merge ducument roots. + log.warn("Couldn't merge new VAMSAS root "+newr[k].getId()); + newr[k] = null; // LATER: this means we ignore mangled roots. NOT GOOD + } + } else { + // add in order. + rts.add(original[i]); + } + } + // add remaining (new) roots + for (int i=0,j=newr.length; i2) + complainArgs(args.length, argc+1, comnext); + return com; + } + } + return -1; + + } +} diff --git a/src/org/vamsas/test/simpleclient/VamsasArchive.java b/src/org/vamsas/test/simpleclient/VamsasArchive.java new file mode 100644 index 0000000..09ddf34 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/VamsasArchive.java @@ -0,0 +1,205 @@ +package org.vamsas.test.simpleclient; + +import java.io.File; +import java.io.ObjectOutputStream; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.vamsas.client.simpleclient.Lock; +import org.vamsas.client.simpleclient.SessionFile; +import org.vamsas.client.simpleclient.SimpleDocument; +import org.vamsas.client.simpleclient.VamsasArchiveReader; +import org.vamsas.client.simpleclient.VamsasFile; +import org.vamsas.objects.core.ApplicationData; +import org.vamsas.objects.core.User; +import org.vamsas.objects.core.VAMSAS; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.test.objects.Core; + +public class VamsasArchive { + /** + * test the org.vamsas.simpleclient.vamsasArchive class + */ + static Log log = LogFactory.getLog(VamsasArchive.class); + public static ApplicationData makeDemoAppdata(org.vamsas.client.simpleclient.VamsasArchive va, String apname, String userName, String userOrg) { + if (va==null) + return null; + VamsasArchiveReader vread=null; + try { + vread = va.getOriginalArchiveReader(); + } + catch (Exception e) { + log.error("Failed to get original archive reader!",e); + return null; + } + ApplicationData appdata = new ApplicationData(); + appdata.setName("org.vamsas.test.simpleclient.VamsasArchive"); + appdata.setData(new String("this is some test data.").getBytes()); + User apuser = new User(); + apuser.setFullname(userName); + apuser.setOrganization(userOrg); + String appdata_ref = "vamsas:"+apname+"/"+apuser.getOrganization()+"/"+apuser.getFullname(); + SimpleDocument sdoc = new SimpleDocument("test.simpleclient.VamsasArchive"); + if (vread!=null) { + VamsasDocument orignalnew; + try { + orignalnew = sdoc.getVamsasDocument(vread); + log.info("*** Dump follows ***"); + + ArchiveReports.reportDocument(orignalnew, vread, false, System.out); + log.info("*** Dump precedes ***"); + } catch (Exception e) { + log.info("makeDemoAppdata: Problems accessing original document"); + } + + log.info("Reading (and avoiding references to) original data"); + if (vread.getAppdataStream(appdata_ref)!=null) { + // transfer over + try { + va.transferAppDataEntry(appdata_ref); + } catch (Exception e) { + log.warn("Exception when transferring appdata reference : "+appdata_ref, e); + } + int i=0; + while (vread.getAppdataStream(appdata_ref+"/"+Integer.toString(++i))!=null) { + try { + // copy over another duplicate. + va.transferAppDataEntry(appdata_ref+"/"+Integer.toString(i)); + } catch (Exception e) { + log.warn("Exception when transferring appdata reference : "+appdata_ref, e); + } + } + // this one must be unique! + appdata_ref+="/"+Integer.toString(i); + } + } + + log.info("Adding new data stuff."); + log.info("Writing an apdata reference using AppDataStream interface."); + apuser.setDataReference(appdata_ref); + appdata.addUser(apuser); + appdata.setVersion("noggin"); + //TODO: write instance appdata appdata.setUrn("program:/the.nog/"); + try { + ObjectOutputStream ost = new ObjectOutputStream(va.getAppDataStream(appdata_ref)); + ost.writeObject(appdata); + ost.close(); + } catch (Exception e) { + log.warn("Couldn't write appdata reference "+appdata_ref); + } + return appdata; + } + public static void main(String args[]) { + + try { + File av; + if (args.length>0) + av = new File(args[0]); + else + av = new File("test/vamsas.zip"); + log.info("Opening archive "+av); + org.vamsas.client.simpleclient.VamsasArchive varchive = new org.vamsas.client.simpleclient.VamsasArchive(av, true); + + VAMSAS[] roots = (VAMSAS[]) varchive.getOriginalRoots(); + + if (roots!=null) { + log.info("Report on Original roots in archive:"); + ArchiveReports.rootReport(roots, true, System.out); + } + log.info("Getting current vamsas document."); + VamsasDocument doc = varchive.getVamsasDocument(); + ArchiveReports.reportDocument(doc, varchive.getOriginalArchiveReader(), true, System.out); // not modified document so references will still be valid + // do some stuff + log.info("Retrieving backup"); + File backup = varchive.backupFile(); + if (backup==null) + log.info(av+" is a New Archive."); + else + log.info(av+" has been backed up as "+backup); + File newf=new File(av.getAbsolutePath()+"_new.zip"); + VamsasFile sfile = new VamsasFile(newf); + /* if (newf.exists()) { + int q=1; + do { + newf=new File(av.getAbsolutePath()+"_"+q+++"_new.zip"); + } + while (newf.exists()); + } */ + if (newf.exists()) { + log.info("Removing existing "+newf); + newf.delete(); + } + + log.info("Now writing new Archive into "+newf.getAbsolutePath()); + org.vamsas.client.simpleclient.VamsasArchive va=null; + { // hold lock over deletion and write of new archive. + //Lock wlock = sfile.getLock(); + //newf.delete(); // clear out old file. + sfile.getLock(); + va = new org.vamsas.client.simpleclient.VamsasArchive(newf, true, true, sfile); + // open another and... + ApplicationData appdata = makeDemoAppdata(va, + "org.vamsas.test.simpleclient.VamsasArchive", "arnold Bugger esq", "disOrganised"); + log.info("Preparing to write new document."); + doc.addApplicationData(appdata); + doc.addVAMSAS(Core.getDemoVamsas()); + va.putVamsasDocument(doc); // gets stream and puts it. + va.closeArchive(); + sfile.unLock(); + } + log.info("Dump of new vamsas document :"); + log.info("Testing update: "); + { + Lock lock=sfile.getLock(); + if (lock==null) + while ((lock=sfile.getLock())==null) { + log.info("Waiting for lock."); + Thread.sleep(100); + } + VamsasArchiveReader vreader = new VamsasArchiveReader(sfile.getVamsasFile());// lock); // cannot do new JarFile on a locked file. // newf); + SimpleDocument sdoc = new SimpleDocument("testing new vamsas write"); + ArchiveReports.reportDocument(sdoc.getVamsasDocument(vreader), vreader, true, System.out); + sfile.unLock(); + } + // backup.delete(); // tidy up + + log.info("Now Cancelling write to original archive "+av); + if (varchive.cancelArchive()) + log.info("Successfully cancelled."); + else + log.info("Didn't cancel."); + long t=System.currentTimeMillis()+200; while (t>System.currentTimeMillis()); + log.info("Now testing archive update."); + va = new org.vamsas.client.simpleclient.VamsasArchive(newf, false, true, sfile); + doc = va.getVamsasDocument(); + doc.addVAMSAS(Core.getDemoVamsas()); + doc.addApplicationData(makeDemoAppdata(va, + "org.vamsas.test.simpleclient.VamsasArchive", "another old Bugger esq", "rescinded")); + if (va.transferRemainingAppDatas()) + log.info("Remain appdatas were transferred."); + else + log.warn("No appdatas were transferred. This is wrong."); + va.putVamsasDocument(doc); + va.closeArchive(); + sfile.unLock(); + log.info("Testing update: "); + { + Lock lock=sfile.getLock(); + if (lock==null) + while ((lock=sfile.getLock())==null) + log.info("Waiting for lock."); + // VamsasArchiveReader vreader = new VamsasArchiveReader(lock); + VamsasArchiveReader vreader = new VamsasArchiveReader(newf); + + SimpleDocument sdoc = new SimpleDocument("testing vamsas update"); + VamsasDocument finaldoc = sdoc.getVamsasDocument(vreader); + if (finaldoc!=null) + ArchiveReports.reportDocument(finaldoc, vreader, true, System.out); + else + log.error("Null Document Read from "+newf); + } + } catch (Exception e) { + e.printStackTrace(System.err); + } + } +} diff --git a/src/org/vamsas/test/simpleclient/simpleapp/VamsasClient.java b/src/org/vamsas/test/simpleclient/simpleapp/VamsasClient.java new file mode 100644 index 0000000..2b70a0a --- /dev/null +++ b/src/org/vamsas/test/simpleclient/simpleapp/VamsasClient.java @@ -0,0 +1,186 @@ +/** + * + */ +package org.vamsas.test.simpleclient.simpleapp; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.Vector; +import java.util.jar.JarOutputStream; + +import javax.swing.JInternalFrame; + +import org.vamsas.client.UserHandle; +import org.vamsas.client.simpleclient.FileWatcher; +import org.vamsas.client.simpleclient.VamsasArchive; +import org.vamsas.client.simpleclient.VamsasFile; +import org.vamsas.objects.core.Entry; +import org.vamsas.objects.core.VamsasDocument; +import org.vamsas.test.simpleclient.ArchiveClient; +import org.vamsas.test.simpleclient.ClientDoc; + +/** + * @author jimp + * + */ +public class VamsasClient extends ArchiveClient { + org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory.getLog(VamsasClient.class); + /** + * create a new vamsas client session from the archive at sessionPath. + * @param sessionPath + */ + public VamsasClient(File sessionPath) { + super(System.getProperty("user.name"),System.getProperty("host.name"), "SimpleVamsasClientApp","0.1", + sessionPath); + } + /** + * Called by gui to read anything from the vamsas session into the apps datamodel + * after it has started up. + * + */ + public void initial_update() { + log.info("Jalview loading the Vamsas Session."); + // load in the vamsas archive for the first time + ClientDoc cdoc = this.getUpdateable(); + updateJalview(cdoc); + // TODO: flush any new VorbaIds to the document : updateVamsasClient may actually generate new Vamsas Document data in the form of vamsas element ids - these should be written back to the document. + //doUpdate(cdoc); // JBPNote: this should flush new VorbaIds but I've not tested it yet. + cdoc.closeDoc(); + // then tell app to update its display based on the datamodel changes. + } + VamsasClientWatcher watcher=null; + /** + * Called by app when internal datamodel should exported (syncrhonised outwards) to vamsas document + * + */ + public void push_update() { + + watchForChange=false; // this makes any watch(long) loops return. + // we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped. + try { + Thread.sleep(WATCH_SLEEP); + } catch (Exception e) { + + }; + + ClientDoc cdoc = getUpdateable(); + updateVamsasDocument(cdoc); + doUpdate(cdoc); + cdoc.closeDoc(); + cdoc=null; + watchForChange=true; + startWatcher(); + } + public void end_session() { + watchForChange=false; // this makes any watch(long) loops return. + // we should also wait arount for this.WATCH_SLEEP to really make sure the watcher thread has stopped. + try { + Thread.sleep(WATCH_SLEEP); + } catch (Exception e) { + + }; + + // stop any update/watcher thread. + log.info("VamsasClientApplication disconnecting from the Vamsas Session."); + } + public void updateJalview(ClientDoc cdoc) { + ensureVamsasBindings(); + VamsasDatastore vds = new VamsasDatastore(cdoc, vobj2jv, jv2vobj, baseProvEntry()); + vds.updateToJalview(); + } + private void ensureVamsasBindings() { + if (jv2vobj==null) { + jv2vobj = new IdentityHashMap(); + vobj2jv = new Hashtable(); + } + } + /** + * App's object binding to VorbaIds + */ + IdentityHashMap jv2vobj = null; + Hashtable vobj2jv = null; + /** + * called with a vamsas document which will be updated with new data from the app + * @param doc + */ + public void updateVamsasDocument(ClientDoc doc) { + ensureVamsasBindings(); + VamsasDatastore vds = new VamsasDatastore(doc, vobj2jv, jv2vobj, baseProvEntry()); + // wander through frames + vds.storeVAMSAS(new Object()); // Object is the apps datamodel ;) + } + /** + * + * @return a base provenance entry used by the VamsasDatastore object to get attributes from. this isn't particularly elegant either. + */ + private Entry baseProvEntry() { + org.vamsas.objects.core.Entry pentry = new org.vamsas.objects.core.Entry(); + pentry.setUser(this.getProvenanceUser()); + pentry.setApp(this.getClientHandle().getClientName()); + pentry.setDate(new org.exolab.castor.types.Date(new java.util.Date())); + pentry.setAction("created"); + return pentry; + } + protected class VamsasClientWatcher extends Thread implements Runnable { + /* (non-Javadoc) + * @see java.lang.Thread#run() + */ + VamsasClient client=null; + VamsasClientWatcher(VamsasClient client) { + this.client = client; + } + boolean running=false; + public void run() { + running=true; + while (client.watchForChange) { + ClientDoc docio = client.watch(0); + if (docio!=null) { + // VamsasClient GUI bits should be disabled whilst an update is in progress so the user doesn't screw anything up. + client.disableGui(true); + log.debug("Updating VamsasClient app from changed vamsas document."); + client.updateJalview(docio); + log.debug("Finished updating from document change."); + docio.closeDoc(); + docio=null; + client.disableGui(false); + } + } + running=false; + + } + + } + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + /** + * disable (if b is true) or enable (if b is true) the VamsasClient's vamsas session gui bits whilst a document change is being updated to the app. + * @param b + */ + public void disableGui(boolean b) { + // in jalview, we turn off the VAMSAS Session menu : Desktop.instance.setVamsasUpdate(b); + } + /** + * spawn a new thread to start the VamsasClientWatcher. + * + */ + public void startWatcher() { + if (watcher==null) + watcher=new VamsasClientWatcher(this); + Thread thr = new Thread() { + public void run() { + watcher.start(); + } + }; + thr.start(); + } + +} diff --git a/src/org/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java b/src/org/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java new file mode 100644 index 0000000..9114e88 --- /dev/null +++ b/src/org/vamsas/test/simpleclient/simpleapp/VamsasDatastore.java @@ -0,0 +1,333 @@ +/* + * VamsasClientSimpleApp - A framework for interoparable Sequence analysis + * Copyright (C) 2006 VAMSAS + * + * 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 org.vamsas.test.simpleclient.simpleapp; + +import org.vamsas.client.Vobject; +import org.vamsas.client.VorbaId; +import org.vamsas.objects.core.*; +import org.vamsas.objects.utils.DocumentStuff; +import org.vamsas.test.simpleclient.ClientDoc; + + +import java.io.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.IdentityHashMap; +import java.util.Vector; +import java.util.jar.*; +import org.exolab.castor.xml.*; +import org.exolab.castor.mapping.Mapping; + +/* + * + * static { + * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty( + * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); } + * + */ + +public class VamsasDatastore { + org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory.getLog(VamsasDatastore.class); + Entry provEntry = null; + + + org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( + new java.util.Date()); + + ClientDoc cdoc; + + Hashtable vobj2jv; + + IdentityHashMap jv2vobj; + + public VamsasDatastore(ClientDoc cdoc, Hashtable vobj2jv, + IdentityHashMap jv2vobj, Entry provEntry) { + this.cdoc = cdoc; + this.vobj2jv = vobj2jv; + this.jv2vobj = jv2vobj; + this.provEntry = provEntry; + } + + /* + * public void storeJalview(String file, AlignFrame af) { try { // 1. Load the + * mapping information from the file Mapping map = new + * Mapping(getClass().getClassLoader()); java.net.URL url = + * getClass().getResource("/jalview_mapping.xml"); map.loadMapping(url); // 2. + * Unmarshal the data // Unmarshaller unmar = new Unmarshaller(); + * //unmar.setIgnoreExtraElements(true); //unmar.setMapping(map); // uni = + * (UniprotFile) unmar.unmarshal(new FileReader(file)); // 3. marshal the data + * with the total price back and print the XML in the console Marshaller + * marshaller = new Marshaller( new FileWriter(file) ); + * + * marshaller.setMapping(map); marshaller.marshal(af); } catch (Exception e) { + * e.printStackTrace(); } } + * + * + */ + /** + * @return the Vobject bound to Jalview datamodel object + */ + protected Vobject getjv2vObj(Object jvobj) { + if (jv2vobj.containsKey(jvobj)) + return cdoc.getObject((VorbaId) jv2vobj.get(jvobj)); + return null; + } + + /** + * + * @param vobj + * @return Jalview datamodel object bound to the vamsas document object + */ + protected Object getvObj2jv(org.vamsas.client.Vobject vobj) { + VorbaId id = vobj.getVorbaId(); + if (id == null) + { + id = cdoc.registerObject(vobj); + log + .debug("Registering new object and returning null for getvObj2jv"); + return null; + } + if (vobj2jv.containsKey(vobj.getVorbaId())) + return vobj2jv.get(vobj.getVorbaId()); + return null; + } + + protected void bindjvvobj(Object jvobj, org.vamsas.client.Vobject vobj) { + VorbaId id = vobj.getVorbaId(); + if (id == null) + { + id = cdoc.registerObject(vobj); + if (id==null || vobj.getVorbaId()==null) + log.error("Failed to get id for "+(vobj.isRegisterable() ? "registerable" : "unregisterable") +" object "+vobj); + } + if (vobj2jv.containsKey(vobj.getVorbaId()) || jv2vobj.containsKey(jvobj)) + { + log.error("Duplicate object binding! "+vobj+" id " +vobj.getVorbaId().getId()+" to "+jvobj); + } + else + { + vobj2jv.put(vobj.getVorbaId(), jvobj);// JBPNote - better implementing a + // hybrid invertible hash. + jv2vobj.put(jvobj, vobj.getVorbaId()); + } + } + + /** + * put the alignment viewed by AlignViewport into cdoc. + * + * @param av + */ + public void storeVAMSAS(Object fromAppsDatamodel) { + boolean nw = false; + VAMSAS root = null; // will be resolved based on Dataset Parent. + DataSet dataset = (DataSet) getjv2vObj(fromAppsDatamodel); + if (dataset == null) + { + root = cdoc.getVamsasRoots()[0]; // default vamsas root for modifying. + dataset = new DataSet(); + root.addDataSet(dataset); + bindjvvobj(fromAppsDatamodel, dataset); + dataset.setProvenance(dummyProvenance()); + dataset.getProvenance().addEntry(provEntry); + nw = true; + } else { + root = (VAMSAS) dataset.getV_parent(); + } + // etc... + } + + private Property newProperty(String name, String type, String content) { + Property vProperty=new Property(); + vProperty.setName(name); + if (type!=null) + vProperty.setType(type); + vProperty.setContent(content); + return vProperty; + } + + /** + * get start0 && dseta.getPosCount()>0) + throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0) + { + se = getSegRange(dseta.getSeg(0),true); + for (int s = 1, sSize = dseta.getSegCount(); s < sSize; s++) + { + int nse[] = getSegRange(dseta.getSeg(s), true); + if (se[0] > nse[0]) + se[0] = nse[0]; + if (se[1] < nse[1]) + se[1] = nse[1]; + } + } + if (dseta.getPosCount() > 0) + { + // could do a polarity for pos range too. and pass back indication of discontinuities. + int pos = dseta.getPos(0).getI(); + se = new int[] { pos, pos }; + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) + { + pos = dseta.getPos(p).getI(); + if (se[0] > pos) + se[0] = pos; + if (se[1] < pos) + se[1] = pos; + } + } + return se; + } + return null; + } + /** + * map from a rangeType's internal frame to the referenced object's coordinate frame. + * @param dseta + * @return int [] { ref(pos)...} for all pos in rangeType's frame. + */ + private int[] getMapping(RangeType dseta) { + Vector posList=new Vector(); + if (dseta != null) + { + int[] se = null; + if (dseta.getSegCount()>0 && dseta.getPosCount()>0) + throw new Error("Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + if (dseta.getSegCount() > 0) + { + for (int s = 0, sSize = dseta.getSegCount(); s < sSize; s++) + { + se = getSegRange(dseta.getSeg(s), false); + int se_end=se[1-se[2]]+(se[2]==0 ? 1 : -1); + for (int p=se[se[2]]; p!=se_end; p+=se[2]==0 ? 1 : -1 ) { + posList.add(Integer.valueOf(p)); + } + } + } + else if (dseta.getPosCount() > 0) + { + int pos = dseta.getPos(0).getI(); + + for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++) + { + pos = dseta.getPos(p).getI(); + posList.add(Integer.valueOf(pos)); + } + } + } + if (posList!=null && posList.size()>0) { + int[] range=new int[posList.size()]; + for (int i=0; i