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
/**
 * 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
@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 3
/**
 * 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
/**
 * 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 5
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 6
/**
 * 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 7
/**
 * 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
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
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 10
/**
 * 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 11
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
/**
 * 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
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 14
@Override
public QName unmarshal(String v) throws Exception
{
    return QName.valueOf(v);
}
 
Example 15
Source Project: tessera   File: MapAdapterTest.java    License: 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 16
Source Project: steady   File: AbstractSTSClient.java    License: Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}
 
Example 17
Source Project: steady   File: AbstractSTSClient.java    License: Apache License 2.0 4 votes vote down vote up
public void setServiceName(String qn) {
    serviceName = QName.valueOf(qn);
}
 
Example 18
Source Project: steady   File: AbstractSTSClient.java    License: Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}
 
Example 19
@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 Project: steady   File: AbstractSTSClient.java    License: Apache License 2.0 4 votes vote down vote up
public void setEndpointName(String qn) {
    endpointName = QName.valueOf(qn);
}