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); }
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); }
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); }
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); }
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; } }
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; } }
/** * Require that the current element have only a single attribute with the given name. * * @param reader the reader * @param attributeName the attribute name * @throws XMLStreamException if an error occurs */ public static void requireSingleAttribute(final XMLExtendedStreamReader reader, final String attributeName) throws XMLStreamException { final int count = reader.getAttributeCount(); if (count == 0) { throw missingRequired(reader, Collections.singleton(attributeName)); } if (reader.getAttributeNamespace(0) != null || ! attributeName.equals(reader.getAttributeLocalName(0))) { throw unexpectedAttribute(reader, 0); } if (count > 1) { throw unexpectedAttribute(reader, 1); } }
public static Property readProperty(final XMLExtendedStreamReader reader, boolean supportsExpressions) throws XMLStreamException { final int cnt = reader.getAttributeCount(); String name = null; ModelNode value = null; for (int i = 0; i < cnt; i++) { String uri = reader.getAttributeNamespace(i); if (uri != null&&!"".equals(XMLConstants.NULL_NS_URI)) { throw unexpectedAttribute(reader, i); } final String localName = reader.getAttributeLocalName(i); if (localName.equals("name")) { name = reader.getAttributeValue(i); } else if (localName.equals("value")) { if (supportsExpressions) { value = parsePossibleExpression(reader.getAttributeValue(i)); } else { value = new ModelNode(reader.getAttributeValue(i)); } } else { throw unexpectedAttribute(reader, i); } } if (name == null) { throw missingRequired(reader, Collections.singleton("name")); } if (reader.next() != END_ELEMENT) { throw unexpectedElement(reader); } return new Property(name, new ModelNode().set(value == null ? new ModelNode() : value)); }
public static Property readProperty(final XMLExtendedStreamReader reader, boolean supportsExpressions) throws XMLStreamException { final int cnt = reader.getAttributeCount(); String name = null; ModelNode value = null; for (int i = 0; i < cnt; i++) { String uri = reader.getAttributeNamespace(i); if (uri != null&&!"".equals(XMLConstants.NULL_NS_URI)) { throw unexpectedAttribute(reader, i); } final String localName = reader.getAttributeLocalName(i); if (localName.equals("name")) { name = reader.getAttributeValue(i); } else if (localName.equals("value")) { if (supportsExpressions) { value = parsePossibleExpression(reader.getAttributeValue(i)); } else { value = new ModelNode(reader.getAttributeValue(i)); } } else { throw unexpectedAttribute(reader, i); } } if (name == null) { throw missingRequired(reader, Collections.singleton("name")); } if (reader.next() != END_ELEMENT) { throw unexpectedElement(reader); } return new Property(name, new ModelNode().set(value == null ? new ModelNode() : value)); }
public static Property readProperty(final XMLExtendedStreamReader reader) throws XMLStreamException { final int cnt = reader.getAttributeCount(); String name = null; String value = null; for (int i = 0; i < cnt; i ++) { if (reader.getAttributeNamespace(i) != null) { throw unexpectedAttribute(reader, i); } final String localName = reader.getAttributeLocalName(i); if (localName.equals("name")) { name = reader.getAttributeValue(i); } else if (localName.equals("value")) { value = reader.getAttributeValue(i); } else { throw unexpectedAttribute(reader, i); } } if (name == null) { throw missingRequired(reader, Collections.singleton("name")); } return new Property(name, value == null ? "" : value); }
static List<AbstractModelUpdate<JvmElement, ?>> parseStack(XMLExtendedStreamReader reader) throws XMLStreamException { List<AbstractModelUpdate<JvmElement, ?>> updates = new ArrayList<AbstractModelUpdate<JvmElement, ?>>(); // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SIZE: { updates.add(new JvmStackUpdate(value)); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (updates.size() == 0) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.SIZE)); } // Handle elements ParseUtils.requireNoContent(reader); return updates; }
static List<AbstractModelUpdate<JvmElement, ?>> parseAgentLib(XMLExtendedStreamReader reader) throws XMLStreamException { List<AbstractModelUpdate<JvmElement, ?>> updates = new ArrayList<AbstractModelUpdate<JvmElement, ?>>(); // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: { updates.add(new JvmAgentLibUpdate(value)); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (updates.size() == 0) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE)); } // Handle elements ParseUtils.requireNoContent(reader); return updates; }
static List<AbstractModelUpdate<JvmElement, ?>> parseAgentPath(XMLExtendedStreamReader reader) throws XMLStreamException { List<AbstractModelUpdate<JvmElement, ?>> updates = new ArrayList<AbstractModelUpdate<JvmElement, ?>>(); // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: { updates.add(new JvmAgentPathUpdate(value)); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (updates.size() == 0) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE)); } // Handle elements ParseUtils.requireNoContent(reader); return updates; }
static List<AbstractModelUpdate<JvmElement, ?>> parseJavaagent(XMLExtendedStreamReader reader) throws XMLStreamException { List<AbstractModelUpdate<JvmElement, ?>> updates = new ArrayList<AbstractModelUpdate<JvmElement, ?>>(); // Handle attributes final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VALUE: { updates.add(new JvmJavaagentUpdate(value)); break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (updates.size() == 0) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE)); } // Handle elements ParseUtils.requireNoContent(reader); return updates; }
private String parseValue(XMLExtendedStreamReader reader) throws XMLStreamException { String found = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SIZE: { found = value; break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (found == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.VALUE)); } // Handle elements ParseUtils.requireNoContent(reader); return found; }
private void parseStack(XMLExtendedStreamReader reader) throws XMLStreamException { // Handle attributes String size = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SIZE: { size = value; break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } if (size == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.SIZE)); } this.stack = size; // Handle elements ParseUtils.requireNoContent(reader); }
private void readDomainElementAttributes_1_0(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { switch (Namespace.forUri(reader.getAttributeNamespace(i))) { case XML_SCHEMA_INSTANCE: { switch (Attribute.forName(reader.getAttributeLocalName(i))) { case SCHEMA_LOCATION: { parseSchemaLocations(reader, address, list, i); break; } case NO_NAMESPACE_SCHEMA_LOCATION: { // todo, jeez break; } default: { throw unexpectedAttribute(reader, i); } } break; } default: throw unexpectedAttribute(reader, i); } } }
protected void readDomainElementAttributes_1_0(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { switch (Namespace.forUri(reader.getAttributeNamespace(i))) { case XML_SCHEMA_INSTANCE: { switch (Attribute.forName(reader.getAttributeLocalName(i))) { case SCHEMA_LOCATION: { parseSchemaLocations(reader, address, list, i); break; } case NO_NAMESPACE_SCHEMA_LOCATION: { // todo, jeez break; } default: { throw unexpectedAttribute(reader, i); } } break; } default: throw unexpectedAttribute(reader, i); } } }
private void readDomainElementAttributes_1_0(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException { final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { switch (Namespace.forUri(reader.getAttributeNamespace(i))) { case XML_SCHEMA_INSTANCE: { switch (Attribute.forName(reader.getAttributeLocalName(i))) { case SCHEMA_LOCATION: { parseSchemaLocations(reader, address, list, i); break; } case NO_NAMESPACE_SCHEMA_LOCATION: { // todo, jeez break; } default: { throw unexpectedAttribute(reader, i); } } break; } default: throw unexpectedAttribute(reader, i); } } }
private void parseMinMax(XMLExtendedStreamReader reader, MinMaxSetter setter) throws XMLStreamException { // Handle attributes String size = null; String max = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i ++) { final String value = reader.getAttributeValue(i); if (reader.getAttributeNamespace(i) != null) { throw ParseUtils.unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case SIZE: { size = value; break; } case MAX_SIZE: { max = value; break; } default: throw ParseUtils.unexpectedAttribute(reader, i); } } } setter.setMinMax(size, max); // Handle elements ParseUtils.requireNoContent(reader); }