Example usage for javax.xml.bind Unmarshaller setListener

List of usage examples for javax.xml.bind Unmarshaller setListener

Introduction

In this page you can find the example usage for javax.xml.bind Unmarshaller setListener.

Prototype

public void setListener(Listener listener);

Source Link

Document

Register unmarshal event callback Listener with this Unmarshaller .

Usage

From source file:org.springframework.oxm.jaxb.Jaxb2Marshaller.java

/**
 * Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior.
 * Gets called after creation of JAXB {@code Marshaller}, and after the respective properties have been set.
 * <p>The default implementation sets the {@link #setUnmarshallerProperties(Map) defined properties}, the {@link
 * #setValidationEventHandler(ValidationEventHandler) validation event handler}, the {@link #setSchemas(Resource[])
 * schemas}, {@link #setUnmarshallerListener(javax.xml.bind.Unmarshaller.Listener) listener}, and
 * {@link #setAdapters(XmlAdapter[]) adapters}.
 *//*from w  ww .jav a  2 s . co m*/
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {
    if (this.unmarshallerProperties != null) {
        for (String name : this.unmarshallerProperties.keySet()) {
            unmarshaller.setProperty(name, this.unmarshallerProperties.get(name));
        }
    }
    if (this.unmarshallerListener != null) {
        unmarshaller.setListener(this.unmarshallerListener);
    }
    if (this.validationEventHandler != null) {
        unmarshaller.setEventHandler(this.validationEventHandler);
    }
    if (this.adapters != null) {
        for (XmlAdapter<?, ?> adapter : this.adapters) {
            unmarshaller.setAdapter(adapter);
        }
    }
    if (this.schema != null) {
        unmarshaller.setSchema(this.schema);
    }
}