use of org.opendaylight.netconf.shaded.exificient.core.CodingMode 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);
}
Aggregations