+ 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 object is present in Vamsas Document.
+ */
+ public boolean is__stored_in_document() {
+ return __stored_in_document;
+ }
+
+ /**
+ * for use by Vorba agent to reflect state of vamsas object to client
+ * application.
+ * Setting stored_in_document on a registerable object without a
+ * vorbaId will mean is will *never* get a vorbaId and
+ * horrible things will happen.
+ * @param __stored_in_document true if object 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 object was last checked
+ * against a IClientDocument generated by the object's parent IClient
+ * instance.
+ *
+ * @return Returns the __last_hash.
+ */
+ public long get__last_hash() {
+ return __last_hash;
+ }
+
+ /**
+ * @return true if object can have a vorbaId
+ */
+ public boolean isRegisterable() {
+ return registerable;
+ }
+
+ /**
+ * Called by __testInstanceForidField and the post-unmarshalling handler
+ * to indicate if object 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 object
+ * 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.
+ * The doHash() function is 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() {
+ if (__vorba==null)
+ throw new Error("Improperly intialised org.vamsas.client.object - no VorbaFactory given.");
+ log.debug("doing "+this.getClass()+".__ensure_instance_ids()");
+ if (!__stored_in_document && registerable)
+ setInstanceIdField();
+ if (!doHash())
+ return; // nothing has changed in this object - probably visited it before.
+ Class descriptor = null;
+ XMLClassDescriptorImpl descimpl = null;
+ try {
+ // castor descriptor resolver magic
+ descriptor = this.getClass().getClassLoader().loadClass(this.getClass().getName()+"Descriptor");
+ descimpl = (XMLClassDescriptorImpl) descriptor.getConstructor(null).newInstance(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;