Search in sources :

Example 1 with ValidationEventLocatorImpl

use of javax.xml.bind.helpers.ValidationEventLocatorImpl in project OpenAM by OpenRock.

the class SAXMarshaller method reconcileID.

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();
}
Also used : ValidationEventLocatorImpl(javax.xml.bind.helpers.ValidationEventLocatorImpl) Iterator(java.util.Iterator) NotIdentifiableEventImpl(javax.xml.bind.helpers.NotIdentifiableEventImpl) IdentifiableObject(com.sun.xml.bind.marshaller.IdentifiableObject)

Example 2 with ValidationEventLocatorImpl

use of javax.xml.bind.helpers.ValidationEventLocatorImpl in project OpenAM by OpenRock.

the class Util method handlePrintConversionException.

/**
     * Reports a print conversion error while marshalling.
     */
public static void handlePrintConversionException(Object caller, Exception e, XMLSerializer serializer) throws SAXException {
    if (e instanceof SAXException)
        //        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);
}
Also used : ValidationEvent(javax.xml.bind.ValidationEvent) ValidationEventLocatorImpl(javax.xml.bind.helpers.ValidationEventLocatorImpl) PrintConversionEventImpl(javax.xml.bind.helpers.PrintConversionEventImpl) SAXException(org.xml.sax.SAXException)

Example 3 with ValidationEventLocatorImpl

use of javax.xml.bind.helpers.ValidationEventLocatorImpl in project OpenAM by OpenRock.

the class ValidationContext method reconcileIDs.

/** 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()))
            // OK.
            continue;
        // 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();
}
Also used : ValidationEventLocatorImpl(javax.xml.bind.helpers.ValidationEventLocatorImpl) Iterator(java.util.Iterator) NotIdentifiableEventImpl(javax.xml.bind.helpers.NotIdentifiableEventImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ValidationEventLocatorImpl

use of javax.xml.bind.helpers.ValidationEventLocatorImpl in project OpenAM by OpenRock.

the class AbstractUnmarshallingEventHandlerImpl method handleParseConversionException.

/**
     * This method is called by the generated derived class
     * when a datatype parse method throws an exception.
     */
protected void handleParseConversionException(Exception e) throws SAXException {
    if (e instanceof RuntimeException)
        // don't catch the runtime exception. just let it go.
        throw (RuntimeException) e;
    // wrap it into a ParseConversionEvent and report it
    ParseConversionEvent pce = new ParseConversionEventImpl(ValidationEvent.ERROR, e.getMessage(), new ValidationEventLocatorImpl(context.getLocator()), e);
    context.handleEvent(pce, true);
}
Also used : ValidationEventLocatorImpl(javax.xml.bind.helpers.ValidationEventLocatorImpl) ParseConversionEventImpl(javax.xml.bind.helpers.ParseConversionEventImpl) ParseConversionEvent(javax.xml.bind.ParseConversionEvent)

Example 5 with ValidationEventLocatorImpl

use of javax.xml.bind.helpers.ValidationEventLocatorImpl in project OpenAM by OpenRock.

the class SAXMarshaller method reconcileID.

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();
}
Also used : ValidationEventLocatorImpl(javax.xml.bind.helpers.ValidationEventLocatorImpl) Iterator(java.util.Iterator) NotIdentifiableEventImpl(javax.xml.bind.helpers.NotIdentifiableEventImpl) IdentifiableObject(com.sun.xml.bind.marshaller.IdentifiableObject)

Aggregations

ValidationEventLocatorImpl (javax.xml.bind.helpers.ValidationEventLocatorImpl)20 NotIdentifiableEventImpl (javax.xml.bind.helpers.NotIdentifiableEventImpl)12 Iterator (java.util.Iterator)8 IdentifiableObject (com.sun.xml.bind.marshaller.IdentifiableObject)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ParseConversionEvent (javax.xml.bind.ParseConversionEvent)4 ValidationEvent (javax.xml.bind.ValidationEvent)4 ParseConversionEventImpl (javax.xml.bind.helpers.ParseConversionEventImpl)4 PrintConversionEventImpl (javax.xml.bind.helpers.PrintConversionEventImpl)4 SAXException (org.xml.sax.SAXException)4