Java Code Examples for javax.xml.bind.annotation.adapters.XmlAdapter#marshal()
The following examples show how to use
javax.xml.bind.annotation.adapters.XmlAdapter#marshal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXBUtils.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public static Object useAdapter(Object obj, XmlJavaTypeAdapter typeAdapter, boolean marshal, Object defaultValue) { if (typeAdapter != null) { try { @SuppressWarnings("rawtypes") XmlAdapter xmlAdapter = typeAdapter.value().newInstance(); if (marshal) { return xmlAdapter.marshal(obj); } return xmlAdapter.unmarshal(obj); } catch (Exception ex) { LOG.log(Level.INFO, "(un)marshalling failed, using defaultValue", ex); } } return defaultValue; }
Example 2
Source File: AdaptedAccessor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 3
Source File: XmlAdapterUtils.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public static <ValueType, BoundType> JAXBElement<BoundType> marshallJAXBElement( Class<? extends XmlAdapter<BoundType, ValueType>> xmlAdapterClass, Class<BoundType> declaredType, QName name, Class<?> scope, ValueType v) { try { if (v == null) { return null; } else { final XmlAdapter<BoundType, ValueType> xmlAdapter = getXmlAdapter(xmlAdapterClass); return new JAXBElement<BoundType>(name, declaredType, scope, xmlAdapter.marshal(v)); } } catch (Exception ex) { throw new RuntimeException(ex); } }
Example 4
Source File: XmlAdapterUtils.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
public static <ValueType, BoundType> ValueType marshall( Class<? extends XmlAdapter<ValueType, BoundType>> xmlAdapterClass, BoundType v) { try { final XmlAdapter<ValueType, BoundType> xmlAdapter = getXmlAdapter(xmlAdapterClass); return xmlAdapter.marshal(v); } catch (Exception ex) { throw new RuntimeException(ex); } }
Example 5
Source File: AdaptedAccessor.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 6
Source File: BridgeAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 7
Source File: AdaptedAccessor.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 8
Source File: BridgeAdapter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 9
Source File: AdaptedAccessor.java From hottub with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 10
Source File: BridgeAdapter.java From hottub with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 11
Source File: AdaptedAccessor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 12
Source File: BridgeAdapter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 13
Source File: AdaptedAccessor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 14
Source File: BridgeAdapter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 15
Source File: BridgeAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 16
Source File: AdaptedAccessor.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public OnWireValueT get(BeanT bean) throws AccessorException { InMemValueT v = core.get(bean); XmlAdapter<OnWireValueT,InMemValueT> a = getAdapter(); try { return a.marshal(v); } catch (Exception e) { throw new AccessorException(e); } }
Example 17
Source File: BridgeAdapter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 18
Source File: BridgeAdapter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private OnWire _adaptM(XMLSerializer serializer, InMemory v) throws MarshalException { XmlAdapter<OnWire,InMemory> a = serializer.getAdapter(adapter); try { return a.marshal(v); } catch (Exception e) { serializer.handleError(e,v,null); throw new MarshalException(e); } }
Example 19
Source File: Utils.java From cxf with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) static Object getFieldValue(Field f, Object target) throws Exception { XmlJavaTypeAdapter adapterAnnotation = getFieldXJTA(f); XmlAdapter adapter = getXmlAdapter(adapterAnnotation); return adapter != null ? adapter.marshal(f.get(target)) : f.get(target); }
Example 20
Source File: Utils.java From cxf with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) static Object getMethodValue(Method m, Object target) throws Exception { XmlJavaTypeAdapter adapterAnnotation = getMethodXJTA(m); XmlAdapter adapter = getXmlAdapter(adapterAnnotation); return adapter != null ? adapter.marshal(m.invoke(target)) : m.invoke(target); }