Java Code Examples for javax.xml.bind.JAXBElement#setValue()

The following examples show how to use javax.xml.bind.JAXBElement#setValue() . 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: ElementBeanInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.getTarget();
    state.setTarget(state.getBackup());
    state.setBackup(null);

    if (state.isNil()) {
        e.setNil(true);
        state.setNil(false);
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 2
Source File: JAXBElementUtils.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static <T> JAXBElement<T> wrap(JAXBElement element,
		String name, T value) {

	if (name == null || value == null) {
		return null;
	} else {
		if (element != null) {
			if (element.getName().equals(QName.valueOf(name))
					&& element.getDeclaredType() == value.getClass()) {
				element.setValue(value);
				return element;
			} else {
				return new JAXBElement(QName.valueOf(name), value
						.getClass(), value);
			}
		} else {
			return new JAXBElement(QName.valueOf(name), value.getClass(),
					value);
		}
	}
}
 
Example 3
Source File: ElementBeanInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.getTarget();
    state.setTarget(state.getBackup());
    state.setBackup(null);

    if (state.isNil()) {
        e.setNil(true);
        state.setNil(false);
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 4
Source File: ElementBeanInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.getTarget();
    state.setTarget(state.getBackup());
    state.setBackup(null);

    if (state.isNil()) {
        e.setNil(true);
        state.setNil(false);
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 5
Source File: ElementBeanInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.target;
    state.target = state.backup;
    state.backup = null;

    if (state.nil) {
        e.setNil(true);
        state.nil = false;
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 6
Source File: GMLUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public FeatureArrayProperty unmarshalFeatureArrayProperty(FeatureArrayPropertyType src) throws MissingADESchemaException {
	FeatureArrayProperty dest = new FeatureArrayProperty();

	if (src.isSet_Feature()) {
		for (JAXBElement<? extends AbstractFeatureType> elem : src.get_Feature()) {
			ModelObject abstractFeature = jaxb.unmarshal(elem);
			if (abstractFeature instanceof AbstractFeature)
				dest.addFeature((AbstractFeature)abstractFeature);

			// release memory
			if (jaxb.isReleaseJAXBElementsFromMemory())
				elem.setValue(null);
		}
	}

	if (!jaxb.isSkipGenericADEContent() && src.isSet_ADEComponent()) {
		for (Element dom : src.get_ADEComponent()) {
			ADEGenericElement ade = jaxb.getADEUnmarshaller().unmarshal(dom);
			if (ade != null)
				dest.addGenericADEElement(ade);
		}
	}

	return dest;
}
 
Example 7
Source File: ElementBeanInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.getTarget();
    state.setTarget(state.getBackup());
    state.setBackup(null);

    if (state.isNil()) {
        e.setNil(true);
        state.setNil(false);
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 8
Source File: ElementBeanInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Object intercept(UnmarshallingContext.State state, Object o) throws SAXException {
    JAXBElement e = (JAXBElement)state.target;
    state.target = state.backup;
    state.backup = null;

    if (state.nil) {
        e.setNil(true);
        state.nil = false;
    }

    if(o!=null)
        // if the value is a leaf type, it's often already set to the element
        // through Accessor.
        e.setValue(o);

    fireAfterUnmarshal(ElementBeanInfoImpl.this, e, state);

    return e;
}
 
Example 9
Source File: UnmarshallingContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 10
Source File: UnmarshallingContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 11
Source File: UnmarshallingContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 12
Source File: UnmarshallingContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 13
Source File: UnmarshallingContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 14
Source File: UnmarshallingContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void receive(State state, Object o) {
    JAXBElement e = (JAXBElement)state.target;
    e.setValue(o);
    state.getContext().recordOuterPeer(e);
    state.getContext().result = e;
}
 
Example 15
Source File: Accessor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void set(JAXBElement jaxbElement, Object o) {
    jaxbElement.setValue(o);
}
 
Example 16
Source File: ElementBeanInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public boolean reset(JAXBElement e, UnmarshallingContext context) {
    e.setValue(null);
    return true;
}
 
Example 17
Source File: Accessor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void set(JAXBElement jaxbElement, Object o) {
    jaxbElement.setValue(o);
}
 
Example 18
Source File: ElementBeanInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public boolean reset(JAXBElement e, UnmarshallingContext context) {
    e.setValue(null);
    return true;
}
 
Example 19
Source File: ElementBeanInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean reset(JAXBElement e, UnmarshallingContext context) {
    e.setValue(null);
    return true;
}
 
Example 20
Source File: ElementBeanInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean reset(JAXBElement e, UnmarshallingContext context) {
    e.setValue(null);
    return true;
}