List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:edu.harvard.i2b2.fr.datavo.I2B2MessageResponseFactory.java
/** * Function to unmarshall i2b2 request message type * //from ww w. ja v a 2s. co m * @param requestXml * @return RequestMessageType * @throws JAXBUtilException */ private static RequestMessageType getI2B2RequestMessageType(String requestXml) throws JAXBUtilException { JAXBUtil jaxbUtil = FRJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(requestXml); RequestMessageType requestMessageType = (RequestMessageType) jaxbElement.getValue(); return requestMessageType; }
From source file:Main.java
public static <ValueType, BoundType> ValueType unmarshallJAXBElement( Class<? extends XmlAdapter<BoundType, ValueType>> xmlAdapterClass, JAXBElement<? extends BoundType> v) { try {/*from w ww . j ava2s . c o m*/ if (v == null) { return null; } else { final XmlAdapter<BoundType, ValueType> xmlAdapter = getXmlAdapter(xmlAdapterClass); return xmlAdapter.unmarshal(v.getValue()); } } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:fr.mael.microrss.util.XMLUtil.java
public static String readProperty(String name, List<Object> objects) { for (Object o : objects) { if (o instanceof JAXBElement) { JAXBElement element = (JAXBElement) o; if (name.equals(element.getName().getLocalPart())) { return String.valueOf(element.getValue()); }/*from ww w. ja v a2 s . co m*/ } else if (o instanceof ElementNSImpl) { ElementNSImpl element = (ElementNSImpl) o; if (name.equals(element.getNodeName())) { return element.getFirstChild().getNodeValue(); } } } return null; }
From source file:no.digipost.api.xml.Marshalling.java
public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final Node node, final Class<T> clazz) { try {//from ww w . j av a 2s. c o m JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller().unmarshal(node, clazz); return jaxbElement.getValue(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:ee.ria.xroad.common.message.SoapParserImpl.java
@SuppressWarnings("unchecked") static <T> T unmarshalHeader(Class<?> clazz, SOAPHeader soapHeader, boolean checkRequiredFields) throws Exception { Unmarshaller unmarshaller = JaxbUtils.createUnmarshaller(clazz); if (checkRequiredFields) { unmarshaller.setListener(new RequiredHeaderFieldsChecker(clazz)); }//from w ww. j a v a2s . c o m unmarshaller.setEventHandler(event -> { switch (event.getSeverity()) { case ValidationEvent.WARNING: return true; case ValidationEvent.ERROR: Throwable t = event.getLinkedException(); return !(t instanceof AccessorException && t.getCause() instanceof CodedException); case ValidationEvent.FATAL_ERROR: return false; default: return true; } }); JAXBElement<T> jaxbElement = (JAXBElement<T>) unmarshaller.unmarshal(soapHeader, clazz); return jaxbElement.getValue(); }
From source file:no.digipost.api.xml.Marshalling.java
public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final SoapHeaderElement header, final Class<T> clazz) { try {/*from www.j av a 2 s . co m*/ JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller() .unmarshal(header.getSource(), clazz); return jaxbElement.getValue(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:no.digipost.api.xml.Marshalling.java
public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final InputStream is, final Class<T> clazz) { try {//from ww w. ja v a 2 s . c om JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller() .unmarshal(new StreamSource(is), clazz); return jaxbElement.getValue(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:no.digipost.api.xml.Marshalling.java
public static <T> T unmarshal(final Jaxb2Marshaller jaxb2Marshaller, final SoapBody body, final Class<T> clazz) { try {/*from w w w .jav a 2 s.co m*/ JAXBElement<T> jaxbElement = jaxb2Marshaller.getJaxbContext().createUnmarshaller() .unmarshal(body.getPayloadSource(), clazz); return jaxbElement.getValue(); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:be.fedict.eid.tsl.TrustServiceListFactory.java
private static TrustStatusListType parseTslDocument(Document tslDocument) throws JAXBException { Unmarshaller unmarshaller = getUnmarshaller(); JAXBElement<TrustStatusListType> jaxbElement = (JAXBElement<TrustStatusListType>) unmarshaller .unmarshal(tslDocument);/* ww w .j av a2 s .c o m*/ TrustStatusListType trustServiceStatusList = jaxbElement.getValue(); return trustServiceStatusList; }
From source file:Main.java
public static <T> T converyToJavaBean(JAXBContext context, String xmlStr, Class<T> c) { JAXBElement<T> t = null; try {// w ww.j a va 2 s . c om Unmarshaller unmarshaller = context.createUnmarshaller(); t = (JAXBElement<T>) unmarshaller.unmarshal((new StreamSource(new StringReader(xmlStr))), c); } catch (Exception e) { e.printStackTrace(); } return t.getValue(); }