Example usage for javax.xml.bind JAXBContext newInstance

List of usage examples for javax.xml.bind JAXBContext newInstance

Introduction

In this page you can find the example usage for javax.xml.bind JAXBContext newInstance.

Prototype

public static JAXBContext newInstance(Class<?>... classesToBeBound) throws JAXBException 

Source Link

Document

Create a new instance of a JAXBContext class.

Usage

From source file:eu.hydrologis.jgrass.featureeditor.utils.Utilities.java

/**
 * Parse a form xml./*from   w w w  . java 2 s. c om*/
 * 
 * @param xml the xml containing the form definition. 
 * @return the {@link AForm}.
 * @throws Exception
 */
public static AForm parseXML(String xml) throws Exception {
    JAXBContext jc = JAXBContext.newInstance("eu.hydrologis.jgrass.featureeditor.xml.annotated"); //$NON-NLS-1$
    Unmarshaller um = jc.createUnmarshaller();
    StringReader sr = new StringReader(xml);
    return (AForm) um.unmarshal(sr);
}

From source file:com.kurtraschke.wsf.gtfsrealtime.services.WSFVesselLocationService.java

public WSFVesselLocationService() throws JAXBException {
    JAXBContext jc = JAXBContext.newInstance(ArrayOfVesselLocationResponse.class);
    _um = jc.createUnmarshaller();//w w  w  . ja  v  a 2 s .  c o m
}

From source file:eu.impress.repository.service.BedAvailabilityServiceImpl.java

@Override
public String getBedAvailablityHAVE(String hospitalname) {

    String hospitalstatushave;//from  w  w w . ja  v a  2  s . c  o  m
    BedStats bedStats = bedService.getHospitalAvailableBeds(hospitalname);
    HospitalStatus hospitalStatus = beansTransformation.BedStatstoHAVE(bedStats);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(HospitalStatus.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        //marshal the envelope 
        jaxbMarshaller.marshal(hospitalStatus, sw);
        hospitalstatushave = sw.toString();

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object";
    }

    return hospitalstatushave;

}

From source file:se.inera.intyg.intygstjanst.web.integration.stub.SendMedicalCertificateAnswerResponderStub.java

public SendMedicalCertificateAnswerResponderStub() {
    try {/*from w w  w. j av  a2s  . c  o  m*/
        jaxbContext = JAXBContext.newInstance(SendMedicalCertificateAnswerType.class);
    } catch (JAXBException e) {
        throw Throwables.propagate(e);
    }
}