public String onIDREF( Object obj ) throws SAXException { String id; try { id = getIdFromObject(obj); } catch (JAXBException e) { reportError(null,e); return null; // recover by returning null } idReferencedObjects.add(obj); if(id==null) { reportError( new NotIdentifiableEventImpl( ValidationEvent.ERROR, Messages.NOT_IDENTIFIABLE.format(), new ValidationEventLocatorImpl(obj) ) ); } return id; }
void reconcileID() throws SAXException { // find objects that were not a part of the object graph idReferencedObjects.removeAll(objectsWithId); for( Object idObj : idReferencedObjects ) { try { String id = getIdFromObject(idObj); reportError( new NotIdentifiableEventImpl( ValidationEvent.ERROR, Messages.DANGLING_IDREF.format(id), new ValidationEventLocatorImpl(idObj) ) ); } catch (JAXBException e) { // this error should have been reported already. just ignore here. } } // clear the garbage idReferencedObjects.clear(); objectsWithId.clear(); }
/** Tests if all IDREFs have corresponding IDs. */ protected void reconcileIDs() throws SAXException { if(!validateID) return; for (Iterator itr = IDREFs.entrySet().iterator(); itr.hasNext();) { Map.Entry e = (Map.Entry) itr.next(); if(IDs.contains(e.getKey())) continue; // OK. // ID was not found. ValidatableObject source = (ValidatableObject)e.getValue(); reportEvent( source, new NotIdentifiableEventImpl( ValidationEvent.ERROR, Messages.format( Messages.ID_NOT_FOUND, e.getKey() ), new ValidationEventLocatorImpl( source ) ) ); } IDREFs.clear(); }
void reconcileID() throws AbortSerializationException { // find objects that were not a part of the object graph idReferencedObjects.removeAll(objectsWithId); for( Iterator itr=idReferencedObjects.iterator(); itr.hasNext(); ) { IdentifiableObject o = (IdentifiableObject)itr.next(); reportError( new NotIdentifiableEventImpl( ValidationEvent.ERROR, Messages.format(Messages.ERR_DANGLING_IDREF,o.____jaxb____getId()), new ValidationEventLocatorImpl(o) ) ); } // clear the garbage idReferencedObjects.clear(); objectsWithId.clear(); }
public String onIDREF( IdentifiableObject obj ) throws SAXException { idReferencedObjects.add(obj); String id = obj.____jaxb____getId(); if(id==null) { reportError( new NotIdentifiableEventImpl( ValidationEvent.ERROR, Messages.format(Messages.ERR_NOT_IDENTIFIABLE), new ValidationEventLocatorImpl(obj) ) ); } return id; }