Example usage for javax.xml.bind Marshaller setEventHandler

List of usage examples for javax.xml.bind Marshaller setEventHandler

Introduction

In this page you can find the example usage for javax.xml.bind Marshaller setEventHandler.

Prototype

public void setEventHandler(ValidationEventHandler handler) throws JAXBException;

Source Link

Document

Allow an application to register a validation event handler.

Usage

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link Continent} as XML into an {@link OutputStream}.
 * <p>/*from w  w  w.  jav  a 2 s .  c  om*/
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param continent
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(Continent continent, Marshaller marshaller, OutputStream output)
        throws JAXBException {
    final org.openestate.is24.restapi.xml.gis.ObjectFactory factory = new org.openestate.is24.restapi.xml.gis.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createContinent(continent), output);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link Country} as XML into an {@link OutputStream}.
 * <p>/* w w  w . j  ava2 s  .c  o  m*/
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param country
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(Country country, Marshaller marshaller, OutputStream output) throws JAXBException {
    final org.openestate.is24.restapi.xml.gis.ObjectFactory factory = new org.openestate.is24.restapi.xml.gis.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createCountry(country), output);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link PublishObject} as XML into an {@link OutputStream}.
 * <p>/*from ww w . java2 s. c o m*/
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param publishing
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(PublishObject publishing, Marshaller marshaller, OutputStream output)
        throws JAXBException {
    final org.openestate.is24.restapi.xml.common.ObjectFactory factory = new org.openestate.is24.restapi.xml.common.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createPublishObject(publishing), output);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link Quarter} as XML into an {@link OutputStream}.
 * <p>/*from  w w w  . ja  va  2s .  c  o m*/
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param quarter
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(Quarter quarter, Marshaller marshaller, OutputStream output) throws JAXBException {
    final org.openestate.is24.restapi.xml.gis.ObjectFactory factory = new org.openestate.is24.restapi.xml.gis.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createQuarter(quarter), output);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link RealtorContactDetails} as XML into an {@link OutputStream}.
 * <p>//from   w  w  w.  j  a  v a  2  s  . c  o m
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param contact
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(RealtorContactDetails contact, Marshaller marshaller, OutputStream output)
        throws JAXBException {
    final org.openestate.is24.restapi.xml.common.ObjectFactory factory = new org.openestate.is24.restapi.xml.common.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createRealtorContactDetail(contact), output);
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link RealEstate} as XML into an {@link OutputStream}.
 * <p>//from   w  w  w.  jav  a  2s.c  o m
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param realEstate
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(RealEstate realEstate, Marshaller marshaller, OutputStream output)
        throws JAXBException {
    final org.openestate.is24.restapi.xml.realestates.ObjectFactory factory = new org.openestate.is24.restapi.xml.realestates.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    if (realEstate instanceof ApartmentBuy) {
        marshaller.marshal(factory.createApartmentBuy((ApartmentBuy) realEstate), output);
    } else if (realEstate instanceof ApartmentRent) {
        marshaller.marshal(factory.createApartmentRent((ApartmentRent) realEstate), output);
    } else if (realEstate instanceof AssistedLiving) {
        marshaller.marshal(factory.createAssistedLiving((AssistedLiving) realEstate), output);
    } else if (realEstate instanceof CompulsoryAuction) {
        marshaller.marshal(factory.createCompulsoryAuction((CompulsoryAuction) realEstate), output);
    } else if (realEstate instanceof FlatShareRoom) {
        marshaller.marshal(factory.createFlatShareRoom((FlatShareRoom) realEstate), output);
    } else if (realEstate instanceof GarageBuy) {
        marshaller.marshal(factory.createGarageBuy((GarageBuy) realEstate), output);
    } else if (realEstate instanceof GarageRent) {
        marshaller.marshal(factory.createGarageRent((GarageRent) realEstate), output);
    } else if (realEstate instanceof Gastronomy) {
        marshaller.marshal(factory.createGastronomy((Gastronomy) realEstate), output);
    } else if (realEstate instanceof HouseBuy) {
        marshaller.marshal(factory.createHouseBuy((HouseBuy) realEstate), output);
    } else if (realEstate instanceof HouseRent) {
        marshaller.marshal(factory.createHouseRent((HouseRent) realEstate), output);
    } else if (realEstate instanceof HouseType) {
        marshaller.marshal(factory.createHouseType((HouseType) realEstate), output);
    } else if (realEstate instanceof Industry) {
        marshaller.marshal(factory.createIndustry((Industry) realEstate), output);
    } else if (realEstate instanceof Investment) {
        marshaller.marshal(factory.createInvestment((Investment) realEstate), output);
    } else if (realEstate instanceof LivingBuySite) {
        marshaller.marshal(factory.createLivingBuySite((LivingBuySite) realEstate), output);
    } else if (realEstate instanceof LivingRentSite) {
        marshaller.marshal(factory.createLivingRentSite((LivingRentSite) realEstate), output);
    } else if (realEstate instanceof Office) {
        marshaller.marshal(factory.createOffice((Office) realEstate), output);
    } else if (realEstate instanceof SeniorCare) {
        marshaller.marshal(factory.createSeniorCare((SeniorCare) realEstate), output);
    } else if (realEstate instanceof ShortTermAccommodation) {
        marshaller.marshal(factory.createShortTermAccommodation((ShortTermAccommodation) realEstate), output);
    } else if (realEstate instanceof SpecialPurpose) {
        marshaller.marshal(factory.createSpecialPurpose((SpecialPurpose) realEstate), output);
    } else if (realEstate instanceof Store) {
        marshaller.marshal(factory.createStore((Store) realEstate), output);
    } else if (realEstate instanceof TradeSite) {
        marshaller.marshal(factory.createTradeSite((TradeSite) realEstate), output);
    } else {
        marshaller.marshal(factory.createRealEstate(realEstate), output);
    }
}

From source file:org.openestate.is24.restapi.utils.XmlUtils.java

/**
 * Write a {@link Region} as XML into an {@link OutputStream}.
 * <p>/*from   www  . j  a  va 2  s .c  o m*/
 * The provided object is wrapped into a {@link JAXBElement} before XML
 * creation in order to match the requirements of the schema.
 * <p>
 * This method makes sure, that validation errors do not break XML creation.
 * Invalid entries are not written into XML.
 *
 * @param region
 * object to write
 *
 * @param marshaller
 * marshaller, that is used for XML generation
 *
 * @param output
 * stream, where the XML is written to
 *
 * @throws JAXBException
 * if an error occured during XML creation
 */
public static void writeXml(Region region, Marshaller marshaller, OutputStream output) throws JAXBException {
    final org.openestate.is24.restapi.xml.gis.ObjectFactory factory = new org.openestate.is24.restapi.xml.gis.ObjectFactory();

    marshaller.setEventHandler(new ValidationEventHandler() {
        @Override
        public boolean handleEvent(ValidationEvent ve) {
            return true;
        }
    });

    marshaller.marshal(factory.createRegion(region), output);
}

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 #setMarshallerProperties(Map) defined properties}, the {@link
 * #setValidationEventHandler(ValidationEventHandler) validation event handler}, the {@link #setSchemas(Resource[])
 * schemas}, {@link #setMarshallerListener(javax.xml.bind.Marshaller.Listener) listener}, and
 * {@link #setAdapters(XmlAdapter[]) adapters}.
 *///ww  w. j a v a  2s. com
protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException {
    if (this.marshallerProperties != null) {
        for (String name : this.marshallerProperties.keySet()) {
            marshaller.setProperty(name, this.marshallerProperties.get(name));
        }
    }
    if (this.marshallerListener != null) {
        marshaller.setListener(this.marshallerListener);
    }
    if (this.validationEventHandler != null) {
        marshaller.setEventHandler(this.validationEventHandler);
    }
    if (this.adapters != null) {
        for (XmlAdapter<?, ?> adapter : this.adapters) {
            marshaller.setAdapter(adapter);
        }
    }
    if (this.schema != null) {
        marshaller.setSchema(this.schema);
    }
}