Example usage for javax.xml.namespace QName getNamespaceURI

List of usage examples for javax.xml.namespace QName getNamespaceURI

Introduction

In this page you can find the example usage for javax.xml.namespace QName getNamespaceURI.

Prototype

public String getNamespaceURI() 

Source Link

Document

Get the Namespace URI of this QName.

Usage

From source file:org.cloudgraph.config.CloudGraphConfig.java

/**
 * Returns a table configuration for the given qualified SDO 
 * Type name or null if not found.// w w w  .  jav a 2  s.  c  o m
 * @param typeName the qualified name of an SDO Type 
 * @return the table configuration or null if not found
 */
public TableConfig findTable(QName typeName) {
    PlasmaType type = (PlasmaType) PlasmaTypeHelper.INSTANCE.getType(typeName.getNamespaceURI(),
            typeName.getLocalPart());
    return this.graphURIToTableMap.get(type.getQualifiedName());
}

From source file:org.cloudgraph.store.mapping.StoreMapping.java

private void mapDataGraph(DataGraphMapping dataGraphConfig) {

    QName qname = new QName(dataGraphConfig.getGraph().getUri(), dataGraphConfig.getGraph().getType());
    PlasmaType configuredType = (PlasmaType) PlasmaTypeHelper.INSTANCE.getType(qname.getNamespaceURI(),
            qname.getLocalPart());/*www.  j  a  va  2s. co  m*/
    // if (configuredType.isAbstract())
    // throw new
    // CloudGraphConfigurationException("a data graph definition within table '"
    // + table.getName() + "' has an abstract type (uri/name), "
    // + graph.getUri() + "#" + graph.getType() +
    // " - use a non abstract type");
    if (graphURIToTableMap.get(qname) != null)
        throw new StoreMappingException("a data graph definition already exists within table '"
                + dataGraphConfig.getTable().getTable().getName() + "' for type (uri/name), "
                + dataGraphConfig.getGraph().getUri() + "#" + dataGraphConfig.getGraph().getType());
    graphURIToTableMap.put(qname, dataGraphConfig.getTable());
    graphURIToGraphMap.put(qname, dataGraphConfig);
    /*
     * Map<QName, PlasmaType> hierarchy = new HashMap<QName, PlasmaType>();
     * this.collectTypeHierarchy(configuredType, hierarchy);
     * 
     * for (PlasmaType type : hierarchy.values()) { qname =
     * type.getQualifiedName(); if (graphURIToTableMap.get(qname) != null) throw
     * new CloudGraphConfigurationException(
     * "a data graph definition already exists within table '" + table.getName()
     * + "' for type (uri/name), " + graph.getUri() + "#" + graph.getType());
     * graphURIToTableMap.put(qname, tableConfig); graphURIToGraphMap.put(qname,
     * dataGraphConfig); }
     */
}

From source file:org.cloudgraph.store.mapping.StoreMapping.java

@Override
public TableMapping findTable(QName typeName) {
    lock.readLock().lock();/*from   w ww  . j av a 2s .co  m*/
    try {
        PlasmaType type = (PlasmaType) PlasmaTypeHelper.INSTANCE.getType(typeName.getNamespaceURI(),
                typeName.getLocalPart());
        return this.graphURIToTableMap.get(type.getQualifiedName());
    } finally {
        lock.readLock().unlock();
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.CswMarshallHelper.java

static void writeValue(HierarchicalStreamWriter writer, MarshallingContext context,
        AttributeDescriptor attributeDescriptor, QName field, Serializable value) {

    String xmlValue = null;//from  www .j av  a  2 s . c om
    AttributeType.AttributeFormat attrFormat = null;

    if (attributeDescriptor != null && attributeDescriptor.getType() != null) {
        attrFormat = attributeDescriptor.getType().getAttributeFormat();
    }

    if (attrFormat == null) {
        attrFormat = AttributeType.AttributeFormat.STRING;
    }

    String name = null;

    if (!StringUtils.isBlank(field.getNamespaceURI())) {
        if (!StringUtils.isBlank(field.getPrefix())) {
            name = field.getPrefix() + CswConstants.NAMESPACE_DELIMITER + field.getLocalPart();
        } else {
            name = field.getLocalPart();
        }
    } else {
        name = field.getLocalPart();
    }

    switch (attrFormat) {
    case BINARY:
        xmlValue = Base64.getEncoder().encodeToString((byte[]) value);
        break;
    case DATE:
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime((Date) value);
        xmlValue = XSD_FACTORY.newXMLGregorianCalendar(cal).toXMLFormat();
        break;
    case OBJECT:
        break;
    case GEOMETRY:
    case XML:
    default:
        xmlValue = value.toString();
        break;
    }

    // Write the node if we were able to convert it.
    if (xmlValue != null) {
        writer.startNode(name);

        if (!StringUtils.isBlank(field.getNamespaceURI())) {
            if (StringUtils.isBlank(field.getPrefix())) {
                writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE, field.getNamespaceURI());
            }
        }

        writer.setValue(xmlValue);
        writer.endNode();
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.impl.CswRecordConverter.java

private void writeValue(HierarchicalStreamWriter writer, MarshallingContext context,
        AttributeDescriptor attributeDescriptor, QName field, Serializable value) {

    String xmlValue = null;//from   ww  w  . ja v  a2s  .co m

    AttributeFormat attrFormat = null;
    if (attributeDescriptor != null && attributeDescriptor.getType() != null) {
        attrFormat = attributeDescriptor.getType().getAttributeFormat();
    }
    if (attrFormat == null) {
        attrFormat = AttributeFormat.STRING;
    }
    String name = null;
    if (!StringUtils.isBlank(field.getNamespaceURI())) {
        if (!StringUtils.isBlank(field.getPrefix())) {
            name = field.getPrefix() + CswConstants.NAMESPACE_DELIMITER + field.getLocalPart();
        } else {
            name = field.getLocalPart();
        }
    } else {
        name = field.getLocalPart();
    }
    switch (attrFormat) {
    case BINARY:
        xmlValue = Base64.encodeBase64String((byte[]) value);
        break;
    case DATE:
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime((Date) value);
        xmlValue = XSD_FACTORY.newXMLGregorianCalendar(cal).toXMLFormat();
        break;
    case OBJECT:
        break;
    case GEOMETRY:
    case XML:
    default:
        xmlValue = value.toString();
        break;
    }
    // Write the node if we were able to convert it.
    if (xmlValue != null) {
        writer.startNode(name);
        if (!StringUtils.isBlank(field.getNamespaceURI())) {
            if (!StringUtils.isBlank(field.getPrefix())) {
                writeNamespace(writer, field);
            } else {
                writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE, field.getNamespaceURI());
            }
        }

        writer.setValue(xmlValue);
        writer.endNode();
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.impl.CswRecordConverter.java

private void writeNamespace(HierarchicalStreamWriter writer, QName field) {
    if (prefixToUriMapping == null || !prefixToUriMapping.containsKey(field.getPrefix())
            || !prefixToUriMapping.get(field.getPrefix()).equals(field.getNamespaceURI())) {
        writer.addAttribute(XMLConstants.XMLNS_ATTRIBUTE + CswConstants.NAMESPACE_DELIMITER + field.getPrefix(),
                field.getNamespaceURI());
    }//from w  ww  .j  ava  2 s.c o  m
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.Validator.java

/**
 * Verifies that that if types are passed, then they are fully qualified
 *
 * @param types List of QNames representing types
 *///from www. j  a  va  2s  .  com
public void validateFullyQualifiedTypes(List<QName> types) throws CswException {
    for (QName type : types) {
        if (StringUtils.isBlank(type.getNamespaceURI())) {
            throw new CswException("Unqualified type name: '" + type.getLocalPart() + "'",
                    CswConstants.INVALID_PARAMETER_VALUE, null);
        }
    }
}

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

private Boolean processGmlType(XmlSchemaElement xmlSchemaElement) {
    QName qName = xmlSchemaElement.getSchemaTypeName();
    String name = xmlSchemaElement.getName();

    if (qName != null && StringUtils.isNotEmpty(name) && qName.getNamespaceURI().equals(gmlNamespace)
            && (qName.getLocalPart().equals("TimeInstantType")
                    || qName.getLocalPart().equals("TimePeriodType"))) {
        LOGGER.debug("Adding temporal property: {}", propertyPrefix + name);
        temporalProperties.add(propertyPrefix + name);

        boolean multiValued = xmlSchemaElement.getMaxOccurs() > 1 ? true : false;
        descriptors.add(/*from   w w w .  j  a  v a2 s. c o  m*/
                new FeatureAttributeDescriptor(propertyPrefix + name, name, isQueryable(name) /* indexed */,
                        true /* stored */, false /* tokenized */, multiValued, BasicTypes.DATE_TYPE));

        properties.add(propertyPrefix + name);

        return true;
    }

    if ((qName != null) && qName.getNamespaceURI().equals(gmlNamespace) && (!StringUtils.isEmpty(name))) {
        LOGGER.debug("Adding geo property: {}", propertyPrefix + name);
        gmlProperties.add(propertyPrefix + name);

        boolean multiValued = xmlSchemaElement.getMaxOccurs() > 1 ? true : false;
        descriptors.add(
                new FeatureAttributeDescriptor(propertyPrefix + name, name, isQueryable(name) /* indexed */,
                        true /* stored */, false /* tokenized */, multiValued, BasicTypes.GEO_TYPE));

        properties.add(propertyPrefix + name);

        return true;
    }

    return false;
}

From source file:org.codice.ddf.spatial.ogc.wfs.catalog.endpoint.WfsEndpoint.java

private XmlSchema buildMultipleFeatureTypeImportSchema(Set<QName> qnames) throws WfsException {
    XmlSchema schema = new XmlSchema("", new XmlSchemaCollection());
    schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
    schema.setTargetNamespace(XmlSchemaSerializer.XSD_NAMESPACE);
    NamespaceMap nsMap = new NamespaceMap();
    nsMap.add("", XmlSchemaSerializer.XSD_NAMESPACE);
    schema.setNamespaceContext(nsMap);//from w  ww  . j  a v a 2  s.c o  m
    for (QName qName : qnames) {
        XmlSchemaImport schemaImport = new XmlSchemaImport(schema);
        schemaImport.setNamespace(qName.getNamespaceURI());
        URI fullUri = UriBuilder.fromUri(uri.getBaseUri())
                .queryParam("request", Wfs10Constants.DESCRIBE_FEATURE_TYPE)
                .queryParam("version", Wfs10Constants.VERSION_1_0_0).queryParam("service", Wfs10Constants.WFS)
                .queryParam("typeName", (StringUtils.isEmpty(qName.getPrefix())) ? qName.getLocalPart()
                        : qName.getPrefix() + ":" + qName.getLocalPart())
                .build();
        schemaImport.setSchemaLocation(fullUri.toString());
        schema.getExternals().add(schemaImport);
    }
    return schema;
}

From source file:org.deegree.services.wfs.query.QueryAnalyzer.java

/**
 * Returns whether the propName has to be considered for re-qualification.
 * /*from www .j a  va 2s  .c o m*/
 * @param propName
 * @return
 */
private boolean isPrefixedAndBound(ValueReference propName) {
    QName name = propName.getAsQName();
    return !name.getPrefix().equals(DEFAULT_NS_PREFIX) && !name.getNamespaceURI().equals("");
}