List of usage examples for javax.xml.bind JAXBElement JAXBElement
public JAXBElement(QName name, Class<T> declaredType, T value)
From source file:hydrograph.ui.engine.helper.ConverterHelper.java
private void addExternalJaxbOperation(List<JAXBElement<?>> operationList, MappingSheetRow mappingsheetRow) { TypeExternalSchema typeExternalSchema = new TypeExternalSchema(); typeExternalSchema.setUri("../" + mappingsheetRow.getExternalOperation().getFilePath()); JAXBElement<TypeExternalSchema> externalOperation = new JAXBElement<TypeExternalSchema>( OperationsExpressionType.INCLUDE_EXTERNAL_OPERATION.getQName(), TypeExternalSchema.class, typeExternalSchema);/*ww w . j a va 2s . c o m*/ operationList.add(externalOperation); }
From source file:org.fcrepo.oai.AbstractOAIProviderIT.java
private InputStream toStream(SetType set) throws JAXBException { ByteArrayOutputStream sink = new ByteArrayOutputStream(); marshaller.marshal(new JAXBElement(new QName("set"), SetType.class, set), sink); return new ByteArrayInputStream(sink.toByteArray()); }
From source file:com.legstar.coxb.transform.AbstractHostToXmlTransformer.java
/** * Marshal JAXB value object to get the XML. * <p/>// ww w. j a v a 2s . c o m * Root elements can be marshalled directly while non-root elements must be * encapsulated in a JAXBElement before they can be marshalled. * * @param valueObject the JAXB value object * @param writer XML will be sent to this writer. * @throws HostTransformException if transformation fails * */ @SuppressWarnings({ "unchecked", "rawtypes" }) public void getXmlFromObject(final Object valueObject, final Writer writer) throws HostTransformException { try { if (isXmlRootElement()) { getXmlMarshaller().marshal(valueObject, writer); } else { QName qName = new QName(getNamespace(), getElementName()); JAXBElement<?> jaxbElement = new JAXBElement(qName, getHostToJavaTransformer().newBinding().getJaxbType(), valueObject); getXmlMarshaller().marshal(jaxbElement, writer); } } catch (JAXBException e) { throw new HostTransformException(e); } catch (CobolBindingException e) { throw new HostTransformException(e); } }
From source file:org.javelin.sws.ext.bind.internal.model.ClassHierarchyTest.java
@Test public void handleXmlAccessTypePropertyWithBase() throws Exception { // f3, f4, p1, p2, p3, p4 - properties and annotated fields System.out.println("\nD2"); JAXBContext context = JAXBContext.newInstance(D2.class); context.createMarshaller().marshal(new JAXBElement<D2>(new QName("", "r"), D2.class, new D2()), System.out); System.out.println();//www . j ava 2 s. c om final List<DOMResult> results = new LinkedList<DOMResult>(); context.generateSchema(new SchemaOutputResolver() { @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { DOMResult result = new DOMResult(); results.add(result); result.setSystemId(suggestedFileName); return result; } }); for (DOMResult dr : results) { javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform( new javax.xml.transform.dom.DOMSource(dr.getNode()), new javax.xml.transform.stream.StreamResult(new java.io.PrintWriter(System.out))); } JAXBContext ctx = SweJaxbContextFactory.createContext(new Class[] { D2.class }, null); Map<Class<?>, TypedPattern<?>> patterns = (Map<Class<?>, TypedPattern<?>>) ReflectionTestUtils.getField(ctx, "patterns"); ComplexTypePattern<D2> pattern = (ComplexTypePattern<D2>) patterns.get(D2.class); Map<QName, PropertyMetadata<D2, ?>> elements = (Map<QName, PropertyMetadata<D2, ?>>) ReflectionTestUtils .getField(pattern, "elements"); assertThat(elements.size(), equalTo(8)); assertTrue(elements.containsKey(new QName("", "f3"))); assertTrue(elements.containsKey(new QName("", "f4"))); assertTrue(elements.containsKey(new QName("", "fd3"))); assertTrue(elements.containsKey(new QName("", "fd4"))); assertTrue(elements.containsKey(new QName("", "p1"))); assertTrue(elements.containsKey(new QName("", "p2"))); assertTrue(elements.containsKey(new QName("", "p3"))); assertTrue(elements.containsKey(new QName("", "p4"))); }
From source file:hydrograph.ui.engine.helper.ConverterHelper.java
private void addExternalJaxbExpression(List<JAXBElement<?>> operationList, MappingSheetRow mappingsheetRow) { TypeExternalSchema typeExternalSchema = new TypeExternalSchema(); typeExternalSchema.setUri("../" + mappingsheetRow.getExternalExpresion().getFilePath()); JAXBElement<TypeExternalSchema> externalExpression = new JAXBElement<TypeExternalSchema>( OperationsExpressionType.INCLUDE_EXTERNAL_EXPRESSION.getQName(), TypeExternalSchema.class, typeExternalSchema);/*w w w. ja va 2 s .co m*/ operationList.add(externalExpression); }
From source file:com.evolveum.midpoint.testing.model.client.sample.RunScript.java
private static String marshalResult(OperationResultType result) throws JAXBException, FileNotFoundException { if (result == null) { return ""; } else {/* w ww .jav a 2 s.c o m*/ return marshalObject(new JAXBElement<>(new QName("result"), OperationResultType.class, result)); } }
From source file:com.evolveum.midpoint.model.client.ModelClientUtil.java
public static <T> JAXBElement<T> toJaxbElement(QName name, T value) { return new JAXBElement<T>(name, (Class<T>) value.getClass(), value); }
From source file:io.onedecision.engine.decisions.model.dmn.DmnModel.java
public String serialize(Definitions def) { JAXBContext context;/*w w w. j a v a 2s . c o m*/ StringWriter stringWriter = new StringWriter(); try { context = JAXBContext.newInstance(Definitions.class); Marshaller m = context.createMarshaller(); Result out = new StreamResult(stringWriter); // Since no @XmlRootElement generated for Definitions need to create // element wrapper here. See // https://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html m.marshal(new JAXBElement<Definitions>(new QName(DecisionConstants.DMN_URI, "definitions"), Definitions.class, def), out); } catch (JAXBException e) { String msg = "Unable to load decision model from stream"; throw new InvalidDmnException(msg, e); } return stringWriter.toString(); }
From source file:hydrograph.ui.engine.helper.ConverterHelper.java
public void addExternalJaxbExpression(List<JAXBElement<?>> operationList, ExternalWidgetData externalExpressionData) { if (externalExpressionData != null) { TypeExternalSchema typeExternalSchema = new TypeExternalSchema(); typeExternalSchema.setUri("../" + externalExpressionData.getFilePath()); JAXBElement<TypeExternalSchema> externalExpression = new JAXBElement<TypeExternalSchema>( OperationsExpressionType.INCLUDE_EXTERNAL_EXPRESSION.getQName(), TypeExternalSchema.class, typeExternalSchema);/*from w ww . j a v a2 s .co m*/ operationList.add(externalExpression); } }
From source file:in.gov.uidai.core.aua.client.KYCClient.java
private String generateSignedKycXML(Kyc kyc) throws JAXBException, Exception { StringWriter kycXML = new StringWriter(); JAXBElement kycElement = new JAXBElement( new QName("http://www.uidai.gov.in/kyc/uid-kyc-request/1.0", "Kyc"), Kyc.class, kyc); JAXBContext.newInstance(Kyc.class).createMarshaller().marshal(kycElement, kycXML); boolean includeKeyInfo = true; return this.digitalSignator.signXML(kycXML.toString(), includeKeyInfo); }