use of javax.xml.bind.ValidationEvent in project OpenAM by OpenRock.
the class Util method handleTypeMismatchError.
/**
* Reports that the type of an object in a property is unexpected.
*/
public static void handleTypeMismatchError(XMLSerializer serializer, Object parentObject, String fieldName, Object childObject) throws AbortSerializationException {
ValidationEvent ve = new ValidationEventImpl(// maybe it should be a fatal error.
ValidationEvent.ERROR, Messages.format(Messages.ERR_TYPE_MISMATCH, getUserFriendlyTypeName(parentObject), fieldName, getUserFriendlyTypeName(childObject)), new ValidationEventLocatorExImpl(parentObject, fieldName));
serializer.reportError(ve);
}
use of javax.xml.bind.ValidationEvent 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);
}
use of javax.xml.bind.ValidationEvent in project OpenAM by OpenRock.
the class Util method handleTypeMismatchError.
/**
* Reports that the type of an object in a property is unexpected.
*/
public static void handleTypeMismatchError(XMLSerializer serializer, Object parentObject, String fieldName, Object childObject) throws AbortSerializationException {
ValidationEvent ve = new ValidationEventImpl(// maybe it should be a fatal error.
ValidationEvent.ERROR, Messages.format(Messages.ERR_TYPE_MISMATCH, getUserFriendlyTypeName(parentObject), fieldName, getUserFriendlyTypeName(childObject)), new ValidationEventLocatorExImpl(parentObject, fieldName));
serializer.reportError(ve);
}
use of javax.xml.bind.ValidationEvent in project OpenAM by OpenRock.
the class Util method handleTypeMismatchError.
/**
* Reports that the type of an object in a property is unexpected.
*/
public static void handleTypeMismatchError(XMLSerializer serializer, Object parentObject, String fieldName, Object childObject) throws AbortSerializationException {
ValidationEvent ve = new ValidationEventImpl(// maybe it should be a fatal error.
ValidationEvent.ERROR, Messages.format(Messages.ERR_TYPE_MISMATCH, getUserFriendlyTypeName(parentObject), fieldName, getUserFriendlyTypeName(childObject)), new ValidationEventLocatorExImpl(parentObject, fieldName));
serializer.reportError(ve);
}
use of javax.xml.bind.ValidationEvent in project OpenAM by OpenRock.
the class Utils method convertJAXBToElement.
/**
* Converts a JAXB object to a <code>org.w3c.dom.Element</code>.
*
* @param jaxbObj a JAXB object
* @return a <code>org.w3c.dom.Element</code>
* @throws JAXBException if an error occurs while converting JAXB object.
* @supported.api
*/
public static Element convertJAXBToElement(Object jaxbObj, boolean checkIdref) throws JAXBException {
Marshaller m = jc.createMarshaller();
try {
m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapperImpl());
} catch (PropertyException ex) {
debug.error("Utils.convertJAXBToElement", ex);
}
if (!checkIdref) {
m.setEventHandler(new DefaultValidationEventHandler() {
public boolean handleEvent(ValidationEvent event) {
if (event instanceof NotIdentifiableEvent) {
return true;
}
return super.handleEvent(event);
}
});
}
Document doc = null;
try {
doc = XMLUtils.newDocument();
} catch (Exception ex) {
debug.error("Utils.convertJAXBToElement:", ex);
}
m.marshal(jaxbObj, doc);
return doc.getDocumentElement();
}
Aggregations