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(); }
protected final void handleStartDocument(NamespaceContext nsc) throws SAXException { visitor.startDocument(new LocatorEx() { public ValidationEventLocator getLocation() { return new ValidationEventLocatorImpl(this); } public int getColumnNumber() { return getCurrentLocation().getColumnNumber(); } public int getLineNumber() { return getCurrentLocation().getLineNumber(); } public String getPublicId() { return getCurrentLocation().getPublicId(); } public String getSystemId() { return getCurrentLocation().getSystemId(); } },nsc); }
/** 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(); }
/** * Reports a print conversion error while marshalling. */ public static void handlePrintConversionException( Object caller, Exception e, XMLSerializer serializer ) throws SAXException { if( e instanceof SAXException ) // assume this exception is not from application. // (e.g., when a marshaller aborts the processing, this exception // will be thrown) throw (SAXException)e; String message = e.getMessage(); if(message==null) { message = e.toString(); } ValidationEvent ve = new PrintConversionEventImpl( ValidationEvent.ERROR, message, new ValidationEventLocatorImpl(caller), e ); serializer.reportError(ve); }
/** * Called when a referenced object doesn't have an ID. */ public void errorMissingId(Object obj) throws SAXException { reportError( new ValidationEventImpl( ValidationEvent.ERROR, Messages.MISSING_ID.format(obj), new ValidationEventLocatorImpl(obj)) ); }
@Override protected boolean validateContent() { if (this.content == null) return false; RenderingMethodDescriptor erm = (RenderingMethodDescriptor) this.content; File shader_dir = null; String all_shaders = ":"; shader_dir = new File(SHADER_PATH); if (shader_dir.exists() && shader_dir.isDirectory()) { for (File f : shader_dir.listFiles()) { all_shaders += f.getName() + ":"; } } // Check that the shaders exist. boolean success = true; for (ShaderRef shader : erm.lshaderref) { if (!all_shaders.contains(shader.location.toString())) { String error_msg = "The shader named " + shader.location.toString() + " doesn't exist or cannot be read in the shader directory " + (shader_dir == null ? "<null>" : shader_dir.getPath()) + "."; ValidationEventLocatorImpl locator = new ValidationEventLocatorImpl(erm); this.eventHandler.handleEvent(new SLDValidationEvent(ValidationEvent.FATAL_ERROR, error_msg, ll.getLocation(erm))); success = false; } } // TODO : check if the parameters types and their restrictions are // valid. return success; }
/** * Reports a print conversion error while marshalling. */ public static void handlePrintConversionException( Object caller, Exception e, XMLSerializer serializer ) throws SAXException { if( e instanceof SAXException ) // assume this exception is not from application. // (e.g., when a marshaller aborts the processing, this exception // will be thrown) throw (SAXException)e; ValidationEvent ve = new PrintConversionEventImpl( ValidationEvent.ERROR, e.getMessage(), new ValidationEventLocatorImpl(caller), e ); serializer.reportError(ve); }