Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeNamespace()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamReader#getAttributeNamespace() . 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: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void readDefaultProtocol_2_0(XMLExtendedStreamReader reader, Namespace expectedNs, CliConfigImpl config)
        throws XMLStreamException {
    final int attributes = reader.getAttributeCount();
    for (int i = 0; i < attributes; i++) {
        String namespace = reader.getAttributeNamespace(i);
        String localName = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        if (namespace != null && !namespace.equals("")) {
            throw new XMLStreamException("Unexpected attribute '" + namespace + ":" + localName + "'",
                    reader.getLocation());
        } else if (localName.equals(USE_LEGACY_OVERRIDE)) {
            config.useLegacyOverride = Boolean.parseBoolean(value);
        } else {
            throw new XMLStreamException("Unexpected attribute '" + localName + "'", reader.getLocation());
        }
    }

    final String resolved = resolveString(reader.getElementText());
    if (resolved != null && resolved.length() > 0) {
        config.defaultControllerProtocol = resolved;
    }
}
 
Example 2
Source File: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void readControllers_2_0(XMLExtendedStreamReader reader, Namespace expectedNs, CliConfigImpl config) throws XMLStreamException {
    Map<String, ControllerAddress> aliasedAddresses = new HashMap<String, ControllerAddress>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        assertExpectedNamespace(reader, expectedNs);
        final String localName = reader.getLocalName();

        if (CONTROLLER.equals(localName)) {
            String name = null;
            final int attributes = reader.getAttributeCount();
            for (int i = 0; i < attributes; i++) {
                String namespace = reader.getAttributeNamespace(i);
                String attrLocalName = reader.getAttributeLocalName(i);
                String value = reader.getAttributeValue(i);

                if (namespace != null && !namespace.equals("")) {
                    throw new XMLStreamException("Unexpected attribute '" + namespace + ":" + attrLocalName + "'",
                            reader.getLocation());
                } else if (attrLocalName.equals(NAME) && name == null) {
                    name = value;
                } else {
                    throw new XMLStreamException("Unexpected attribute '" + attrLocalName + "'", reader.getLocation());
                }
            }

            if (name == null) {
                throw new XMLStreamException("Missing required attribute 'name'", reader.getLocation());
            }
            aliasedAddresses.put(name, readController(true, reader, expectedNs));
        } else {
            throw new XMLStreamException("Unexpected child of " + CONTROLLER + ": " + localName);
        }
    }

    config.controllerAliases = Collections.unmodifiableMap(aliasedAddresses);
}
 
Example 3
Source File: ParseUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static boolean isNoNamespaceAttribute(final XMLExtendedStreamReader reader, final int index) {
    String namespace = reader.getAttributeNamespace(index);
    // FIXME when STXM-8 is done, remove the null check
    return namespace == null || XMLConstants.NULL_NS_URI.equals(namespace);
}