List of usage examples for javax.xml.bind JAXBElement JAXBElement
public JAXBElement(QName name, Class<T> declaredType, T value)
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
/** * Serializes DOM or JAXB element to string, using specified elementName if needed. *///from w w w .j ava 2 s .c om public String marshalElementToString(Object element, QName elementName) throws JAXBException { if (element == null) { return null; } if (element instanceof Element) { return DOMUtil.serializeDOMToString((Element) element); } else if (element instanceof JAXBElement) { return marshalElementToString((JAXBElement<?>) element); } else { JAXBElement<Object> jaxbElement = new JAXBElement<Object>(elementName, Object.class, element); return marshalElementToString(jaxbElement); } }
From source file:com.evolveum.midpoint.prism.marshaller.JaxbDomHack.java
private Object wrapIfNeeded(Object value, QName elementName) { if (value instanceof Element || value instanceof JAXBElement) { return value; } else {/* www .jav a 2 s .co m*/ return new JAXBElement(elementName, value.getClass(), value); } }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public void marshalToDom(Objectable objectable, Node parentNode) throws JAXBException { QName elementQName = determineElementQName(objectable); JAXBElement<Object> jaxbElement = new JAXBElement<Object>(elementQName, (Class) objectable.getClass(), objectable);/*from w ww . j a va 2 s . co m*/ marshalElementToDom(jaxbElement, parentNode); }
From source file:gov.nih.nci.integration.caaers.CaAERSAdverseEventServiceClientIntegrationTest.java
private String getAdverseEventsInputMessageString() { StringWriter sw = null;/*from ww w .j a v a 2 s. c o m*/ try { final AdverseEventsInputMessage inputMessage = new AdverseEventsInputMessage(); final AdverseEvents adverseEvents = new AdverseEvents(); final Criteria criteria = new Criteria(); final AdverseEventType event1 = getAdverseEvent1(); adverseEvents.getAdverseEvent().add(event1); final AdverseEventType event2 = getAdverseEvent2(); adverseEvents.getAdverseEvent().add(event2); criteria.setStudySubjectIdentifier("PM-113"); criteria.setStudyIdentifier("7216"); final CourseType course = getCourseType(); criteria.setCourse(course); inputMessage.setAdverseEvents(adverseEvents); inputMessage.setCriteria(criteria); final QName qname = new QName("http://schema.integration.caaers.cabig.nci.nih.gov/adverseevent", "adverseevent"); final JAXBElement<AdverseEventsInputMessage> ptJaxbEle = new JAXBElement<AdverseEventsInputMessage>( qname, AdverseEventsInputMessage.class, inputMessage); sw = new StringWriter(); getMarshaller().marshal(ptJaxbEle, sw); System.out.println("StringXML-->" + sw.toString()); // NOPMD } catch (DatatypeConfigurationException de) { LOG.debug("DatatypeConfigurationExceptionwhile populating the test data.", de); } catch (JAXBException je) { LOG.debug("JAXBException while populating the test data.", je); } return sw.toString(); }
From source file:com.evolveum.midpoint.web.util.ExpressionUtil.java
public static void updateShadowRefEvaluatorValue(ExpressionType expression, String value, PrismContext prismContext) {//from w ww . j a v a 2 s . c o m JAXBElement<RawType> element = findFirstEvaluatorByName(expression, SchemaConstants.C_VALUE); if (element == null) { element = new JAXBElement(SchemaConstants.C_VALUE, RawType.class, new RawType(prismContext)); } element.setValue(new RawType(new PrimitiveXNode<>(value), prismContext)); expression.getExpressionEvaluator().add(element); }
From source file:com.evolveum.midpoint.pwdfilter.opendj.PasswordPusher.java
private static <T> JAXBElement<T> toJaxbElement(QName name, T value) { return new JAXBElement<T>(name, (Class<T>) value.getClass(), value); }
From source file:com.evolveum.midpoint.web.util.ExpressionUtil.java
public static JAXBElement createAssociationTargetSearchElement() { JAXBElement evaluator = new JAXBElement(SchemaConstantsGenerated.C_ASSOCIATION_TARGET_SEARCH, JAXBElement.GlobalScope.class, new JAXBElement.GlobalScope()); SearchObjectExpressionEvaluatorType searchObjectExpressionEvaluatorType = new SearchObjectExpressionEvaluatorType(); SearchFilterType filterType = new SearchFilterType(); MapXNode filterClauseNode = new MapXNode(); MapXNode values = new MapXNode(); values.put(new QName("path"), new PrimitiveXNode<ItemPathType>()); values.put(new QName("value"), new PrimitiveXNode()); filterClauseNode.put(new QName("equal"), values); filterType.setFilterClauseXNode(filterClauseNode); searchObjectExpressionEvaluatorType.setFilter(filterType); evaluator.setValue(searchObjectExpressionEvaluatorType); return evaluator; }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public <T> String marshalObjectToString(T jaxbObject, QName elementQName) throws JAXBException { JAXBElement<Object> jaxbElement = new JAXBElement<Object>(elementQName, (Class) jaxbObject.getClass(), jaxbObject);//from w w w.jav a 2 s. c o m return marshalElementToString(jaxbElement); }
From source file:org.emergya.osrm.OSRM.java
private List<JAXBElement<?>> decodeRouteGeometry(List<JAXBElement<?>> list, CoordinateReferenceSystem targetCRS, CoordinateReferenceSystem sourceCRS, JsonParser jp) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException, TransformException, JsonParseException, IOException { MathTransform transform = null;// ww w.jav a 2 s .c o m LOG.trace(targetCRS.toWKT()); LOG.trace(sourceCRS.toWKT()); jp.nextToken(); while (jp.nextToken() == JsonToken.START_ARRAY && jp.getCurrentToken() != null) { jp.nextToken(); Double lat = jp.getDoubleValue(); jp.nextToken(); Double lon = jp.getDoubleValue(); jp.nextToken(); Coordinate coord = new Coordinate(lat, lon); Point sourceGeometry = gf.createPoint(coord); LOG.trace(sourceGeometry); if (sourceCRS != targetCRS) { if (transform == null) transform = CRS.findMathTransform(sourceCRS, targetCRS); sourceGeometry = JTS.transform(sourceGeometry, transform).getCentroid(); LOG.trace(sourceGeometry); } DirectPositionListType e = new DirectPositionListType(); e.getValue().add(sourceGeometry.getY()); e.getValue().add(sourceGeometry.getX()); JAXBElement<DirectPositionListType> elem = new JAXBElement<DirectPositionListType>( new QName("http://www.opengis.net/gml", "pos", "gml"), DirectPositionListType.class, e); list.add(elem); } return list; }