Java Code Examples for javax.xml.bind.JAXBElement#getValue()
The following examples show how to use
javax.xml.bind.JAXBElement#getValue() .
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: Aes57Utils.java From proarc with GNU General Public License v3.0 | 6 votes |
public static <T> T unmarshal(Source source, Class<T> type) { try { JAXBElement<T> item = defaultUnmarshaller().unmarshal(source, type); return item.getValue(); } catch (JAXBException ex) { throw new DataBindingException(ex); } }
Example 2
Source File: JaxbReadTest168NC.java From portals-pluto with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { try { JAXBContext cntxt = JAXBContext.newInstance(JAXB_CONTEXT); InputStream in = this.getClass().getClassLoader().getResourceAsStream(XML_FILE); Unmarshaller um = cntxt.createUnmarshaller(); JAXBElement<?> jel = (JAXBElement<?>) um.unmarshal(in); assertNotNull(jel.getValue()); assertTrue(jel.getValue() instanceof PortletAppType); portletApp = (PortletAppType) jel.getValue(); } catch (Exception e) { System.out.println("\nException during setup: " + e.getMessage() + "\n"); throw e; } }
Example 3
Source File: CaptureService.java From epcis with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") private BsonDocument prepareEvent(Object jaxbEvent, String userID, String accessModifier, Integer gcpLength) { JAXBElement eventElement = (JAXBElement) jaxbEvent; Object event = eventElement.getValue(); CaptureUtil.isCorrectEvent(event); MongoCaptureUtil m = new MongoCaptureUtil(); BsonDocument doc = m.convert(event, userID, accessModifier, gcpLength); return doc; }
Example 4
Source File: FATCAMetadata.java From IDES-Data-Preparation-Java with Creative Commons Zero v1.0 Universal | 5 votes |
public Object unmarshal(String metadataFile) throws Exception { Unmarshaller unmrshlr = null; Object obj = null; FATCAIDESSenderFileMetadataType metadataObj = null; //unmarshall metadata xml file content into Java bean/object unmrshlr = jaxbCtxMetadata.createUnmarshaller(); obj = unmrshlr.unmarshal(new File(metadataFile));; if (obj instanceof JAXBElement<?>) { @SuppressWarnings("unchecked") JAXBElement<FATCAIDESSenderFileMetadataType> jaxbElem = (JAXBElement<FATCAIDESSenderFileMetadataType>)obj; metadataObj = jaxbElem.getValue(); } return metadataObj; }
Example 5
Source File: PresetGeometries.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Convert a single CustomGeometry object, i.e. from xmlbeans */ public static CustomGeometry convertCustomGeometry(XMLStreamReader staxReader) { try { JAXBContext jaxbContext = JAXBContext.newInstance(BINDING_PACKAGE); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<CTCustomGeometry2D> el = unmarshaller.unmarshal(staxReader, CTCustomGeometry2D.class); return new CustomGeometry(el.getValue()); } catch (JAXBException e) { LOG.log(POILogger.ERROR, "Unable to parse single custom geometry", e); return null; } }
Example 6
Source File: EncoderDecoder10AImpl.java From cxf with Apache License 2.0 | 5 votes |
public CloseSequenceType decodeSequenceTypeCloseSequence(Element elem) throws JAXBException { Unmarshaller unmarshaller = getContext().createUnmarshaller(); JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502wsa15.SequenceType.class); org.apache.cxf.ws.rm.v200502wsa15.SequenceType seq = jaxbElement.getValue(); if (seq.isSetLastMessage()) { CloseSequenceType close = new CloseSequenceType(); close.setIdentifier(VersionTransformer.convert(seq.getIdentifier())); close.setLastMsgNumber(seq.getMessageNumber()); return close; } return null; }
Example 7
Source File: IntervalBlockAdapter.java From OpenESPI-Common-java with Apache License 2.0 | 5 votes |
@Override public IntervalBlock unmarshal(JAXBElement<IntervalBlock> v) throws Exception { IntervalBlock intervalBlock = v.getValue(); for (IntervalReading intervalReading : intervalBlock .getIntervalReadings()) { intervalReading.setIntervalBlock(intervalBlock); } return intervalBlock; }
Example 8
Source File: GMLMarshaller.java From citygml4j with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void marshalSurface(Surface src, SurfaceType dest) { marshalAbstractSurface(src, dest); if (src.isSetPatches()) { JAXBElement<?> elem = jaxb.marshalJAXBElement(src.getPatches()); if (elem != null && elem.getValue() instanceof SurfacePatchArrayPropertyType) dest.setPatches((JAXBElement<? extends SurfacePatchArrayPropertyType>)elem); } }
Example 9
Source File: CustomParameterTest.java From cxf with Apache License 2.0 | 5 votes |
private RequestedSecurityTokenType getRequestedSecurityToken(RequestSecurityTokenResponseType securityResponse) { for (Object obj : securityResponse.getAny()) { if (obj instanceof JAXBElement<?>) { JAXBElement<?> jaxbElement = (JAXBElement<?>)obj; if ("RequestedSecurityToken".equals(jaxbElement.getName().getLocalPart())) { return (RequestedSecurityTokenType)jaxbElement.getValue(); } } } return null; }
Example 10
Source File: ExpressionContainer.java From XACML with MIT License | 5 votes |
protected Collection<?> getChildrenIds(ApplyType apply, boolean recursive) { Collection<Object> items = new ArrayList<Object>(); for (JAXBElement<?> child : apply.getExpression()) { // // Make sure there's a value // if (child.getValue() == null) { continue; } // // What kind is it? // if (child.getValue() instanceof ApplyType) { items.add(child.getValue()); // // Do we add its children? // if (recursive) { items.addAll(this.getChildrenIds((ApplyType) child.getValue(), true)); } } else if (child.getValue() instanceof AttributeValueType) { items.add(child.getValue()); } else if (child.getValue() instanceof AttributeDesignatorType) { items.add(child.getValue()); } else if (child.getValue() instanceof AttributeSelectorType) { items.add(child.getValue()); } else if (child.getValue() instanceof VariableReferenceType) { items.add(child.getValue()); } else if (child.getValue() instanceof FunctionType) { items.add(child.getValue()); } else if (child.getValue() instanceof ExpressionType) { items.add(child.getValue()); } } if (logger.isTraceEnabled()) { logger.trace("getChildrenIds " + apply.getFunctionId() + " (" + items.size() + "):" + items); } return items; }
Example 11
Source File: JMSTestUtil.java From cxf with Apache License 2.0 | 5 votes |
private static void loadTestCases() throws Exception { JAXBContext context = JAXBContext.newInstance("org.apache.cxf.testsuite.testcase"); Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBElement<?> e = (JAXBElement<?>)unmarshaller.unmarshal(new JMSTestUtil().getClass() .getResource("/org/apache/cxf/jms/testsuite/util/testcases.xml")); testcases = (TestCasesType)e.getValue(); }
Example 12
Source File: TexturedSurface200Marshaller.java From citygml4j with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public AppearancePropertyType marshalAppearanceProperty(_AppearanceProperty src) { AppearancePropertyType dest = tex.createAppearancePropertyType(); if (src.isSetOrientation()) dest.setOrientation(src.getOrientation().getValue()); if (src.isSetAppearance()) { JAXBElement<?> elem = jaxb.marshalJAXBElement(src.getAppearance()); if (elem != null && elem.getValue() instanceof AbstractAppearanceType) dest.set_Appearance((JAXBElement<? extends AbstractAppearanceType>)elem); } if (src.isSetRemoteSchema()) dest.setRemoteSchema(src.getRemoteSchema()); if (src.isSetType()) dest.setType(TypeType.fromValue(src.getType().getValue())); if (src.isSetHref()) dest.setHref(src.getHref()); if (src.isSetRole()) dest.setRole(src.getRole()); if (src.isSetArcrole()) dest.setArcrole(src.getArcrole()); if (src.isSetTitle()) dest.setTitle(src.getTitle()); if (src.isSetShow()) dest.setShow(ShowType.fromValue(src.getShow().getValue())); if (src.isSetActuate()) dest.setActuate(ActuateType.fromValue(src.getActuate().getValue())); return dest; }
Example 13
Source File: GMLMarshaller.java From citygml4j with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public RectifiedGridCoverageType marshalRectifiedGridCoverage(RectifiedGridCoverage src) { RectifiedGridCoverageType dest = gml.createRectifiedGridCoverageType(); marshalAbstractDiscreteCoverage(src, dest); if (src.isSetRectifiedGridDomain()) { JAXBElement<?> elem = jaxb.marshalJAXBElement(src.getRectifiedGridDomain()); if (elem != null && elem.getValue() instanceof RectifiedGridDomainType) dest.setDomainSet((JAXBElement<? extends DomainSetType>)elem); } return dest; }
Example 14
Source File: CounterSignatureValidationTest.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void verifyETSIValidationReport(ValidationReportType etsiValidationReportJaxb) { super.verifyETSIValidationReport(etsiValidationReportJaxb); int countSignatures = 0; int countCounterSignatures = 0; String etsiCounterSignatureId = null; List<SignatureValidationReportType> reports = etsiValidationReportJaxb.getSignatureValidationReport(); for (SignatureValidationReportType signatureValidationReport : reports) { boolean containsCounterSignatures = false; SignatureAttributesType signatureAttributes = signatureValidationReport.getSignatureAttributes(); List<Object> signatureAttributeObjects = signatureAttributes.getSigningTimeOrSigningCertificateOrDataObjectFormat(); for (Object signatureAttributeObj : signatureAttributeObjects) { if (signatureAttributeObj instanceof JAXBElement) { JAXBElement jaxbElement = (JAXBElement) signatureAttributeObj; Object value = jaxbElement.getValue(); if (value instanceof SACounterSignatureType) { SACounterSignatureType counterSignatureType = (SACounterSignatureType) jaxbElement.getValue(); assertNotNull(counterSignatureType.getAttributeObject()); assertEquals(1, counterSignatureType.getAttributeObject().size()); assertTrue(Utils.isCollectionNotEmpty(counterSignatureType.getAttributeObject())); assertNotNull(counterSignatureType.getCounterSignature()); ValidationObjectType counterSignatureReference = (ValidationObjectType) counterSignatureType.getAttributeObject().get(0).getVOReference().get(0); etsiCounterSignatureId = counterSignatureReference.getId(); countCounterSignatures++; containsCounterSignatures = true; } } } if (!containsCounterSignatures) { countSignatures++; } } assertEquals(1, countSignatures); assertEquals(1, countCounterSignatures); assertNotNull(etsiCounterSignatureId); assertEquals(ddCounterSignatureId, etsiCounterSignatureId); }
Example 15
Source File: Tunnel200Marshaller.java From citygml4j with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public IntTunnelInstallationPropertyType marshalIntTunnelInstallationProperty(IntTunnelInstallationProperty src) { IntTunnelInstallationPropertyType dest = tun.createIntTunnelInstallationPropertyType(); if (src.isSetIntTunnelInstallation()) { JAXBElement<?> elem = jaxb.marshalJAXBElement(src.getIntTunnelInstallation()); if (elem != null && elem.getValue() instanceof IntTunnelInstallationType) dest.set_CityObject((JAXBElement<? extends IntTunnelInstallationType>)elem); } if (src.isSetGenericADEElement()) { Element element = jaxb.getADEMarshaller().marshalDOMElement(src.getGenericADEElement()); if (element != null) dest.set_ADEComponent(element); } if (src.isSetRemoteSchema()) dest.setRemoteSchema(src.getRemoteSchema()); if (src.isSetType()) dest.setType(TypeType.fromValue(src.getType().getValue())); if (src.isSetHref()) dest.setHref(src.getHref()); if (src.isSetRole()) dest.setRole(src.getRole()); if (src.isSetArcrole()) dest.setArcrole(src.getArcrole()); if (src.isSetTitle()) dest.setTitle(src.getTitle()); if (src.isSetShow()) dest.setShow(ShowType.fromValue(src.getShow().getValue())); if (src.isSetActuate()) dest.setActuate(ActuateType.fromValue(src.getActuate().getValue())); return dest; }
Example 16
Source File: Bridge200Marshaller.java From citygml4j with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public IntBridgeInstallationPropertyType marshalIntBridgeInstallationProperty(IntBridgeInstallationProperty src) { IntBridgeInstallationPropertyType dest = brid.createIntBridgeInstallationPropertyType(); if (src.isSetIntBridgeInstallation()) { JAXBElement<?> elem = jaxb.marshalJAXBElement(src.getIntBridgeInstallation()); if (elem != null && elem.getValue() instanceof IntBridgeInstallationType) dest.set_CityObject((JAXBElement<? extends IntBridgeInstallationType>)elem); } if (src.isSetGenericADEElement()) { Element element = jaxb.getADEMarshaller().marshalDOMElement(src.getGenericADEElement()); if (element != null) dest.set_ADEComponent(element); } if (src.isSetRemoteSchema()) dest.setRemoteSchema(src.getRemoteSchema()); if (src.isSetType()) dest.setType(TypeType.fromValue(src.getType().getValue())); if (src.isSetHref()) dest.setHref(src.getHref()); if (src.isSetRole()) dest.setRole(src.getRole()); if (src.isSetArcrole()) dest.setArcrole(src.getArcrole()); if (src.isSetTitle()) dest.setTitle(src.getTitle()); if (src.isSetShow()) dest.setShow(ShowType.fromValue(src.getShow().getValue())); if (src.isSetActuate()) dest.setActuate(ActuateType.fromValue(src.getActuate().getValue())); return dest; }
Example 17
Source File: DefaultDMNValidator.java From jdmn with Apache License 2.0 | 4 votes |
protected void validateDecision(TDecision decision, DMNModelRepository dmnModelRepository, List<String> errors) { TDefinitions model = dmnModelRepository.getModel(decision); validateNamedElement(decision, errors); TInformationItem variable = decision.getVariable(); validateVariable(decision, variable, errors); String decisionName = decision.getName(); if (variable != null) { // decision/@name == decision/variable/@name String variableName = variable.getName(); if (!decisionName.equals(variableName)) { errors.add(String.format("Decision name and variable name should be the same. Found '%s' and '%s'", decisionName, variableName)); } // decision/variable/@typeRef is not null QualifiedName typeRef = QualifiedName.toQualifiedName(model, variable.getTypeRef()); if (typeRef == null) { errors.add(String.format("Variable typRef is missing in decision '%s'", decisionName)); } } else { errors.add(String.format("Missing variable for '%s'", decision.getName())); } // Validate requirements List<TInformationRequirement> informationRequirement = decision.getInformationRequirement(); Function<TDMNElement, String> accessor = (TDMNElement e) -> { TInformationRequirement ir = (TInformationRequirement) e; if (ir.getRequiredInput() != null) { return ir.getRequiredInput().getHref(); } else { return ir.getRequiredDecision().getHref(); } }; validateUnique("TInformationRequirement", "href", false, dmnModelRepository, informationRequirement, accessor, decision.getName(), errors); // Validate expression JAXBElement<? extends TExpression> element = decision.getExpression(); if (element != null && element.getValue() != null) { validateExpression(decisionName, element, errors); } }
Example 18
Source File: AbstractPkiFactoryTestValidation.java From dss with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("rawtypes") protected void validateETSISignatureAttributes(SignatureAttributesType signatureAttributes) { List<Object> signatureAttributeObjects = signatureAttributes.getSigningTimeOrSigningCertificateOrDataObjectFormat(); assertTrue(Utils.isCollectionNotEmpty(signatureAttributeObjects)); for (Object signatureAttributeObj : signatureAttributeObjects) { if (signatureAttributeObj instanceof JAXBElement) { JAXBElement jaxbElement = (JAXBElement) signatureAttributeObj; Object value = jaxbElement.getValue(); if (value instanceof SASigningTimeType) { SASigningTimeType signingTime = (SASigningTimeType) value; assertNotNull(signingTime.getTime()); } else if (value instanceof SACertIDListType) { SACertIDListType certIdList = (SACertIDListType) value; List<SACertIDType> certIds = certIdList.getCertID(); for (SACertIDType saCertIDType : certIds) { assertNotNull(saCertIDType.getDigestMethod()); assertNotNull(saCertIDType.getDigestValue()); assertNotNull(saCertIDType.getX509IssuerSerial()); } } else if (value instanceof SADataObjectFormatType) { SADataObjectFormatType dataObjectFormatType = (SADataObjectFormatType) value; assertTrue((dataObjectFormatType.getContentType() != null) || (dataObjectFormatType.getMimeType() != null)); } else if (value instanceof SATimestampType) { SATimestampType timestamp = (SATimestampType) value; assertNotNull(timestamp.getAttributeObject()); assertNotNull(timestamp.getTimeStampValue()); } else if (value instanceof SAMessageDigestType) { SAMessageDigestType md = (SAMessageDigestType) value; validateETSIMessageDigest(md); } else if (value instanceof SAReasonType) { SAReasonType reasonType = (SAReasonType) value; validateETSISAReasonType(reasonType); } else if (value instanceof SAFilterType) { SAFilterType filterType = (SAFilterType) value; validateETSIFilter(filterType); } else if (value instanceof SASubFilterType) { SASubFilterType subFilterType = (SASubFilterType) value; validateETSISubFilter(subFilterType); } else if (value instanceof SANameType) { SANameType nameType = (SANameType) value; validateETSISAName(nameType); } else if (value instanceof SAContactInfoType) { SAContactInfoType contactTypeInfo = (SAContactInfoType) value; validateETSIContactInfo(contactTypeInfo); } else if (value instanceof SADSSType) { SADSSType dss = (SADSSType) value; validateETSIDSSType(dss); } else if (value instanceof SAVRIType) { SAVRIType vri = (SAVRIType) value; validateETSIVRIType(vri); } else if (value instanceof SARevIDListType) { SARevIDListType revIdList = (SARevIDListType) value; validateETSIRevIDListType(revIdList); } else if (value instanceof SASigPolicyIdentifierType) { SASigPolicyIdentifierType saSigPolicyIdentifier = (SASigPolicyIdentifierType) value; validateETSISASigPolicyIdentifierType(saSigPolicyIdentifier); } else if ("ByteRange".equals(jaxbElement.getName().getLocalPart())) { assertTrue(value instanceof List<?>); List<?> byteArray = (List<?>) value; validateETSIByteArray(byteArray); } else { LOG.warn("{} not tested", value.getClass()); } } else { fail("Only JAXBElement are accepted"); } } }
Example 19
Source File: ScuflParser.java From incubator-taverna-language with Apache License 2.0 | 4 votes |
private void parseProcessorElement(JAXBElement<?> processorElement) { Object processorElementValue = processorElement.getValue(); parseExtensionObject(processorElementValue); }
Example 20
Source File: MCRActionMappingsManager.java From mycore with GNU General Public License v3.0 | 4 votes |
public static MCRActionMappings getActionMappings() throws TransformerException, JAXBException { Source source = MCRURIResolver.instance().resolve("resource:actionmappings.xml", null); Unmarshaller unmarshaller = MCRConstants.JAXB_CONTEXT.createUnmarshaller(); JAXBElement<MCRActionMappings> jaxbElement = unmarshaller.unmarshal(source, MCRActionMappings.class); return jaxbElement.getValue(); }