Example usage for javax.xml.bind JAXBElement getName

List of usage examples for javax.xml.bind JAXBElement getName

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getName.

Prototype

public QName getName() 

Source Link

Document

Returns the xml element tag name.

Usage

From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java

private String extractPolygonMemberCoordinates(PolygonMemberType polygonMemberType1)
        throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    JAXBElement<? extends AbstractGeometryType> polygonGeometry1 = polygonMemberType1.getGeometry();
    assertThat(Wfs10Constants.POLYGON.getLocalPart().equals(polygonGeometry1.getName().getLocalPart()),
            is(Boolean.TRUE));//from w  ww  .  j a  v a  2  s.  c o  m
    PolygonType polygonType1 = (PolygonType) polygonGeometry1.getValue();
    LinearRingMemberType linearRingMemberType1 = polygonType1.getOuterBoundaryIs();
    JAXBElement<? extends AbstractGeometryType> linearRingGeometry1 = linearRingMemberType1.getGeometry();
    LinearRingType linearRingType1 = (LinearRingType) linearRingGeometry1.getValue();
    return linearRingType1.getCoordinates().getValue().replaceAll("\n", "").trim();
}

From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java

@Test
public void testGMLToGeometryCollectionType()
        throws JAXBException, SAXException, IOException, ParseException, NullPointerException {

    String geometryCollectionGML = Wfs10JTStoGML200Converter
            .convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION));
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter
            .convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
    assertFalse(geometryCollectionType == null);
    List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = geometryCollectionType
            .getGeometryMember();/*from w w w . ja va2 s  .  c o  m*/
    assertThat(CollectionUtils.isEmpty(geometryMembers), is(Boolean.FALSE));
    assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));

    GeometryAssociationType geometryAssociationType = geometryMembers.get(0).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement = geometryAssociationType.getGeometry();
    assertThat(Wfs10Constants.POINT.getLocalPart().equals(jaxbElement.getName().getLocalPart()),
            is(Boolean.TRUE));
    PointType pointType = (PointType) jaxbElement.getValue();
    assertThat(pointType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_POINT_COORD.equals(pointType.getCoordinates().getValue().trim()),
            is(Boolean.TRUE));

    GeometryAssociationType geometryAssociationType2 = geometryMembers.get(1).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement2 = geometryAssociationType2.getGeometry();
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(jaxbElement2.getName().getLocalPart()),
            is(Boolean.TRUE));
    LineStringType lineStringType = (LineStringType) jaxbElement2.getValue();
    assertThat(lineStringType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_LINESTRING_COORD.equals(lineStringType.getCoordinates().getValue().trim()),
            is(Boolean.TRUE));
}

From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.TestWfsFilterDelegate.java

private String fetchPropertyIsLikeExpression(PropertyIsLikeType compOpsType, String expressionType) {
    String result = null;/*  ww  w  . j av  a2  s .c o  m*/
    List<JAXBElement<?>> expressions = compOpsType.getExpression();
    for (JAXBElement<?> expression : expressions) {
        String item = expression.getName().getLocalPart();
        if (item.equals(VALUE_REFERENCE) && item.equals(expressionType)) {
            result = expression.getValue().toString();

        } else if (item.equals(LITERAL) && item.equals(expressionType)) {
            LiteralType literal = (LiteralType) expression.getValue();
            result = literal.getContent().get(0).toString();
        }
    }

    return result;
}

From source file:org.deegree.services.wms.SldStyleBuilder.java

private void extractFromSld(SLDStyleType sty, XMLAdapter adapter, File stylesDir, String layerName,
        Map<String, Pair<File, URL>> legends, Map<String, Boolean> glgUrls, Map<String, String> map)
        throws Throwable {
    String name = null, lastName = null;
    for (JAXBElement<?> elem : sty.getNameAndUserStyleAndLegendConfigurationFile()) {
        if (elem.getName().getLocalPart().equals("Name")) {
            name = elem.getValue().toString();
        } else if (elem.getName().getLocalPart().equals("LegendConfigurationFile")) {
            File legendFile = new File(adapter.resolve(elem.getValue().toString()).toURI());
            Style style = findStyle(legendFile, stylesDir, layerName);

            if (style != null) {
                if (name != null) {
                    style.setName(name);
                }//  w ww.j  a  va2  s  .  c  o m
                registry.putLegend(layerName, style, false);
            }
        } else if (elem.getName().getLocalPart().equals("LegendGraphicFile")) {
            LegendGraphicFile lgf = (LegendGraphicFile) elem.getValue();
            URL url = adapter.resolve(lgf.getValue());
            if (url.toURI().getScheme().equals("file")) {
                File legend = new File(url.toURI());
                legends.put(lastName, new Pair<File, URL>(legend, null));
            } else {
                legends.put(lastName, new Pair<File, URL>(null, url));
            }
            glgUrls.put(lastName, lgf.isOutputGetLegendGraphicUrl());
        } else if (elem.getName().getLocalPart().equals("UserStyle")) {
            if (name == null) {
                name = elem.getValue().toString();
            }
            LOG.debug("Will load user style with name '{}', it will be known as '{}'.", elem.getValue(), name);
            map.put(elem.getValue().toString(), name);
            lastName = name;
            name = null;
        }
    }
}

From source file:org.docx4j.XmlUtils.java

public static String JAXBElementDebug(javax.xml.bind.JAXBElement o) {

    String prefix = null;/*w  ww.j  a va 2  s . c o  m*/
    if (o.getName().getNamespaceURI() != null) {
        try {
            prefix = NamespacePrefixMapperUtils.getPreferredPrefix(o.getName().getNamespaceURI(), null, false);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }
    if (prefix != null) {
        return prefix + ':' + o.getName().getLocalPart()
                + " is a javax.xml.bind.JAXBElement; it has declared type " + o.getDeclaredType().getName();
    } else {
        return o.getName() + " is a javax.xml.bind.JAXBElement; it has declared type "
                + o.getDeclaredType().getName();
    }

}

From source file:org.docx4j.XmlUtils.java

/**
 * @param list//from   ww  w. j a va2s  . com
 * @param name
 * @return
 * @since 3.2.0
 */
public static JAXBElement<?> getListItemByQName(List<JAXBElement<?>> list, QName name) {

    for (JAXBElement<?> el : list) {

        if (el.getName().equals(name)) {
            return el;
        }
    }
    return null;
}

From source file:org.plasma.provisioning.xsd.ConstraintAssembler.java

public ValueConstraint buildValueConstraint(Restriction rest) {
    ValueConstraint constraint = new ValueConstraint();
    for (Object obj : rest.getMinExclusivesAndMinInclusivesAndMaxExclusives()) {
        if (obj instanceof JAXBElement<?>) {
            JAXBElement<Facet> facet = (JAXBElement<Facet>) obj;
            if (facet.getName().getLocalPart().equals("maxInclusive")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMaxInclusive(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("minInclusive")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMinInclusive(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("minExclusive")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMinExclusive(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("maxExclusive")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMaxExclusive(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("totalDigits")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setTotalDigits(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("fractionDigits")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setFractionDigits(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("maxLength")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMaxLength(numFacet.getValue());
            } else if (facet.getName().getLocalPart().equals("minLength")) {
                Facet numFacet = (Facet) facet.getValue();
                constraint.setMinLength(numFacet.getValue());
            }/*from w w w.j a  va 2 s.co m*/
        } else if (obj instanceof Pattern) {
            Pattern pattern = (Pattern) obj;
            constraint.setPattern(pattern.getValue());
        }
    } // for
    return constraint;
}

From source file:org.plasma.provisioning.xsd.SDOXSchemaConverter.java

@SuppressWarnings("unchecked")
private JAXBElement<Facet> findFacet(String name, List<Object> list) {
    for (Object obj : list) {
        if (obj instanceof JAXBElement<?>) {
            JAXBElement<Facet> facet = (JAXBElement<Facet>) obj;
            if (facet.getName().getLocalPart().equals(name))
                return facet;
        }//  w  ww.j  ava 2s .  c  o  m
    }
    return null;
}

From source file:org.wso2.carbon.identity.application.mgt.defaultsequence.DefaultAuthSeqMgtServiceImpl.java

/**
 * Convert xml file of default authentication sequence to object.
 *
 * @param defaultAuthSeq xml string of the default authentication sequence
 * @param tenantDomain   tenant domain name
 * @return LocalAndOutboundAuthenticationConfig instance
 * @throws DefaultAuthSeqMgtException Auth Sequence Management Client Exception
 *//*ww  w  . j  a va  2  s.  co  m*/
private LocalAndOutboundAuthenticationConfig unmarshalDefaultAuthSeq(String defaultAuthSeq, String tenantDomain)
        throws DefaultAuthSeqMgtException {

    if (StringUtils.isEmpty(defaultAuthSeq)) {
        throw new DefaultAuthSeqMgtException(
                new String[] { "Empty default authentication sequence " + "configuration is provided" });
    }
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(LocalAndOutboundAuthenticationConfig.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        JAXBElement<LocalAndOutboundAuthenticationConfig> root = unmarshaller.unmarshal(
                new StreamSource(new ByteArrayInputStream(defaultAuthSeq.getBytes(StandardCharsets.UTF_8))),
                LocalAndOutboundAuthenticationConfig.class);
        if (root.getName().getLocalPart()
                .equalsIgnoreCase(LocalAndOutboundAuthenticationConfig.class.getSimpleName())) {
            return root.getValue();
        }
        throw new DefaultAuthSeqMgtException(
                new String[] { "Syntax error in the provided default " + "authentication sequence" });
    } catch (JAXBException e) {
        String msg = "Error in reading default authentication sequence configuration in tenant: "
                + tenantDomain;
        log.error(msg, e);
        throw new DefaultAuthSeqMgtException(new String[] { msg });
    }
}

From source file:se.inera.axel.riv.internal.ShsToRivHeaderMapper.java

private SoapHeader createStringSoapHeader(QName qname, String to) {
    JAXBElement<String> toElement = new JAXBElement<>(qname, String.class, to);

    return new SoapHeader(toElement.getName(), toElement, STRING_JAXB_BINDING);
}