Java Code Examples for javax.xml.bind.JAXBElement

The following examples show how to use javax.xml.bind.JAXBElement. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private LoginIdentityProviders loadLoginIdentityProvidersConfiguration() throws Exception {
    final File loginIdentityProvidersConfigurationFile = properties.getLoginIdentityProviderConfigurationFile();

    // load the users from the specified file
    if (loginIdentityProvidersConfigurationFile.exists()) {
        try {
            // find the schema
            final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            final Schema schema = schemaFactory.newSchema(LoginIdentityProviders.class.getResource(LOGIN_IDENTITY_PROVIDERS_XSD));

            // attempt to unmarshal
            final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
            unmarshaller.setSchema(schema);
            final JAXBElement<LoginIdentityProviders> element = unmarshaller.unmarshal(new StreamSource(loginIdentityProvidersConfigurationFile), LoginIdentityProviders.class);
            return element.getValue();
        } catch (SAXException | JAXBException e) {
            throw new Exception("Unable to load the login identity provider configuration file at: " + loginIdentityProvidersConfigurationFile.getAbsolutePath());
        }
    } else {
        throw new Exception("Unable to find the login identity provider configuration file at " + loginIdentityProvidersConfigurationFile.getAbsolutePath());
    }
}
 
Example 2
public String toString(Y data) {
   StringWriter writer = new StringWriter();

   try {
      if (!data.getClass().isAnnotationPresent(XmlRootElement.class) && !(data instanceof JAXBElement)) {
         JAXBElement<Y> jaxbElement = new JAXBElement(translate(data.getClass()), this.marshallClass, data);
         this.getMarshaller().marshal(jaxbElement, writer);
      } else {
         this.getMarshaller().marshal(data, writer);
      }
   } catch (JAXBException var4) {
      throw handleException(var4);
   }

   return writer.toString();
}
 
Example 3
Source Project: citygml4j   Source File: Generics200Marshaller.java    License: Apache License 2.0 6 votes vote down vote up
private TypeMapper<JAXBElement<?>> getElementMapper() {
	if (elementMapper == null) {
		lock.lock();
		try {
			if (elementMapper == null) {
				elementMapper = TypeMapper.<JAXBElement<?>>create()
						.with(GenericCityObject.class, this::createGenericCityObject)
						.with(DateAttribute.class, this::createDateAttribute)
						.with(DoubleAttribute.class, this::createDoubleAttribute)
						.with(IntAttribute.class, this::createIntAttribute)
						.with(StringAttribute.class, this::createStringAttribute)
						.with(UriAttribute.class, this::createUriAttribute)
						.with(MeasureAttribute.class, this::createMeasureAttribute)
						.with(GenericAttributeSet.class, this::createGenericAttributeSet);
			}
		} finally {
			lock.unlock();
		}
	}

	return elementMapper;
}
 
Example 4
/**
 * Sends the given EPCIS Document to the EPCIS capture interface. Please see
 * the <a href="http://www.fosstrak.org/epcis/docs/user-guide.html">Fosstrak
 * User-Guide</a> for more information and code samples.
 * 
 * @param epcisDoc
 *            The EPCIS Document with a list of events.
 * @return The HTTP response code from the repository.
 * @throws IOException
 *             If an error sending the document occurred.
 * @throws JAXBException
 *             If an error serializing the given document into XML occurred.
 */
public int capture(final Document epcisDoc) throws CaptureClientException {
    StringWriter writer = new StringWriter();
    ObjectFactory objectFactory = new ObjectFactory();
    try {
        JAXBContext context = JAXBContext.newInstance("org.fosstrak.epcis.model");
        JAXBElement<? extends Document> item;
        if (epcisDoc instanceof EPCISDocumentType) {
            item = objectFactory.createEPCISDocument((EPCISDocumentType) epcisDoc);
        } else {
            item = objectFactory.createEPCISMasterDataDocument((EPCISMasterDataDocumentType) epcisDoc);
        }
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(item, writer);
    } catch (JAXBException e) {
        throw new CaptureClientException("error serializing EPCIS Document: " + e.getMessage(), e);
    }
    return capture(writer.toString());
}
 
Example 5
Source Project: citygml4j   Source File: Building200Unmarshaller.java    License: Apache License 2.0 6 votes vote down vote up
public void unmarshalDoor(DoorType src, Door dest) throws MissingADESchemaException {
	unmarshalAbstractOpening(src, dest);

	if (src.isSetAddress()) {
		for (AddressPropertyType addressProperty : src.getAddress())
			dest.addAddress(citygml.getCore200Unmarshaller().unmarshalAddressProperty(addressProperty));
	}

	if (src.isSet_GenericApplicationPropertyOfDoor()) {
		for (JAXBElement<Object> elem : src.get_GenericApplicationPropertyOfDoor()) {
			ADEModelObject ade = jaxb.getADEUnmarshaller().unmarshal(elem);
			if (ade != null)
				dest.addGenericApplicationPropertyOfDoor(ade);
		}
	}
}
 
Example 6
Source Project: citygml4j   Source File: Appearance200Unmarshaller.java    License: Apache License 2.0 6 votes vote down vote up
public void unmarshalAppearance(AppearanceType src, Appearance dest) throws MissingADESchemaException {
	jaxb.getGMLUnmarshaller().unmarshalAbstractFeature(src, dest);

	if (src.isSetTheme())
		dest.setTheme(src.getTheme());

	if (src.isSetSurfaceDataMember()) {
		for (SurfaceDataPropertyType surfaceDataMember : src.getSurfaceDataMember())
			dest.addSurfaceDataMember(unmarshalSurfaceDataProperty(surfaceDataMember));
	}

	if (src.isSet_GenericApplicationPropertyOfAppearance()) {
		for (JAXBElement<Object> elem : src.get_GenericApplicationPropertyOfAppearance()) {
			ADEModelObject ade = jaxb.getADEUnmarshaller().unmarshal(elem);
			if (ade != null)
				dest.addGenericApplicationPropertyOfAppearance(ade);
		}
	}
}
 
Example 7
@XmlElementDecl(
   namespace = "http://uri.etsi.org/01903/v1.3.2#",
   name = "CompleteCertificateRefs"
)
public JAXBElement<CompleteCertificateRefsType> createCompleteCertificateRefs(CompleteCertificateRefsType value) {
   return new JAXBElement(_CompleteCertificateRefs_QNAME, CompleteCertificateRefsType.class, (Class)null, value);
}
 
Example 8
@Override
public <T> JAXBElement<T> unmarshal(XMLStreamReader reader, Class<T> expectedType) throws JAXBException {
    if (expectedType==null) {
        throw new IllegalArgumentException();
    }
    return (JAXBElement)unmarshal0(reader,getBeanInfo(expectedType));
}
 
Example 9
@XmlElementDecl(
   namespace = "http://www.w3.org/2001/04/xmlenc#",
   name = "RecipientKeyInfo",
   scope = AgreementMethod.class
)
public JAXBElement<KeyInfo> createAgreementMethodRecipientKeyInfo(KeyInfo value) {
   return new JAXBElement(_AgreementMethodRecipientKeyInfo_QNAME, KeyInfo.class, AgreementMethod.class, value);
}
 
Example 10
Source Project: citygml4j   Source File: Transportation200Unmarshaller.java    License: Apache License 2.0 5 votes vote down vote up
public void unmarshalTrack(TrackType src, Track dest) throws MissingADESchemaException {
	unmarshalTransportationComplex(src, dest);

	if (src.isSet_GenericApplicationPropertyOfTrack()) {
		for (JAXBElement<Object> elem : src.get_GenericApplicationPropertyOfTrack()) {
			ADEModelObject ade = jaxb.getADEUnmarshaller().unmarshal(elem);
			if (ade != null)
				dest.addGenericApplicationPropertyOfTrack(ade);
		}
	}
}
 
Example 11
@XmlElementDecl(
   namespace = "http://uri.etsi.org/01903/v1.3.2#",
   name = "AttributeCertificateRefs"
)
public JAXBElement<CompleteCertificateRefsType> createAttributeCertificateRefs(CompleteCertificateRefsType value) {
   return new JAXBElement(_AttributeCertificateRefs_QNAME, CompleteCertificateRefsType.class, (Class)null, value);
}
 
Example 12
Source Project: cxf   Source File: XKMSInvoker.java    License: Apache License 2.0 5 votes vote down vote up
protected ValidateRequestType prepareValidateXKMSRequest(
                                                      X509Certificate cert) {
    JAXBElement<byte[]> x509Cert;
    try {
        x509Cert = DSIG_OF.createX509DataTypeX509Certificate(cert
            .getEncoded());
    } catch (CertificateEncodingException e) {
        throw new IllegalArgumentException(e);
    }
    X509DataType x509DataType = DSIG_OF.createX509DataType();
    x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(
                                                                     x509Cert);
    JAXBElement<X509DataType> x509Data = DSIG_OF
        .createX509Data(x509DataType);

    KeyInfoType keyInfoType = DSIG_OF.createKeyInfoType();
    keyInfoType.getContent().add(x509Data);

    QueryKeyBindingType queryKeyBindingType = XKMS_OF
        .createQueryKeyBindingType();
    queryKeyBindingType.setKeyInfo(keyInfoType);

    ValidateRequestType validateRequestType = XKMS_OF
        .createValidateRequestType();
    setGenericRequestParams(validateRequestType);
    validateRequestType.setQueryKeyBinding(queryKeyBindingType);
    // temporary
    validateRequestType.setId(cert.getSubjectDN().toString());
    return validateRequestType;
}
 
Example 13
@XmlElementDecl(
   namespace = "http://www.ehealth.fgov.be/standards/kmehr/schema/v1",
   name = "quantity",
   scope = CompoundprescriptionType.class
)
public JAXBElement<QuantityType> createCompoundprescriptionTypeQuantity(QuantityType value) {
   return new JAXBElement(_RegimenQuantity_QNAME, QuantityType.class, CompoundprescriptionType.class, value);
}
 
Example 14
@XmlElementDecl(
   namespace = "urn:oasis:names:tc:SAML:1.0:protocol",
   name = "SubjectQuery"
)
public JAXBElement<SubjectQueryAbstractType> createSubjectQuery(SubjectQueryAbstractType value) {
   return new JAXBElement(_SubjectQuery_QNAME, SubjectQueryAbstractType.class, (Class)null, value);
}
 
Example 15
Source Project: spring-ws   Source File: TicketAgentEndpoint.java    License: MIT License 5 votes vote down vote up
@PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest")
@ResponsePayload
public JAXBElement<TFlightsResponse> listFlights(
    @RequestPayload JAXBElement<TListFlights> request) {
  ObjectFactory factory = new ObjectFactory();
  TFlightsResponse tFlightsResponse = factory.createTFlightsResponse();
  tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101));

  return factory.createListFlightsResponse(tFlightsResponse);
}
 
Example 16
Source Project: tomee   Source File: ObjectFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}
 * {@link MessageDestinationRef }{@code >}
 */
@XmlElementDecl(namespace = "common.xmi", name = "MessageDestinationRef")
public JAXBElement<MessageDestinationRef> createMessageDestinationRef(
    final MessageDestinationRef value) {
    return new JAXBElement<MessageDestinationRef>(
        _MessageDestinationRef_QNAME, MessageDestinationRef.class,
        null, value);
}
 
Example 17
Source Project: citygml4j   Source File: Tunnel200Marshaller.java    License: Apache License 2.0 5 votes vote down vote up
public void marshalIntTunnelInstallation(IntTunnelInstallation src, IntTunnelInstallationType dest) {
	citygml.getCore200Marshaller().marshalAbstractCityObject(src, dest);

	if (src.isSetClazz())
		dest.setClazz(jaxb.getGMLMarshaller().marshalCode(src.getClazz()));

	if (src.isSetFunction()) {
		for (Code function : src.getFunction())
			dest.getFunction().add(jaxb.getGMLMarshaller().marshalCode(function));
	}

	if (src.isSetUsage()) {
		for (Code usage : src.getUsage())
			dest.getUsage().add(jaxb.getGMLMarshaller().marshalCode(usage));
	}

	if (src.isSetLod4Geometry())
		dest.setLod4Geometry(jaxb.getGMLMarshaller().marshalGeometryProperty(src.getLod4Geometry()));

	if (src.isSetLod4ImplicitRepresentation())
		dest.setLod4ImplicitRepresentation(citygml.getCore200Marshaller().marshalImplicitRepresentationProperty(src.getLod4ImplicitRepresentation()));

	if (src.isSetBoundedBySurface()) {
		for (BoundarySurfaceProperty boundarySurfaceProperty : src.getBoundedBySurface())
			dest.getBoundedBySurface().add(marshalBoundarySurfaceProperty(boundarySurfaceProperty));
	}

	if (src.isSetGenericApplicationPropertyOfIntTunnelInstallation()) {
		for (ADEComponent adeComponent : src.getGenericApplicationPropertyOfIntTunnelInstallation()) {
			JAXBElement<Object> jaxbElement = jaxb.getADEMarshaller().marshalJAXBElement(adeComponent);
			if (jaxbElement != null)
				dest.get_GenericApplicationPropertyOfIntTunnelInstallation().add(jaxbElement);
		}
	}
}
 
Example 18
@XmlElementDecl(
   namespace = "http://www.apb.be/standards/smoa/schema/model/v1",
   name = "kmehrPrescription",
   substitutionHeadNamespace = "http://www.apb.be/standards/smoa/schema/model/v1",
   substitutionHeadName = "abstract-Prescription"
)
public JAXBElement<KmehrPrescriptionType> createKmehrPrescription(KmehrPrescriptionType value) {
   return new JAXBElement(_KmehrPrescription_QNAME, KmehrPrescriptionType.class, (Class)null, value);
}
 
Example 19
Source Project: steady   Source File: SecurityTokenServiceProvider.java    License: Apache License 2.0 5 votes vote down vote up
private Object convertToJAXBObject(Source source) throws Exception {
    //this is entirely to work around http://java.net/jira/browse/JAXB-909
    //if that bug is ever fixed and we can detect it, we can remove this 
    //complete and total HACK HACK HACK and replace with just:  
    //Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    //JAXBElement<?> jaxbElement = (JAXBElement<?>) unmarshaller.unmarshal(source);
    //return jaxbElement.getValue();
    
    Document d = StaxUtils.read(source);
    Binder<Node> binder = jaxbContext.createBinder();
    JAXBElement<?> jaxbElement = (JAXBElement<?>)binder.unmarshal(d);
    walkDom("", d.getDocumentElement(), binder, null);
    return jaxbElement.getValue();
}
 
Example 20
Source Project: OpenESPI-Common-java   Source File: ObjectFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }
 * {@code >}
 */
@XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = SourceType.class)
public JAXBElement<LogoType> createSourceTypeLogo(LogoType value) {
	return new JAXBElement<LogoType>(SourceTypeLogo_QNAME, LogoType.class,
			SourceType.class, value);
}
 
Example 21
Source Project: citygml4j   Source File: GMLMarshaller.java    License: Apache License 2.0 4 votes vote down vote up
private JAXBElement<?> createMultiPoint(MultiPoint src) {
	return gml.createMultiPoint(marshalMultiPoint(src));
}
 
Example 22
Source Project: bluima   Source File: ObjectFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link DeclareType }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www.w3.org/1998/Math/MathML", name = "declare")
public JAXBElement<DeclareType> createDeclare(DeclareType value) {
    return new JAXBElement<DeclareType>(_Declare_QNAME, DeclareType.class, null, value);
}
 
Example 23
Source Project: icure-backend   Source File: ObjectFactory.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link Signature }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www.ehealth.fgov.be/standards/kmehr/schema/v1", name = "Signature", scope = Kmehrmessage.class)
public JAXBElement<Signature> createKmehrmessageSignature(Signature value) {
    return new JAXBElement<Signature>(_KmehrmessageSignature_QNAME, Signature.class, Kmehrmessage.class, value);
}
 
Example 24
Source Project: cxf   Source File: EncoderDecoder11Impl.java    License: Apache License 2.0 4 votes vote down vote up
public SequenceType decodeSequenceType(Element elem) throws JAXBException {
    Unmarshaller unmarshaller = getContext().createUnmarshaller();
    JAXBElement<SequenceType> jaxbElement = unmarshaller.unmarshal(elem, SequenceType.class);
    return jaxbElement.getValue();
}
 
Example 25
Source Project: proarc   Source File: ObjectFactory.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link TIdentifikator }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www.mvcr.cz/nsesss/v2", name = "IdentifikatorOrganizace", scope = TSubjektExterni.class)
public JAXBElement<TIdentifikator> createTSubjektExterniIdentifikatorOrganizace(TIdentifikator value) {
    return new JAXBElement<TIdentifikator>(_TSubjektExterniIdentifikatorOrganizace_QNAME, TIdentifikator.class, TSubjektExterni.class, value);
}
 
Example 26
public <T> JAXBElement<T> unmarshal(Source source, Class<T> expectedType) throws JAXBException {
    throw new UnsupportedOperationException();
}
 
Example 27
Source Project: photon   Source File: ObjectFactory.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link X509DataType }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Data")
public JAXBElement<X509DataType> createX509Data(X509DataType value) {
    return new JAXBElement<X509DataType>(_X509Data_QNAME, X509DataType.class, null, value);
}
 
Example 28
Source Project: icure-backend   Source File: ObjectFactory.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Certificate", scope = X509Data.class)
public JAXBElement<byte[]> createX509DataX509Certificate(byte[] value) {
    return new JAXBElement<byte[]>(_X509DataX509Certificate_QNAME, byte[].class, X509Data.class, ((byte[]) value));
}
 
Example 29
Source Project: sierra-ecg-tools   Source File: ObjectFactory.java    License: MIT License 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www3.medical.philips.com", name = "ppamp")
public JAXBElement<String> createPpamp(String value) {
    return new JAXBElement<String>(_Ppamp_QNAME, String.class, null, value);
}
 
Example 30
Source Project: sierra-ecg-tools   Source File: ObjectFactory.java    License: MIT License 4 votes vote down vote up
/**
 * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}}
 * 
 */
@XmlElementDecl(namespace = "http://www3.medical.philips.com", name = "highpassfiltersetting")
public JAXBElement<String> createHighpassfiltersetting(String value) {
    return new JAXBElement<String>(_Highpassfiltersetting_QNAME, String.class, null, value);
}