Formatted code for Bug-3890 87/30187/4
authorshivanip <shivani.pathak@tcs.com>
Tue, 15 Dec 2015 11:09:56 +0000 (16:39 +0530)
committershivanip <shivani.pathak@tcs.com>
Tue, 15 Dec 2015 11:11:06 +0000 (16:41 +0530)
Change-Id: I7b6c481104ec4445c034cc5a9e560a641e7df93c
Signed-off-by: Shivani Pathak <shivani.pathak@tcs.com>
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/exi/EXIParameters.java

index 2bc96beb0517d766a6dcbd8aefea1d184cd77363..6fcea5130a7e18b42fc3d069f0c0d179386e229f 100644 (file)
@@ -14,6 +14,8 @@ import org.openexi.proc.common.EXIOptions;
 import org.openexi.proc.common.EXIOptionsException;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class EXIParameters {
     private static final String EXI_PARAMETER_ALIGNMENT = "alignment";
@@ -30,6 +32,7 @@ public final class EXIParameters {
     private static final String EXI_FIDELITY_PREFIXES = "prefixes";
 
     private final EXIOptions options;
+    private static final Logger LOG = LoggerFactory.getLogger(EXIParameters.class);
 
     private EXIParameters(final EXIOptions options) {
         this.options = Preconditions.checkNotNull(options);
@@ -38,18 +41,12 @@ public final class EXIParameters {
 
     public static EXIParameters fromXmlElement(final XmlElement root) throws EXIOptionsException {
         final EXIOptions options =  new EXIOptions();
-
-        options.setAlignmentType(AlignmentType.bitPacked);
-
         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);
-                break;
             case EXI_PARAMETER_BYTE_ALIGNED:
                 options.setAlignmentType(AlignmentType.byteAligned);
                 break;
@@ -59,7 +56,14 @@ public final class EXIParameters {
             case EXI_PARAMETER_PRE_COMPRESSION:
                 options.setAlignmentType(AlignmentType.preCompress);
                 break;
+            default:
+                LOG.warn("Unexpected value in alignmentTextContent: {} , using default value", alignmentTextContent);
+            case EXI_PARAMETER_BIT_PACKED:
+                options.setAlignmentType(AlignmentType.bitPacked);
+                break;
             }
+        } else {
+            options.setAlignmentType(AlignmentType.bitPacked);
         }
 
         if (root.getElementsByTagName(EXI_PARAMETER_FIDELITY).getLength() > 0) {