javax.xml.bind.annotation.XmlAnyElement Java Examples

The following examples show how to use javax.xml.bind.annotation.XmlAnyElement. 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: GO_CharacterString.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the code list wrapped in a JAXB element, or {@code null} if the {@link #text} is not a wrapper for
 * a code list. Only one of {@link #getValue()} and {@code getCodeList()} should return a non-null value.
 *
 * <div class="note"><b>Note:</b>
 * we have to rely on a somewhat complicated mechanism because the code lists implementations in GeoAPI
 * do not have JAXB annotations. If those annotations are added in a future GeoAPI implementation, then
 * we could replace this mechanism by a simple property annotated with {@code XmlElementRef}.</div>
 *
 * @since 0.7
 */
@XmlAnyElement
@Workaround(library = "GeoAPI", version = "3.0")
private Object getCodeList() {
    if (type != ENUM) {
        return null;
    }
    final CodeList<?> code = Types.forCodeTitle(text);
    final String name = Types.getListName(code);
    /*
     * The namespace has have various value like CIT, SRV, MDQ, MRI, MSR, LAN, etc.
     * The real namespace is declared in the @XmlElement annotation of the getElement
     * method in the JAXB adapter. We could use reflection, but we do not in order to
     * avoid potential class loading issue and also because not all CodeList are in the
     * same package.
     */
    String namespace = Namespaces.guessForType(name);
    if (namespace == null) {
        namespace = XMLConstants.NULL_NS_URI;
    }
    return new JAXBElement<>(new QName(namespace, name), CodeListUID.class,
            new CodeListUID(Context.current(), code));
}
 
Example #2
Source File: ReferencePropertyInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #3
Source File: ReferencePropertyInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #4
Source File: ReferencePropertyInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #5
Source File: ReferencePropertyInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #6
Source File: ReferencePropertyInfoImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #7
Source File: ReferencePropertyInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #8
Source File: ReferencePropertyInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #9
Source File: ReferencePropertyInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ReferencePropertyInfoImpl(
    ClassInfoImpl<T,C,F,M> classInfo,
    PropertySeed<T,C,F,M> seed) {

    super(classInfo, seed);

    isMixed = seed.readAnnotation(XmlMixed.class) != null;

    XmlAnyElement xae = seed.readAnnotation(XmlAnyElement.class);
    if(xae==null) {
        wildcard = null;
        domHandler = null;
    } else {
        wildcard = xae.lax()?WildcardMode.LAX:WildcardMode.SKIP;
        domHandler = nav().asDecl(reader().getClassValue(xae,"value"));
    }
}
 
Example #10
Source File: SecurityTokenServiceProvider.java    From steady with Apache License 2.0 5 votes vote down vote up
private void walkDom(String pfx, Element element, Binder<Node> binder, Object parent) {
    try {
        Object o = binder.getJAXBNode(element);
        if (o instanceof JAXBElement) {
            o = ((JAXBElement<?>)o).getValue();
        }
        //System.out.println(pfx + DOMUtils.getElementQName(element) + " ->  " 
        //    + (o == null ? "null" : o.getClass()));
        if (o == null && parent != null) {
            // if it's not able to bind to an object, it's possibly an xsd:any
            // we'll check the parent for the standard "any" and replace with 
            // the original element.
            Field f = parent.getClass().getDeclaredField("any");
            if (f.getAnnotation(XmlAnyElement.class) != null) {
                Object old = ReflectionUtil.setAccessible(f).get(parent);
                if (old instanceof Element
                    && DOMUtils.getElementQName(element).equals(DOMUtils.getElementQName((Element)old))) {
                    ReflectionUtil.setAccessible(f).set(parent, element);
                }
            }
        }
        if (o == null) {
            return;
        }
        Node nd = element.getFirstChild();
        while (nd != null) {
            if (nd instanceof Element) {
                walkDom(pfx + "  ", (Element)nd, binder, o);
            }
            nd = nd.getNextSibling();
        }
    } catch (Throwable t) {
        //ignore -this is a complete hack anyway
    }
}
 
Example #11
Source File: JIIB10Test.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void testXmlAnyElementLax() throws Exception {

		final Field contentField = IssueJIIB10Type.class.getDeclaredField("content");
		final XmlAnyElement xmlAnyElementAnnotation = contentField
				.getAnnotation(XmlAnyElement.class);
		Assert.assertTrue(xmlAnyElementAnnotation.lax());
	}
 
Example #12
Source File: ImmutableJaxbGenerator.java    From rice with Educational Community License v2.0 5 votes vote down vote up
private void renderFutureElementsField(JDefinedClass classModel) throws Exception {
	JType collectionType = codeModel.parseType("java.util.Collection<org.w3c.dom.Element>");
	JFieldVar field = classModel.field(JMod.PRIVATE | JMod.FINAL, collectionType, "_futureElements");
	field.init(JExpr._null());
	JAnnotationUse annotation = field.annotate(SuppressWarnings.class);
	annotation.param("value", "unused");
	field.annotate(XmlAnyElement.class);
}
 
Example #13
Source File: SecurityTokenServiceProvider.java    From steady with Apache License 2.0 5 votes vote down vote up
private void walkDom(String pfx, Element element, Binder<Node> binder, Object parent) {
    try {
        Object o = binder.getJAXBNode(element);
        if (o instanceof JAXBElement) {
            o = ((JAXBElement<?>)o).getValue();
        }
        //System.out.println(pfx + DOMUtils.getElementQName(element) + " ->  " 
        //    + (o == null ? "null" : o.getClass()));
        if (o == null && parent != null) {
            // if it's not able to bind to an object, it's possibly an xsd:any
            // we'll check the parent for the standard "any" and replace with 
            // the original element.
            Field f = parent.getClass().getDeclaredField("any");
            if (f.getAnnotation(XmlAnyElement.class) != null) {
                Object old = ReflectionUtil.setAccessible(f).get(parent);
                if (old instanceof Element
                    && DOMUtils.getElementQName(element).equals(DOMUtils.getElementQName((Element)old))) {
                    ReflectionUtil.setAccessible(f).set(parent, element);
                }
            }
        }
        if (o == null) {
            return;
        }
        Node nd = element.getFirstChild();
        while (nd != null) {
            if (nd instanceof Element) {
                walkDom(pfx + "  ", (Element)nd, binder, o);
            }
            nd = nd.getNextSibling();
        }
    } catch (Throwable t) {
        //ignore -this is a complete hack anyway
    }
}
 
Example #14
Source File: SecurityTokenServiceProvider.java    From steady with Apache License 2.0 5 votes vote down vote up
private void walkDom(String pfx, Element element, Binder<Node> binder, Object parent) {
    try {
        Object o = binder.getJAXBNode(element);
        if (o instanceof JAXBElement) {
            o = ((JAXBElement<?>)o).getValue();
        }
        //System.out.println(pfx + DOMUtils.getElementQName(element) + " ->  " 
        //    + (o == null ? "null" : o.getClass()));
        if (o == null && parent != null) {
            // if it's not able to bind to an object, it's possibly an xsd:any
            // we'll check the parent for the standard "any" and replace with 
            // the original element.
            Field f = parent.getClass().getDeclaredField("any");
            if (f.getAnnotation(XmlAnyElement.class) != null) {
                Object old = ReflectionUtil.setAccessible(f).get(parent);
                if (old instanceof Element
                    && DOMUtils.getElementQName(element).equals(DOMUtils.getElementQName((Element)old))) {
                    ReflectionUtil.setAccessible(f).set(parent, element);
                }
            }
        }
        if (o == null) {
            return;
        }
        Node nd = element.getFirstChild();
        while (nd != null) {
            if (nd instanceof Element) {
                walkDom(pfx + "  ", (Element)nd, binder, o);
            }
            nd = nd.getNextSibling();
        }
    } catch (Throwable t) {
        //ignore -this is a complete hack anyway
    }
}
 
Example #15
Source File: SecurityTokenServiceProvider.java    From steady with Apache License 2.0 5 votes vote down vote up
private void walkDom(String pfx, Element element, Binder<Node> binder, Object parent) {
    try {
        Object o = binder.getJAXBNode(element);
        if (o instanceof JAXBElement) {
            o = ((JAXBElement<?>)o).getValue();
        }
        //System.out.println(pfx + DOMUtils.getElementQName(element) + " ->  " 
        //    + (o == null ? "null" : o.getClass()));
        if (o == null && parent != null) {
            // if it's not able to bind to an object, it's possibly an xsd:any
            // we'll check the parent for the standard "any" and replace with 
            // the original element.
            Field f = parent.getClass().getDeclaredField("any");
            if (f.getAnnotation(XmlAnyElement.class) != null) {
                Object old = ReflectionUtil.setAccessible(f).get(parent);
                if (old instanceof Element
                    && DOMUtils.getElementQName(element).equals(DOMUtils.getElementQName((Element)old))) {
                    ReflectionUtil.setAccessible(f).set(parent, element);
                }
            }
        }
        if (o == null) {
            return;
        }
        Node nd = element.getFirstChild();
        while (nd != null) {
            if (nd instanceof Element) {
                walkDom(pfx + "  ", (Element)nd, binder, o);
            }
            nd = nd.getNextSibling();
        }
    } catch (Throwable t) {
        //ignore -this is a complete hack anyway
    }
}
 
Example #16
Source File: SecurityTokenServiceProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void walkDom(String pfx, Element element, Binder<Node> binder, Object parent) {
    try {
        Object o = binder.getJAXBNode(element);
        if (o instanceof JAXBElement) {
            o = ((JAXBElement<?>)o).getValue();
        }
        //System.out.println(pfx + DOMUtils.getElementQName(element) + " ->  "
        //    + (o == null ? "null" : o.getClass()));
        if (o == null && parent != null) {
            // if it's not able to bind to an object, it's possibly an xsd:any
            // we'll check the parent for the standard "any" and replace with
            // the original element.
            Field f = parent.getClass().getDeclaredField("any");
            if (f.getAnnotation(XmlAnyElement.class) != null) {
                Object old = ReflectionUtil.setAccessible(f).get(parent);
                if (old instanceof Element
                    && DOMUtils.getElementQName(element).equals(DOMUtils.getElementQName((Element)old))) {
                    ReflectionUtil.setAccessible(f).set(parent, element);
                }
            }
        }
        if (o == null) {
            return;
        }
        Node nd = element.getFirstChild();
        while (nd != null) {
            if (nd instanceof Element) {
                walkDom(pfx + "  ", (Element)nd, binder, o);
            }
            nd = nd.getNextSibling();
        }
    } catch (Throwable t) {
        //ignore -this is a complete hack anyway
    }
}
 
Example #17
Source File: GEffectsNode.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
@XmlAnyElement
public List<JAXBElement<GEffect>> getEffectsXml(){
    List<JAXBElement<GEffect>> res = new LinkedList<JAXBElement<GEffect>>();
    for(GEffect effect : effects){
        res.add(new JAXBElement<GEffect>(new QName(effect.getEventType().toString()),GEffect.class, effect));
    }
    return res;
}
 
Example #18
Source File: ApplicationDocs.java    From eagle with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement(value = UninstallDocDomHandler.class)
public String getUninstall() {
    return uninstall;
}
 
Example #19
Source File: OAuthServer.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
@XmlJavaTypeAdapter(OauthMapAdapter.class)
public OAuthServer setMapping(Map<String, String> map) {
	mapping.putAll(map);
	return this;
}
 
Example #20
Source File: ApplicationDocs.java    From eagle with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement(value = InstallDocDomHandler.class)
public void setInstall(String install) {
    this.install = install;
}
 
Example #21
Source File: JaxbProperty.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlElementWrapper(name="value-assist")
@XmlAnyElement
public List<Element> getValueAssistElement() {
    return valueAssistElement;
}
 
Example #22
Source File: AdaptedMap.java    From jeddict with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public Object getValue() {
    return value;
}
 
Example #23
Source File: ResourceWithUrl.java    From todo-backend-spring4-java8 with MIT License 4 votes vote down vote up
@JsonUnwrapped
@XmlAnyElement
public T getContent() {
    return content;
}
 
Example #24
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
@XmlAnyElement
public List<Entity> getEntities() {
    return entities;
}
 
Example #25
Source File: JaxbValueAssistantRequest.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public List<Element> getElements() {
    return elements;
}
 
Example #26
Source File: JaxbAuditPolicy.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public Element getAttributeRulesElement() {
    return attributeRulesElement;
}
 
Example #27
Source File: JaxbPropertyLifecycleInfo.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlElementWrapper(name="value-assist")
@XmlAnyElement
public List<Element> getValueAssistElement() {
    return valueAssistElement;
}
 
Example #28
Source File: JaxbEntry.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public Element getElement() {
    return element;
}
 
Example #29
Source File: JaxbValueAssistance.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public List<Element> getElements() {
    return elements;
}
 
Example #30
Source File: JaxbObject.java    From documentum-rest-client-java with Apache License 2.0 4 votes vote down vote up
@XmlAnyElement
public List<Element> getElements() {
    return elements;
}