/** * If an object is wrapped in a JAXBElement, return the object. * Warning: be careful with this. If you are copying objects * into your document (rather than just reading them), you'll * probably want the object to remain wrapped (JAXB usually wraps them * for a reason; without the wrapper, you'll (probably?) need an * @XmlRootElement annotation in order to be able to marshall ie save your * document). * * @param o * @return */ public static Object unwrap(Object o) { if (o==null) return null; if (o instanceof javax.xml.bind.JAXBElement) { log.debug("Unwrapped " + ((JAXBElement)o).getDeclaredType().getName() ); log.debug("name: " + ((JAXBElement)o).getName() ); return ((JAXBElement)o).getValue(); } else { return o; } /* * Interestingly, DocumentSettingsPart (settings.xml) gets unwrapped, * and CTSettings does not have @XmlRootElement, but this does * not cause a problem when it is marshalled. */ }
public void serializeBody(JAXBElement e, XMLSerializer target, Object outerPeer) throws SAXException, IOException, XMLStreamException { Class scope = e.getScope(); if(e.isGlobalScope()) scope = null; QName n = e.getName(); ElementBeanInfoImpl bi = grammar.getElement(scope,n); if(bi==null) { tbi = grammar.getBeanInfo(e.getDeclaredType(),true); } catch (JAXBException x) { return; Object value = e.getValue(); target.startElement(n.getNamespaceURI(),n.getLocalPart(),n.getPrefix(),null); if(value==null) {
public void serializeBody(JAXBElement e, XMLSerializer target, Object outerPeer) throws SAXException, IOException, XMLStreamException { Class scope = e.getScope(); if(e.isGlobalScope()) scope = null; QName n = e.getName(); ElementBeanInfoImpl bi = grammar.getElement(scope,n); if(bi==null) { tbi = grammar.getBeanInfo(e.getDeclaredType(),true); } catch (JAXBException x) { return; Object value = e.getValue(); target.startElement(n.getNamespaceURI(),n.getLocalPart(),n.getPrefix(),null); if(value==null) {
private String getInstrText(R run) { List<Object> rContent = run.getContent(); Object item = null; Text text = null; for (int i=0; i<rContent.size(); i++) { item = rContent.get(i); if (item instanceof JAXBElement && ((JAXBElement)item).getName().equals(_RInstrText_QNAME)) { text = (Text)((JAXBElement)item).getValue(); break; } } return (text != null ? text.getValue() : null); }
private void assertJaxbElement(JAXBElement jaxbElement, QName name, Class<?> clazz) { assertEquals("Wrong JAXB element name", name, jaxbElement.getName()); assertEquals("Wrong JAXB element declared type", clazz, jaxbElement.getDeclaredType()); assertEquals("Wrong JAXB element value type", clazz, jaxbElement.getValue().getClass()); }
/** * Creates and returns a deep copy of a given {@code javax.xml.bind.JAXBElement<java.lang.String>} instance. * * @param e * The instance to copy or {@code null}. * @return * A deep copy of {@code e} or {@code null} if {@code e} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement<String> copyOfStringElement(final JAXBElement<String> e) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (e!= null) { final JAXBElement<String> copy = new JAXBElement<>(e.getName(), e.getDeclaredType(), e.getScope(), e.getValue()); copy.setNil(e.isNil()); // CBuiltinLeafInfo: java.lang.String copy.setValue(((String) copy.getValue())); return copy; } return null; }
@Nullable public static <DATATYPE> JAXBElement <DATATYPE> getClonedJAXBElement (@Nullable final JAXBElement <DATATYPE> aObj) { if (aObj == null) return null; final DATATYPE aClonedValue = CloneHelper.getClonedValue (aObj.getValue ()); final JAXBElement <DATATYPE> ret = new JAXBElement <> (aObj.getName (), aObj.getDeclaredType (), aObj.getScope (), aClonedValue); ret.setNil (aObj.isNil ()); return ret; } }
qName = defs1element.getName(); defs2value = findTrValue(defs2, qName); if (defs2value == null) qNameLocal = qName.getLocalPart(); if ("gridAfter".equals(qNameLocal)) { if (!areEqual((GridAfter)defs1element.getValue(), (GridAfter)defs2value)) return false; if (!areEqual((BooleanDefaultTrue)defs1element.getValue(), (BooleanDefaultTrue)defs2value)) return false; if (!areEqual((TblWidth)defs1element.getValue(), (TblWidth)defs2value)) return false;
/** * Creates and returns a deep copy of a given {@code javax.xml.bind.JAXBElement<java.lang.String>} instance. * * @param e * The instance to copy or {@code null}. * @return * A deep copy of {@code e} or {@code null} if {@code e} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement<String> copyOfStringElement(final JAXBElement<String> e) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (e!= null) { final JAXBElement<String> copy = new JAXBElement<>(e.getName(), e.getDeclaredType(), e.getScope(), e.getValue()); copy.setNil(e.isNil()); // CBuiltinLeafInfo: java.lang.String copy.setValue(((String) copy.getValue())); return copy; } return null; }
/** * Creates and returns a deep copy of a given {@code JAXBElement} instance. * * @param element * The instance to copy or {@code null}. * @return * A deep copy of {@code element} or {@code null} if {@code element} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement copyOf(final JAXBElement element) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (element!= null) { final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue()); copy.setNil(element.isNil()); copy.setValue(copyOf(copy.getValue())); return copy; } return null; }
if (wrapped != null) if (!wrapped.map().equals(ele.getName().getLocalPart())) throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedLocalPart(wrapped.map(), ele.getName().getLocalPart())); if (!wrapped.namespace().equals(ele.getName().getNamespaceURI())) throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI())); jaxbMap = ele.getValue();
@SuppressWarnings({ "unchecked", "rawtypes" }) private JAXBElement<?> doDuplicateJAXBElement(JAXBElement<?> originalObject) { if (originalObject == null) return null; final JAXBElement<?> sourceElement = (JAXBElement<?>) originalObject; final Object sourceObject = sourceElement.getValue(); final Object copyObject = doDuplicate(sourceObject); final JAXBElement copyElement = new JAXBElement( sourceElement.getName(), sourceElement.getDeclaredType(), sourceElement.getScope(), copyObject); return copyElement; }
if (wrapped != null) if (!wrapped.element().equals(ele.getName().getLocalPart())) throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedLocalPart(wrapped.element(), ele.getName().getLocalPart())); if (!wrapped.namespace().equals(ele.getName().getNamespaceURI())) throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI())); col = ele.getValue();
/** * Creates and returns a deep copy of a given {@code JAXBElement} instance. * * @param element * The instance to copy or {@code null}. * @return * A deep copy of {@code element} or {@code null} if {@code element} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement copyOf(final JAXBElement element) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (element!= null) { final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue()); copy.setNil(element.isNil()); copy.setValue(copyOf(copy.getValue())); return copy; } return null; }
private RequestedSecurityTokenType getRequestedSecurityToken(RequestSecurityTokenResponseType response) { for (Object obj : response.getAny()) { if (obj instanceof JAXBElement<?>) { JAXBElement<?> jaxbElement = (JAXBElement<?>)obj; if ("RequestedSecurityToken".equals(jaxbElement.getName().getLocalPart())) { return (RequestedSecurityTokenType)jaxbElement.getValue(); } } } return null; }
/** * Creates and returns a deep copy of a given {@code JAXBElement} instance. * * @param element * The instance to copy or {@code null}. * @return * A deep copy of {@code element} or {@code null} if {@code element} is {@code null}. */ @SuppressWarnings("unchecked") private static JAXBElement copyOf(final JAXBElement element) { // CC-XJC Version 2.0 Build 2011-09-16T18:27:24+0000 if (element!= null) { final JAXBElement copy = new JAXBElement(element.getName(), element.getDeclaredType(), element.getScope(), element.getValue()); copy.setNil(element.isNil()); copy.setValue(copyOf(copy.getValue())); return copy; } return null; }