use of org.opendaylight.netconf.shaded.exificient.core.FidelityOptions in project netconf by opendaylight.
the class EXIParametersTest method data.
@Parameterized.Parameters
public static Iterable<Object[]> data() throws Exception {
final String noChangeXml = "<start-exi xmlns=\"urn:ietf:params:xml:ns:netconf:exi:1.0\">\n" + "<alignment>bit-packed</alignment>\n" + "</start-exi>\n";
final String fullOptionsXml = "<start-exi xmlns=\"urn:ietf:params:xml:ns:netconf:exi:1.0\">\n" + "<alignment>byte-aligned</alignment>\n" + "<fidelity>\n" + "<comments/>\n" + "<dtd/>\n" + "<lexical-values/>\n" + "<pis/>\n" + "<prefixes/>\n" + "</fidelity>\n" + "</start-exi>\n";
final FidelityOptions fullOptions = FidelityOptions.createDefault();
fullOptions.setFidelity(FidelityOptions.FEATURE_LEXICAL_VALUE, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_DTD, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_COMMENT, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_PREFIX, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_PI, true);
return Arrays.asList(new Object[][] { { noChangeXml, CodingMode.BIT_PACKED, FidelityOptions.createDefault() }, { fullOptionsXml, CodingMode.BYTE_PACKED, fullOptions } });
}
use of org.opendaylight.netconf.shaded.exificient.core.FidelityOptions in project netconf by opendaylight.
the class EXIParameters method fromXmlElement.
public static EXIParameters fromXmlElement(final XmlElement root) throws UnsupportedOption {
final CodingMode coding;
final NodeList alignmentElements = root.getElementsByTagName(EXI_PARAMETER_ALIGNMENT);
if (alignmentElements.getLength() > 0) {
final Element alignmentElement = (Element) alignmentElements.item(0);
final String alignmentTextContent = alignmentElement.getTextContent().trim();
switch(alignmentTextContent) {
case EXI_PARAMETER_BYTE_ALIGNED:
coding = CodingMode.BYTE_PACKED;
break;
case EXI_PARAMETER_COMPRESSED:
coding = CodingMode.COMPRESSION;
break;
case EXI_PARAMETER_PRE_COMPRESSION:
coding = CodingMode.PRE_COMPRESSION;
break;
case EXI_PARAMETER_BIT_PACKED:
coding = CodingMode.BIT_PACKED;
break;
default:
LOG.warn("Unexpected value in alignmentTextContent: {} , using default value", alignmentTextContent);
coding = CodingMode.BIT_PACKED;
break;
}
} else {
coding = CodingMode.BIT_PACKED;
}
final FidelityOptions fidelity = FidelityOptions.createDefault();
final NodeList fidelityElements = root.getElementsByTagName(EXI_PARAMETER_FIDELITY);
if (fidelityElements.getLength() > 0) {
final Element fidelityElement = (Element) fidelityElements.item(0);
fidelity.setFidelity(FidelityOptions.FEATURE_DTD, fidelityElement.getElementsByTagName(EXI_FIDELITY_DTD).getLength() > 0);
fidelity.setFidelity(FidelityOptions.FEATURE_LEXICAL_VALUE, fidelityElement.getElementsByTagName(EXI_FIDELITY_LEXICAL_VALUES).getLength() > 0);
fidelity.setFidelity(FidelityOptions.FEATURE_COMMENT, fidelityElement.getElementsByTagName(EXI_FIDELITY_COMMENTS).getLength() > 0);
fidelity.setFidelity(FidelityOptions.FEATURE_PI, fidelityElement.getElementsByTagName(EXI_FIDELITY_PIS).getLength() > 0);
fidelity.setFidelity(FidelityOptions.FEATURE_PREFIX, fidelityElement.getElementsByTagName(EXI_FIDELITY_PREFIXES).getLength() > 0);
}
final EXISchema schema;
final NodeList schemaElements = root.getElementsByTagName(EXI_PARAMETER_SCHEMAS);
if (schemaElements.getLength() > 0) {
final Element schemaElement = (Element) schemaElements.item(0);
final String schemaName = schemaElement.getTextContent().trim();
schema = EXISchema.forOption(schemaName);
checkArgument(schema != null, "Unsupported schema name %s", schemaName);
} else {
schema = EXISchema.NONE;
}
return new EXIParameters(coding, fidelity, schema);
}
use of org.opendaylight.netconf.shaded.exificient.core.FidelityOptions in project netconf by opendaylight.
the class NetconfStartExiMessageTest method data.
@Parameterized.Parameters
public static Iterable<Object[]> data() throws Exception {
final String noChangeXml = "<rpc xmlns:ns0=\"urn:ietf:params:xml:ns:netconf:base:1.0\" " + "ns0:message-id=\"id\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + "<start-exi xmlns=\"urn:ietf:params:xml:ns:netconf:exi:1.0\">\n" + "<alignment>bit-packed</alignment>\n" + "</start-exi>\n" + "</rpc>";
final String fullOptionsXml = "<rpc xmlns:ns0=\"urn:ietf:params:xml:ns:netconf:base:1.0\" " + "ns0:message-id=\"id\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + "<start-exi xmlns=\"urn:ietf:params:xml:ns:netconf:exi:1.0\">\n" + "<alignment>byte-aligned</alignment>\n" + "<fidelity>\n" + "<comments/>\n" + "<dtd/>\n" + "<lexical-values/>\n" + "<pis/>\n" + "<prefixes/>\n" + "</fidelity>\n" + "</start-exi>\n" + "</rpc>";
final FidelityOptions fullOptions = FidelityOptions.createDefault();
fullOptions.setFidelity(FidelityOptions.FEATURE_LEXICAL_VALUE, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_DTD, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_COMMENT, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_PREFIX, true);
fullOptions.setFidelity(FidelityOptions.FEATURE_PI, true);
return Arrays.asList(new Object[][] { { noChangeXml, EXIParameters.empty() }, { fullOptionsXml, new EXIParameters(CodingMode.BYTE_PACKED, fullOptions) } });
}
Aggregations