/** * Write the criteria elements, extracting the information of the sub-model. * * @param writer the xml stream writer * @param subModel the interface model * @param nested whether it the criteria elements are nested as part of <not /> or <any /> * @throws XMLStreamException */ private void writeInterfaceCriteria(final XMLExtendedStreamWriter writer, final ModelNode subModel, final boolean nested) throws XMLStreamException { for (final Property property : subModel.asPropertyList()) { if (property.getValue().isDefined()) { writeInterfaceCriteria(writer, property, nested); } } }
/** * Write the criteria elements, extracting the information of the sub-model. * * @param writer the xml stream writer * @param subModel the interface model * @param nested whether it the criteria elements are nested as part of <not /> or <any /> * @throws XMLStreamException */ private void writeInterfaceCriteria(final XMLExtendedStreamWriter writer, final ModelNode subModel, final boolean nested) throws XMLStreamException { for (final Property property : subModel.asPropertyList()) { if (property.getValue().isDefined()) { writeInterfaceCriteria(writer, property, nested); } } }
switch (element) { case INET_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), nested); break; case LOOPBACK_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), false); break; case LINK_LOCAL_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.NAME, property.getValue(), nested); break; case NIC_MATCH: writeInterfaceCriteria(writer, element, Attribute.PATTERN, property.getValue(), nested); break; case SUBNET_MATCH: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), nested); break; case ANY: writeInterfaceCriteria(writer, property.getValue(), true); writer.writeEndElement(); break;
switch (element) { case INET_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), nested); break; case LOOPBACK_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), false); break; case LINK_LOCAL_ADDRESS: writeInterfaceCriteria(writer, element, Attribute.NAME, property.getValue(), nested); break; case NIC_MATCH: writeInterfaceCriteria(writer, element, Attribute.PATTERN, property.getValue(), nested); break; case SUBNET_MATCH: writeInterfaceCriteria(writer, element, Attribute.VALUE, property.getValue(), nested); break; case ANY: writeInterfaceCriteria(writer, property.getValue(), true); writer.writeEndElement(); break;
/** * Write the interfaces including the criteria elements. * * @param writer the xml stream writer * @param modelNode the model * @throws XMLStreamException */ protected void writeInterfaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException { writer.writeStartElement(Element.INTERFACES.getLocalName()); final Set<String> interfaces = modelNode.keys(); for (String ifaceName : interfaces) { final ModelNode iface = modelNode.get(ifaceName); writer.writeStartElement(Element.INTERFACE.getLocalName()); writeAttribute(writer, Attribute.NAME, ifaceName); // <any-* /> is just handled at the root if (iface.get(Element.ANY_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_ADDRESS.getLocalName()); } else if (iface.get(Element.ANY_IPV4_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_IPV4_ADDRESS.getLocalName()); } else if (iface.get(Element.ANY_IPV6_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_IPV6_ADDRESS.getLocalName()); } else { // Write the other criteria elements writeInterfaceCriteria(writer, iface, false); } writer.writeEndElement(); } writer.writeEndElement(); }
/** * Write the interfaces including the criteria elements. * * @param writer the xml stream writer * @param modelNode the model * @throws XMLStreamException */ protected void writeInterfaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException { writer.writeStartElement(Element.INTERFACES.getLocalName()); final Set<String> interfaces = modelNode.keys(); for (String ifaceName : interfaces) { final ModelNode iface = modelNode.get(ifaceName); writer.writeStartElement(Element.INTERFACE.getLocalName()); writeAttribute(writer, Attribute.NAME, ifaceName); // <any-* /> is just handled at the root if (iface.get(Element.ANY_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_ADDRESS.getLocalName()); } else if (iface.get(Element.ANY_IPV4_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_IPV4_ADDRESS.getLocalName()); } else if (iface.get(Element.ANY_IPV6_ADDRESS.getLocalName()).asBoolean(false)) { writer.writeEmptyElement(Element.ANY_IPV6_ADDRESS.getLocalName()); } else { // Write the other criteria elements writeInterfaceCriteria(writer, iface, false); } writer.writeEndElement(); } writer.writeEndElement(); }