Java Code Examples for javax.xml.namespace.QName#valueOf()

The following examples show how to use javax.xml.namespace.QName#valueOf() . 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: DOMStreamReader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return an attribute's qname. Handle the case of DOM level 1 nodes.
 */
public QName getAttributeName(int index) {
    if (_state == START_ELEMENT) {
        Node attr = _currentAttributes.get(index);
        String localName = attr.getLocalName();
        if (localName != null) {
            String prefix = attr.getPrefix();
            String uri = attr.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(attr.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getAttributeName() called in illegal state");
}
 
Example 2
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return an attribute's qname. Handle the case of DOM level 1 nodes.
 */
public QName getAttributeName(int index) {
    if (_state == START_ELEMENT) {
        Node attr = _currentAttributes.get(index);
        String localName = attr.getLocalName();
        if (localName != null) {
            String prefix = attr.getPrefix();
            String uri = attr.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(attr.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getAttributeName() called in illegal state");
}
 
Example 3
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return an attribute's qname. Handle the case of DOM level 1 nodes.
 */
public QName getAttributeName(int index) {
    if (_state == START_ELEMENT) {
        Node attr = _currentAttributes.get(index);
        String localName = attr.getLocalName();
        if (localName != null) {
            String prefix = attr.getPrefix();
            String uri = attr.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(attr.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getAttributeName() called in illegal state");
}
 
Example 4
Source File: CoreXMLDeserializers.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Object _deserialize(String value, DeserializationContext ctxt)
    throws IOException
{
    switch (_kind) {
    case TYPE_DURATION:
        return _dataTypeFactory.newDuration(value);
    case TYPE_QNAME:
        return QName.valueOf(value);
    case TYPE_G_CALENDAR:
        Date d;
        try {
            d = _parseDate(value, ctxt);
        }
        catch (JsonMappingException e) {
            // try to parse from native XML Schema 1.0 lexical representation String,
            // which includes time-only formats not handled by parseXMLGregorianCalendarFromJacksonFormat(...)
            return _dataTypeFactory.newXMLGregorianCalendar(value);
        }
        return _gregorianFromDate(ctxt, d);
    }
    throw new IllegalStateException();
}
 
Example 5
Source File: DOMStreamReader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an element's qname. Handle the case of DOM level 1 nodes.
 */
public javax.xml.namespace.QName getName() {
    if (_state == START_ELEMENT || _state == END_ELEMENT) {
        String localName = _current.getLocalName();
        if (localName != null) {
            String prefix = _current.getPrefix();
            String uri = _current.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(_current.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getName() called in illegal state");
}
 
Example 6
Source File: JwsImplGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static boolean equalsNSOptional(String strQName, QName checkQN) {
        if (strQName == null)
                return false;
        strQName = strQName.trim();
        QName reqQN = QName.valueOf(strQName);

        if (reqQN.getNamespaceURI() == null || reqQN.getNamespaceURI().equals(""))
                return reqQN.getLocalPart().equals(checkQN.getLocalPart());

        return reqQN.equals(checkQN);
}
 
Example 7
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an element's qname. Handle the case of DOM level 1 nodes.
 */
public javax.xml.namespace.QName getName() {
    if (_state == START_ELEMENT || _state == END_ELEMENT) {
        String localName = _current.getLocalName();
        if (localName != null) {
            String prefix = _current.getPrefix();
            String uri = _current.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(_current.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getName() called in illegal state");
}
 
Example 8
Source File: JwsImplGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static boolean equalsNSOptional(String strQName, QName checkQN) {
        if (strQName == null)
                return false;
        strQName = strQName.trim();
        QName reqQN = QName.valueOf(strQName);

        if (reqQN.getNamespaceURI() == null || reqQN.getNamespaceURI().equals(""))
                return reqQN.getLocalPart().equals(checkQN.getLocalPart());

        return reqQN.equals(checkQN);
}
 
Example 9
Source File: DOMStreamReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an element's qname. Handle the case of DOM level 1 nodes.
 */
public javax.xml.namespace.QName getName() {
    if (_state == START_ELEMENT || _state == END_ELEMENT) {
        String localName = _current.getLocalName();
        if (localName != null) {
            String prefix = _current.getPrefix();
            String uri = _current.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(_current.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getName() called in illegal state");
}
 
Example 10
Source File: DeploymentDescriptorParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected QName getQNameAttribute(Attributes attrs, String name) {
    String value = getAttribute(attrs, name);
    if (value == null || value.equals("")) {
        return null;
    } else {
        return QName.valueOf(value);
    }
}
 
Example 11
Source File: JwsImplGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static boolean equalsNSOptional(String strQName, QName checkQN) {
        if (strQName == null)
                return false;
        strQName = strQName.trim();
        QName reqQN = QName.valueOf(strQName);

        if (reqQN.getNamespaceURI() == null || reqQN.getNamespaceURI().equals(""))
                return reqQN.getLocalPart().equals(checkQN.getLocalPart());

        return reqQN.equals(checkQN);
}
 
Example 12
Source File: DOMStreamReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return an element's qname. Handle the case of DOM level 1 nodes.
 */
public javax.xml.namespace.QName getName() {
    if (_state == START_ELEMENT || _state == END_ELEMENT) {
        String localName = _current.getLocalName();
        if (localName != null) {
            String prefix = _current.getPrefix();
            String uri = _current.getNamespaceURI();
            return new QName(fixNull(uri), localName, fixNull(prefix));
        }
        else {
            return QName.valueOf(_current.getNodeName());
        }
    }
    throw new IllegalStateException("DOMStreamReader: getName() called in illegal state");
}
 
Example 13
Source File: DeploymentDescriptorParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected QName getQNameAttribute(Attributes attrs, String name) {
    String value = getAttribute(attrs, name);
    if (value == null || value.equals("")) {
        return null;
    } else {
        return QName.valueOf(value);
    }
}
 
Example 14
Source File: MapAdapterTest.java    From tessera with Apache License 2.0 4 votes vote down vote up
@Test
public void unmarshal() throws Exception {

    ConfigProperties properties = new ConfigProperties();

    JAXBElement<String> someElement =
            new JAXBElement<>(QName.valueOf("message"), String.class, "I love sparrows!!");
    JAXBElement<String> someOtherElement = new JAXBElement<>(QName.valueOf("greeting"), String.class, "Hellow");

    properties.setProperties(Arrays.asList(someElement, someOtherElement));

    Map<String, String> result = adapter.unmarshal(properties);

    Map<String, String> map = new LinkedHashMap<>();
    map.put("message", "I love sparrows!!");
    map.put("greeting", "Hellow");

    assertThat(result).containsAllEntriesOf(map);
}
 
Example 15
Source File: TestJaxbAnnotationIntrospector.java    From jackson-modules-base with Apache License 2.0 4 votes vote down vote up
@Override
public QName unmarshal(String v) throws Exception
{
    return QName.valueOf(v);
}
 
Example 16
Source File: AbstractSTSClient.java    From steady with Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}
 
Example 17
Source File: AbstractSTSClient.java    From steady with Apache License 2.0 4 votes vote down vote up
public void setServiceName(String qn) {
    serviceName = QName.valueOf(qn);
}
 
Example 18
Source File: AbstractSTSClient.java    From steady with Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}
 
Example 19
Source File: WsgenOptions.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int parseArguments(String[] args, int i) throws BadCommandLineException {

    int j = super.parseArguments(args, i);
    if (args[i].equals(SERVICENAME_OPTION)) {
        serviceName = QName.valueOf(requireArgument(SERVICENAME_OPTION, args, ++i));
        if (serviceName.getNamespaceURI() == null || serviceName.getNamespaceURI().length() == 0) {
            throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_NAMESPACE(args[i]));
        }
        if (serviceName.getLocalPart() == null || serviceName.getLocalPart().length() == 0) {
            throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_LOCALNAME(args[i]));
        }
        return 2;
    } else if (args[i].equals(PORTNAME_OPTION)) {
        portName = QName.valueOf(requireArgument(PORTNAME_OPTION, args, ++i));
        if (portName.getNamespaceURI() == null || portName.getNamespaceURI().length() == 0) {
            throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_NAMESPACE(args[i]));
        }
        if (portName.getLocalPart() == null || portName.getLocalPart().length() == 0) {
            throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_LOCALNAME(args[i]));
        }
        return 2;
    } else if (args[i].equals("-r")) {
        nonclassDestDir = new File(requireArgument("-r", args, ++i));
        if (!nonclassDestDir.exists()) {
            throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(nonclassDestDir.getPath()));
        }
        return 2;
    } else if (args[i].startsWith("-wsdl")) {
        genWsdl = true;
        //String value = requireArgument("-wsdl", args, ++i).substring(5);
        String value = args[i].substring(5);
        int index = value.indexOf(':');
        if (index == 0) {
            value = value.substring(1);
            index = value.indexOf('/');
            if (index == -1) {
                protocol = value;
            } else {
                protocol = value.substring(0, index);
            }
            protocolSet = true;
        }
        return 1;
    } else if (args[i].equals("-XwsgenReport")) {
        // undocumented switch for the test harness
        wsgenReport = new File(requireArgument("-XwsgenReport", args, ++i));
        return 2;
    } else if (args[i].equals("-Xdonotoverwrite")) {
        doNotOverWrite = true;
        return 1;
    } else if (args[i].equals("-inlineSchemas")) {
        inlineSchemas = true;
        return 1;
    } else if ("-x".equals(args[i])) {
        externalMetadataFiles.add(requireArgument("-x", args, ++i));
        return 1;
    }

    return j;
}
 
Example 20
Source File: AbstractSTSClient.java    From steady with Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}