X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fexi%2FEXIParameters.java;h=cb07635a1abb958b233c8a474b8d3bb453258241;hb=refs%2Fchanges%2F13%2F23413%2F26;hp=993709258a3410b80a8a6fbdde47f0374ca15619;hpb=c0664e68c1408f269a5782f2dba4b1e9044164f6;p=controller.git diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java index 993709258a..cb07635a1a 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java @@ -8,17 +8,19 @@ package org.opendaylight.controller.netconf.nettyutil.handler.exi; import com.google.common.base.Preconditions; -import org.opendaylight.controller.netconf.util.xml.XmlElement; +import org.opendaylight.controller.config.util.xml.XmlElement; import org.openexi.proc.common.AlignmentType; import org.openexi.proc.common.EXIOptions; import org.openexi.proc.common.EXIOptionsException; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; public final class EXIParameters { private static final String EXI_PARAMETER_ALIGNMENT = "alignment"; - private static final String EXI_PARAMETER_BYTE_ALIGNED = "byte-aligned"; - private static final String EXI_PARAMETER_BIT_PACKED = "bit-packed"; - private static final String EXI_PARAMETER_COMPRESSED = "compressed"; - private static final String EXI_PARAMETER_PRE_COMPRESSION = "pre-compression"; + static final String EXI_PARAMETER_BYTE_ALIGNED = "byte-aligned"; + static final String EXI_PARAMETER_BIT_PACKED = "bit-packed"; + static final String EXI_PARAMETER_COMPRESSED = "compressed"; + static final String EXI_PARAMETER_PRE_COMPRESSION = "pre-compression"; private static final String EXI_PARAMETER_FIDELITY = "fidelity"; private static final String EXI_FIDELITY_DTD = "dtd"; @@ -38,15 +40,25 @@ public final class EXIParameters { final EXIOptions options = new EXIOptions(); options.setAlignmentType(AlignmentType.bitPacked); - if (root.getElementsByTagName(EXI_PARAMETER_ALIGNMENT).getLength() > 0) { - if (root.getElementsByTagName(EXI_PARAMETER_BIT_PACKED).getLength() > 0) { + + 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_BIT_PACKED: options.setAlignmentType(AlignmentType.bitPacked); - } else if (root.getElementsByTagName(EXI_PARAMETER_BYTE_ALIGNED).getLength() > 0) { + break; + case EXI_PARAMETER_BYTE_ALIGNED: options.setAlignmentType(AlignmentType.byteAligned); - } else if (root.getElementsByTagName(EXI_PARAMETER_COMPRESSED).getLength() > 0) { + break; + case EXI_PARAMETER_COMPRESSED: options.setAlignmentType(AlignmentType.compress); - } else if (root.getElementsByTagName(EXI_PARAMETER_PRE_COMPRESSION).getLength() > 0) { + break; + case EXI_PARAMETER_PRE_COMPRESSION: options.setAlignmentType(AlignmentType.preCompress); + break; } }