package forum10243679; import java.io.StringReader; import javax.xml.bind.*; import javax.xml.transform.stream.StreamSource; public class Demo { private static final String XML = "<root/>"; public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Root.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); JAXBIntrospector jaxbIntrospector = jc.createJAXBIntrospector(); Object object = unmarshaller.unmarshal(new StringReader(XML)); System.out.println(object.getClass()); System.out.println(jaxbIntrospector.getValue(object).getClass()); Object jaxbElement = unmarshaller.unmarshal(new StreamSource(new StringReader(XML)), Root.class); System.out.println(jaxbElement.getClass()); System.out.println(jaxbIntrospector.getValue(jaxbElement).getClass()); } }
JAXBIntrospector introspector = jc.createJAXBIntrospector(); Marshaller marshaller = jc.createMarshaller(); if(null == introspector.getElementName(value)) {
introspector = context.createJAXBIntrospector();
introspector = context.createJAXBIntrospector();
introspector = context.createJAXBIntrospector();
/** * @return {@link JAXBIntrospector} * @see javax.xml.bind.JAXBContext#createJAXBIntrospector() */ public JAXBIntrospector createJAXBIntrospector() { return wrappedContext.createJAXBIntrospector(); }
introspector = context.createJAXBIntrospector();
private QName getElementName(Class<?> parameterType, Object param) { try { JAXBContext context = JAXBContext.newInstance(parameterType); JAXBIntrospector introspector = context.createJAXBIntrospector(); return introspector.getElementName(param); } catch (JAXBException ex) { return null; } }
private QName getElementName(Class<?> parameterType, Object param) { try { JAXBContext context = JAXBContext.newInstance(parameterType); JAXBIntrospector introspector = context.createJAXBIntrospector(); return introspector.getElementName(param); } catch (JAXBException ex) { return null; } }
private JaxbStreamingPayload(Class<?> clazz, Object jaxbElement) throws JAXBException { JAXBContext jaxbContext = getJaxbContext(clazz); this.marshaller = jaxbContext.createMarshaller(); this.marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); this.jaxbElement = jaxbElement; JAXBIntrospector introspector = jaxbContext.createJAXBIntrospector(); this.name = introspector.getElementName(jaxbElement); }
private JaxbStreamingPayload(Class<?> clazz, Object jaxbElement) throws JAXBException { JAXBContext jaxbContext = getJaxbContext(clazz); this.marshaller = jaxbContext.createMarshaller(); this.marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); this.jaxbElement = jaxbElement; JAXBIntrospector introspector = jaxbContext.createJAXBIntrospector(); this.name = introspector.getElementName(jaxbElement); }
private JaxbStreamingPayload(Class<?> clazz, Object jaxbElement) throws JAXBException { JAXBContext jaxbContext = getJaxbContext(clazz); this.marshaller = jaxbContext.createMarshaller(); this.marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); this.jaxbElement = jaxbElement; JAXBIntrospector introspector = jaxbContext.createJAXBIntrospector(); this.name = introspector.getElementName(jaxbElement); }
private QName getElementName(Class<?> parameterType, Object param) { try { JAXBContext context = JAXBContext.newInstance(parameterType); JAXBIntrospector introspector = context.createJAXBIntrospector(); return introspector.getElementName(param); } catch (JAXBException ex) { return null; } }
private QName getElementName(Class<?> parameterType, Object param) { try { JAXBContext context = JAXBContext.newInstance(parameterType); JAXBIntrospector introspector = context.createJAXBIntrospector(); return introspector.getElementName(param); } catch (JAXBException ex) { return null; } }
public static boolean isMarshallable(String contextPath, Object object) { try { return object != null && (object instanceof Element || getJAXBContext(contextPath) .createJAXBIntrospector().isElement(object)); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
public static boolean isElement(String contextPath, Object object) { try { return object != null && getJAXBContext(contextPath).createJAXBIntrospector() .isElement(object); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
public static boolean isElement(String contextPath, Object object) { try { return object != null && getJAXBContext(contextPath).createJAXBIntrospector() .isElement(object); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
public static boolean isMarshallable(String contextPath, Object object) { try { return object != null && (object instanceof Element || getJAXBContext(contextPath) .createJAXBIntrospector().isElement(object)); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
public static boolean isMarshallableObject(String contextPath, Object object) { try { return object != null && (getJAXBContext(contextPath).createJAXBIntrospector() .isElement(object)); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
public static boolean isMarshallableObject(String contextPath, Object object) { try { return object != null && (getJAXBContext(contextPath).createJAXBIntrospector() .isElement(object)); } catch (JAXBException ex) { throw new RuntimeException(ex); } }