Refactored YangModelParserImpl
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / model / parser / util / YangModelBuilderUtil.java
index a27108e4715bd668fc720f7ce5b0c232bf2e678b..31ec7654233625adcae2652ec0083a37fb3d5b55 100644 (file)
@@ -622,11 +622,27 @@ public class YangModelBuilderUtil {
                 reference = stringFromNode(child);
             }
         }
-        String pattern = stringFromNode(ctx);
+        String pattern = patternStringFromNode(ctx);
         return BaseConstraints.patternConstraint(pattern, description,
                 reference);
     }
 
+    public static String patternStringFromNode(final Pattern_stmtContext treeNode) {
+        String result = "";
+        for (int i = 0; i < treeNode.getChildCount(); ++i) {
+            ParseTree child = treeNode.getChild(i);
+            if (child instanceof StringContext) {
+                for(int j = 0; j < child.getChildCount(); j++) {
+                    if(j % 2 == 0) {
+                        String patternToken = child.getChild(j).getText();
+                        result += patternToken.substring(1, patternToken.length()-1);
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
     private static Integer getFractionDigits(Type_body_stmtsContext ctx) {
         for (int j = 0; j < ctx.getChildCount(); j++) {
             ParseTree dec64specChild = ctx.getChild(j);
@@ -974,7 +990,7 @@ public class YangModelBuilderUtil {
         if (typeName.equals("decimal64")) {
             type = YangTypesConverter.javaTypeForBaseYangDecimal64Type(
                     rangeStatements, fractionDigits);
-        } else if (typeName.startsWith("int") || typeName.startsWith("uint")) {
+        } else if (typeName.startsWith("int")) {
             type = YangTypesConverter.javaTypeForBaseYangSignedIntegerType(typeName,
                     rangeStatements);
         } else if(typeName.startsWith("uint")) {