Example usage for javax.xml.namespace QName equals

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

Introduction

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

Prototype

public final boolean equals(Object objectToTest) 

Source Link

Document

Test this QName for equality with another Object.

If the Object to be tested is not a QName or is null, then this method returns false.

Two QNames are considered equal if and only if both the Namespace URI and local part are equal.

Usage

From source file:org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.java

private void unwrapUsually(Binder<Node> binder, Node doc) throws JAXBException {

    jaxbElement = (E) XmlUtils.unwrap(binder.unmarshal(doc));
    // Unwrap, so we have eg CTEndnotes, not JAXBElement

    // .. but we do need to leave it wrapped, 
    // if there is not @XmlRootElement annotation 
    if (jaxbElement instanceof org.docx4j.dml.chartDrawing.CTDrawing) {
        // Check it
        Object tmp = binder.unmarshal(doc);
        if (tmp instanceof javax.xml.bind.JAXBElement) {
            QName qname = ((javax.xml.bind.JAXBElement) tmp).getName();
            if (qname.equals(org.docx4j.dml.chart.ObjectFactory._UserShapes_QNAME)) {
                jaxbElement = (E) tmp;//from w w w  .  ja v a2  s . c o  m
            }
        }
    }

}

From source file:org.eclipse.winery.repository.backend.BackendUtils.java

/**
 * @param qNameOfTheType the QName of the type, where all TOSCAComponentIds,
 *            where the associated element points to the type
 * @param clazz the Id class of the entities to discover
 *//*from w  w  w. j  a v a 2s .  co m*/
public static <X extends TOSCAComponentId> Collection<X> getAllElementsRelatedWithATypeAttribute(Class<X> clazz,
        QName qNameOfTheType) {
    // we do not use any database system,
    // therefore we have to crawl through each node type implementation by ourselves
    SortedSet<X> allIds = Repository.INSTANCE.getAllTOSCAComponentIds(clazz);
    Collection<X> res = new HashSet<>();
    for (X id : allIds) {
        IHasTypeReference resource;
        try {
            resource = (IHasTypeReference) AbstractComponentsResource.getComponentInstaceResource(id);
        } catch (ClassCastException e) {
            String error = "Requested following the type, but the component instance does not implmenet IHasTypeReference";
            BackendUtils.logger.error(error);
            throw new IllegalStateException(error);
        }
        // The resource may have been freshly initialized due to existence of a directory
        // then it has no node type assigned leading to ntiRes.getType() being null
        // we ignore this error here
        if (qNameOfTheType.equals(resource.getType())) {
            // the component instance is an implementation of the associated node type
            res.add(id);
        }
    }
    return res;
}

From source file:org.enhydra.shark.asap.util.BeanSerializerShark.java

/**
 * Check for meta-data in the bean that will tell us if any of the
 * properties are actually attributes, add those to the element
 * attribute list/*from w ww  .  ja v a2s.co  m*/
 *
 * @param value the object we are serializing
 * @return attributes for this element, null if none
 */
protected Attributes getObjectAttributes(Object value, Attributes attributes, SerializationContext context) {

    if (typeDesc == null || !typeDesc.hasAttributes())
        return attributes;

    AttributesImpl attrs;
    if (attributes == null) {
        attrs = new AttributesImpl();
    } else if (attributes instanceof AttributesImpl) {
        attrs = (AttributesImpl) attributes;
    } else {
        attrs = new AttributesImpl(attributes);
    }

    try {
        // Find each property that is an attribute
        // and add it to our attribute list
        for (int i = 0; i < propertyDescriptor.length; i++) {
            String propName = propertyDescriptor[i].getName();
            if (propName.equals("class"))
                continue;

            FieldDesc field = typeDesc.getFieldByName(propName);
            // skip it if its not an attribute
            if (field == null || field.isElement())
                continue;

            QName qname = field.getXmlName();
            if (qname == null) {
                qname = new QName("", propName);
            }

            if (propertyDescriptor[i].isReadable() && !propertyDescriptor[i].isIndexed()) {
                // add to our attributes
                Object propValue = propertyDescriptor[i].get(value);
                // Convert true/false to 1/0 in case of soapenv:mustUnderstand
                if (qname.equals(new QName(Constants.URI_SOAP11_ENV, Constants.ATTR_MUST_UNDERSTAND))) {
                    if (propValue.equals(Boolean.TRUE)) {
                        propValue = "1";
                    } else if (propValue.equals(Boolean.FALSE)) {
                        propValue = "0";
                    }
                }
                // If the property value does not exist, don't serialize
                // the attribute.  In the future, the decision to serializer
                // the attribute may be more sophisticated.  For example, don't
                // serialize if the attribute matches the default value.
                if (propValue != null) {
                    setAttributeProperty(propValue, qname, field.getXmlType(), attrs, context);
                }
            }
        }
    } catch (Exception e) {
        // no attributes
        return attrs;
    }

    return attrs;
}

From source file:org.expath.servlex.processors.saxon.SaxonSerializer.java

@Override
public void setExtension(QName name, String value) throws TechnicalException {
    if (name.equals(S_ATTRIBUTE_ORDER)) {
        throw new TechnicalException("Output property attribute not supported yet: " + name);
    } else if (name.equals(S_CHARACTER_REPRESENTATION)) {
        mySaxonCharacterRepresentation = value;
    } else if (name.equals(S_DOUBLE_SPACE)) {
        mySaxonDoubleSpace = value;/* w  ww .  java2 s .  c  om*/
    } else if (name.equals(S_IMPLICIT_RESULT_DOCUMENT)) {
        throw new TechnicalException("Output property attribute not supported: " + name);
    } else if (name.equals(S_INDENT_SPACES)) {
        mySaxonIndentSpaces = value;
    } else if (name.equals(S_LINE_LENGTH)) {
        mySaxonLineLength = value;
    } else if (name.equals(S_NEXT_IN_CHAIN)) {
        throw new TechnicalException("Output property attribute not supported: " + name);
    } else if (name.equals(S_NEXT_IN_CHAIN_BASE_URI)) {
        throw new TechnicalException("Output property attribute not supported: " + name);
    } else if (name.equals(S_RECOGNIZE_BINARY)) {
        mySaxonRecognizeBinary = value;
    } else if (name.equals(S_REQUIRE_WELL_FORMED)) {
        mySaxonRequireWellFormed = value;
    } else if (name.equals(S_STYLESHEET_VERSION)) {
        mySaxonStylesheetVersion = value;
    } else if (name.equals(S_SUPPLY_SOURCE_LOCATOR)) {
        throw new TechnicalException("Output property attribute not supported: " + name);
    } else if (name.equals(S_SUPPRESS_INDENTATION)) {
        mySaxonSuppressIndentation = value;
    } else if (name.equals(S_WRAP)) {
        mySaxonWrap = value;
    } else {
        throw new TechnicalException("Unknown output property attribute: " + name);
    }
}

From source file:org.geoserver.backuprestore.reader.CatalogFileReader.java

private void readToEndFragment(QName fragmentRootElementName) throws XMLStreamException {
    while (true) {
        XMLEvent nextEvent = eventReader.nextEvent();
        if (nextEvent.isEndElement() && fragmentRootElementName.equals(((EndElement) nextEvent).getName())) {
            return;
        }//from   w ww.  ja va  2 s.  c o m
    }
}

From source file:org.geoserver.data.test.SystemTestData.java

/**
 * Adds one of the default raster layers.
 * <p>/*w w  w  .j  ava 2  s  .c  o m*/
 *  The <tt>name</tt> parameter must be one of:
 *  <ul>
 *  <li>{@link CiteTestData#TASMANIA_BM}
 *  <li>{@link CiteTestData#TASMANIA_DEM}
 *  <li>{@link CiteTestData#ROTATED_CAD}
 *  <li>{@link CiteTestData#WORLD}
 * </ul>
 * </p>
 */
public void addDefaultRasterLayer(QName name, Catalog catalog) throws IOException {
    if (name.equals(TASMANIA_DEM)) {
        addRasterLayer(name, "tazdem.tiff", null, catalog);
    } else if (name.equals(TASMANIA_BM)) {
        addRasterLayer(name, "tazbm.tiff", null, catalog);
    } else if (name.equals(ROTATED_CAD)) {
        addRasterLayer(name, "rotated.tiff", null, catalog);
    } else if (name.equals(WORLD)) {
        addRasterLayer(name, "world.tiff", null, catalog);
    } else if (name.equals(MULTIBAND)) {
        addRasterLayer(name, "multiband.tiff", null, catalog);
    } else {
        throw new IllegalArgumentException("Unknown default raster layer: " + name);
    }
}

From source file:org.geoserver.gss.HTTPGSSClient.java

public long getCentralRevision(QName layerName) throws IOException {
    // execute the GetCentralRevision call
    GetMethod method = new GetMethod(address + "?service=GSS&version=1.0.0&request=GetCentralRevision&typeName="
            + prefixedName(layerName));/*  w w  w.jav  a2s .  co m*/
    Object response = executeMethod(method);

    // interpret the parsed response
    if (response instanceof CentralRevisionsType) {
        CentralRevisionsType cr = (CentralRevisionsType) response;
        for (LayerRevision lr : cr.getLayerRevisions()) {
            if (layerName.equals(lr.getTypeName())) {
                return lr.getCentralRevision();
            }
        }
        throw new IOException("Response to GetCentralRevision received, but it "
                + "did not contain a central revision for " + layerName);
    } else {
        if (response == null) {
            throw new IOException("The response was parsed to a null object");
        }
        throw new IOException("The response was parsed to an unrecognized object type: " + response.getClass());
    }
}

From source file:org.geowebcache.georss.StaxGeoRSSReader.java

private Entry parseEntry() throws XMLStreamException {
    reader.require(START_ELEMENT, ATOM.NSURI, ATOM.entry.getLocalPart());

    Entry entry = new Entry();

    logger.trace("Parsing GeoRSS entry...");

    while (true) {
        reader.next();/*from   w  w  w  . ja  va2 s  . c o  m*/
        if (reader.isStartElement()) {
            QName name = reader.getName();
            parseEntryMember(reader, name, entry);
        } else if (reader.isEndElement()) {
            if (ATOM.entry.equals(reader.getName())) {
                break;
            }
        }
    }

    logger.trace("Done parsing GeoRSS entry.");

    reader.require(END_ELEMENT, ATOM.NSURI, ATOM.entry.getLocalPart());

    QName nextTag;
    while ((nextTag = nextTag(reader)) != null) {
        // position parser ready for next entry
        if (reader.isStartElement() && nextTag.equals(ATOM.entry)) {
            break;
        }
    }

    if (END_DOCUMENT == reader.getEventType()) {
        reader.close();
        reader = null;
    }

    return entry;
}

From source file:org.jasig.portal.portlet.rendering.PortletEventCoordinatationService.java

protected boolean supportsEvent(Event event, IPortletDefinitionId portletDefinitionId) {
    final QName eventName = event.getQName();

    //The cache key to use
    final Tuple<IPortletDefinitionId, QName> key = new Tuple<IPortletDefinitionId, QName>(portletDefinitionId,
            eventName);//from  ww  w.jav a  2  s .c o  m

    //Check in the cache if the portlet definition supports this event
    final Element element = this.supportedEventCache.get(key);
    if (element != null) {
        final Boolean supported = (Boolean) element.getValue();
        if (supported != null) {
            return supported;
        }
    }

    final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry
            .getParentPortletApplicationDescriptor(portletDefinitionId);
    if (portletApplicationDescriptor == null) {
        return false;
    }

    final Set<QName> aliases = this.getAllAliases(eventName, portletApplicationDescriptor);

    final String defaultNamespace = portletApplicationDescriptor.getDefaultNamespace();

    //No support found so far, do more complex namespace matching
    final PortletDefinition portletDescriptor = this.portletDefinitionRegistry
            .getParentPortletDescriptor(portletDefinitionId);
    if (portletDescriptor == null) {
        return false;
    }

    final List<? extends EventDefinitionReference> supportedProcessingEvents = portletDescriptor
            .getSupportedProcessingEvents();
    for (final EventDefinitionReference eventDefinitionReference : supportedProcessingEvents) {
        final QName qualifiedName = eventDefinitionReference.getQualifiedName(defaultNamespace);
        if (qualifiedName == null) {
            continue;
        }

        //See if the supported qname and event qname match explicitly
        //Look for alias names
        if (qualifiedName.equals(eventName) || aliases.contains(qualifiedName)) {
            this.supportedEventCache.put(new Element(key, Boolean.TRUE));
            return true;
        }

        //Look for namespaced events
        if (StringUtils.isEmpty(qualifiedName.getNamespaceURI())) {
            final QName namespacedName = new QName(defaultNamespace, qualifiedName.getLocalPart());
            if (eventName.equals(namespacedName)) {
                this.supportedEventCache.put(new Element(key, Boolean.TRUE));
                return true;
            }
        }
    }

    this.supportedEventCache.put(new Element(key, Boolean.FALSE));
    return false;
}

From source file:org.jboss.bpm.console.server.util.DOMUtils.java

private static void search(List<Element> list, Element baseElement, QName nodeName, boolean recursive) {
    if (nodeName == null) {
        list.add(baseElement);/*from  ww w .j  a  va2s  .  co  m*/
    } else {
        QName qname;
        if (nodeName.getNamespaceURI().length() > 0) {
            qname = new QName(baseElement.getNamespaceURI(), baseElement.getLocalName());
        } else {
            qname = new QName(baseElement.getLocalName());
        }
        if (qname.equals(nodeName)) {
            list.add(baseElement);
        }
    }
    if (recursive) {
        NodeList nlist = baseElement.getChildNodes();
        for (int i = 0; i < nlist.getLength(); i++) {
            Node child = nlist.item(i);
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                search(list, (Element) child, nodeName, recursive);
            }
        }
    }
}