Java XML JAXB Unmarshaller unMarshallRequest(String xmlString)

Here you can find the source of unMarshallRequest(String xmlString)

Description

un Marshall Request

License

Apache License

Declaration

public static Object unMarshallRequest(String xmlString) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayInputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

import javax.xml.bind.Unmarshaller;

public class Main {
    private static JAXBContext jaxbRequestContext = null;

    public static Object unMarshallRequest(String xmlString) {
        Object request = null;/*www  .  j  a  v a2  s . c  o  m*/
        try {
            Unmarshaller um = getRequestContext().createUnmarshaller();
            request = um.unmarshal(new ByteArrayInputStream(xmlString.getBytes()));

        } catch (JAXBException je) {
            je.printStackTrace();
        }
        return request;
    }

    private static JAXBContext getRequestContext() {
        try {
            if (jaxbRequestContext == null)
                jaxbRequestContext = JAXBContext.newInstance("flowers.salta.resource.request");
        } catch (JAXBException je) {
            je.printStackTrace();
        }
        return jaxbRequestContext;
    }
}

Related

  1. unmarshall(String xml, Class clazz)
  2. unmarshall(String xml, URL schemaURL, Class... classesToBeBound)
  3. unmarshaller(Class entityType, InputStream in)
  4. unmarshaller(String xml, Class T)
  5. unmarshallJAXBElement(JAXBElement v)
  6. unmarshallString(String str, Class c)
  7. unmarshallXml(final String string, final Class type)
  8. unmarshallXMLtoObject(final byte[] xmlObject, final Class objectClass, final URL schemaURL)
  9. unmarshalObject(final InputStream input, final Class clazz)