if (newobj instanceof Vobject) {
Vobject nobj = (Vobject) newobj;
nobj.set__stored_in_document(true);
- Field fd = null;
try {
if (nobj.isRegisterable() && nobj.___id_field!=null) {
// look for the id field (should be an NCName string)
nobj.__vorba = vorbafactory;
- fd = nobj.___id_field;
// use the Vobject accessor method to avoid unpleasant security exceptions.
String idstring = nobj.__getInstanceIdField();
if (idstring!=null) {
if (idstring.length() > 0) {
- if (!objrefs.containsKey(idstring)) {
- objrefs.put(idstring, nobj);
- nobj.setVorbaId(VorbaId.newId(idstring));
- } else {
+ nobj.setVorbaId(VorbaId.newId(idstring));
+ if (objrefs.containsKey(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.getVorbaId(), nobj);
} else {
// add to list of objects without a valid vorbaId
obj.add(nobj);
// forces registration and id field update.
VorbaId id = o.getVorbaId();
if (!objrefs.containsKey(id)) {
- objrefs.put(id.id, o);
+ objrefs.put(id, o);
} else {
- throw new Error("Serious! Duplicate reference made by vorbaIdFactory!");
+ if (!objrefs.get(id).equals(o))
+ throw new Error("Serious! Duplicate reference made by vorbaIdFactory!");
}
}
}
* @return null or {(Object) VamsasDocument Vobject, (Object) Hashtable of Vobject references, (Object) Boolean(sync) }
*/
public static Object[] getVamsasObjects(Reader instream,
- IVorbaIdFactory factory, Vobject root) {
+ VorbaIdFactory factory, Vobject root) {
Unmarshaller unmarshaller = new Unmarshaller(root);
unmarshaller.setIDResolver(new IDResolver() {
public Object resolve(String id) {
Hashtable refbase = new Hashtable();
Vector unrefed = new Vector();
final Hashtable objrefs = refbase;
- final IVorbaIdFactory vorbafactory = factory;
+ final VorbaIdFactory vorbafactory = factory;
final Vector unrefedObj = unrefed;
unmarshaller.setUnmarshalListener(new VorbaXmlBinder(vorbafactory, unrefedObj, objrefs));
// Call the unmarshaller.
boolean sync=ensure_references(unrefed, 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)};
}
} catch (MarshalException e) {