Merge "Updated SCM location"
authorGiovanni Meo <gmeo@cisco.com>
Mon, 20 May 2013 16:53:58 +0000 (16:53 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 20 May 2013 16:53:58 +0000 (16:53 +0000)
29 files changed:
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/api/Builder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/api/TypeDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AnyXmlBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/AugmentationSchemaBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ConstraintsBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/DeviationBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ExtensionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/FeatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/IdentitySchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/IdentityrefTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ListSchemaNodeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/RpcDefinitionBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UnionTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/builder/impl/UsesNodeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangValidationException.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TypesResolutionTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/AugmentationSchema.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/AugmentationTarget.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ChoiceCaseNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ChoiceNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ConstraintDefinition.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ContainerSchemaNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/DataNodeContainer.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/SchemaNode.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java

index 4288a7632a3e0f4bf9d456a758e3bde496689d3c..db3ac36d69124dd6d4830c5294ec8bd49af482fa 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.controller.yang.parser.builder.api;
 \r
 import java.util.List;\r
 \r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
 import org.opendaylight.controller.yang.model.api.type.LengthConstraint;\r
@@ -26,10 +24,6 @@ public interface TypeDefinitionBuilder extends TypeAwareBuilder,
 \r
     TypeDefinition<?> build();\r
 \r
-    QName getQName();\r
-\r
-    SchemaPath getPath();\r
-\r
     String getDescription();\r
 \r
     String getReference();\r
index bd6e0afcdf0646cf04402f6d49c5c1125bd24964..4b95ab9dcb79c63843babe02195557a71aef6bfc 100644 (file)
@@ -135,7 +135,7 @@ public class AnyXmlBuilder implements DataSchemaNodeBuilder {
         instance.setConfiguration(configuration);
     }
 
-    private static class AnyXmlSchemaNodeImpl implements AnyXmlSchemaNode {
+    private class AnyXmlSchemaNodeImpl implements AnyXmlSchemaNode {
         private final QName qname;
         private SchemaPath path;
         private String description;
index 0473726168dcc0af2db6e0cf3cfa750b796a89ad..29c38dfa0e727eaaba4c61adf7320f8893bb90c8 100644 (file)
@@ -188,11 +188,6 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
         int result = 1;
         result = prime * result
                 + ((augmentTargetStr == null) ? 0 : augmentTargetStr.hashCode());
-        result = prime * result
-                + ((childNodes == null) ? 0 : childNodes.hashCode());
-        result = prime * result
-                + ((groupings == null) ? 0 : groupings.hashCode());
-        result = prime * result + ((usesNodes == null) ? 0 : usesNodes.hashCode());
         result = prime * result
                 + ((whenCondition == null) ? 0 : whenCondition.hashCode());
         return result;
@@ -217,27 +212,6 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
         } else if (!augmentTargetStr.equals(other.augmentTargetStr)) {
             return false;
         }
-        if (childNodes == null) {
-            if (other.childNodes != null) {
-                return false;
-            }
-        } else if (!childNodes.equals(other.childNodes)) {
-            return false;
-        }
-        if (groupings == null) {
-            if (other.groupings != null) {
-                return false;
-            }
-        } else if (!groupings.equals(other.groupings)) {
-            return false;
-        }
-        if (usesNodes == null) {
-            if (other.usesNodes != null) {
-                return false;
-            }
-        } else if (!usesNodes.equals(other.usesNodes)) {
-            return false;
-        }
         if (whenCondition == null) {
             if (other.whenCondition != null) {
                 return false;
@@ -374,11 +348,6 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
             int result = 1;
             result = prime * result
                     + ((targetPath == null) ? 0 : targetPath.hashCode());
-            result = prime * result
-                    + ((childNodes == null) ? 0 : childNodes.hashCode());
-            result = prime * result
-                    + ((groupings == null) ? 0 : groupings.hashCode());
-            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
             result = prime * result
                     + ((whenCondition == null) ? 0 : whenCondition.hashCode());
             return result;
@@ -403,27 +372,6 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
             } else if (!targetPath.equals(other.targetPath)) {
                 return false;
             }
-            if (childNodes == null) {
-                if (other.childNodes != null) {
-                    return false;
-                }
-            } else if (!childNodes.equals(other.childNodes)) {
-                return false;
-            }
-            if (groupings == null) {
-                if (other.groupings != null) {
-                    return false;
-                }
-            } else if (!groupings.equals(other.groupings)) {
-                return false;
-            }
-            if (uses == null) {
-                if (other.uses != null) {
-                    return false;
-                }
-            } else if (!uses.equals(other.uses)) {
-                return false;
-            }
             if (whenCondition == null) {
                 if (other.whenCondition != null) {
                     return false;
index a1936dea55a5183eb2d155e6e803afc0175452e0..a6c37e34214d8d995d9ef2e7bcb49c155bcb1460 100644 (file)
@@ -12,7 +12,6 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;
 import org.opendaylight.controller.yang.model.api.MustDefinition;
 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
@@ -96,18 +95,12 @@ public class ConstraintsBuilder implements Builder {
 
     private static class ConstraintDefinitionImpl implements
             ConstraintDefinition {
-        private DataSchemaNode parent;
         private RevisionAwareXPath whenCondition;
         private Set<MustDefinition> mustConstraints;
         private boolean mandatory;
         private Integer minElements;
         private Integer maxElements;
 
-        @Override
-        public DataSchemaNode getParent() {
-            return parent;
-        }
-
         @Override
         public RevisionAwareXPath getWhenCondition() {
             return whenCondition;
@@ -163,8 +156,6 @@ public class ConstraintsBuilder implements Builder {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result
-                    + ((parent == null) ? 0 : parent.hashCode());
             result = prime * result
                     + ((whenCondition == null) ? 0 : whenCondition.hashCode());
             result = prime
@@ -191,13 +182,6 @@ public class ConstraintsBuilder implements Builder {
                 return false;
             }
             ConstraintDefinitionImpl other = (ConstraintDefinitionImpl) obj;
-            if (parent == null) {
-                if (other.parent != null) {
-                    return false;
-                }
-            } else if (!parent.equals(other.parent)) {
-                return false;
-            }
             if (whenCondition == null) {
                 if (other.whenCondition != null) {
                     return false;
@@ -237,8 +221,7 @@ public class ConstraintsBuilder implements Builder {
             StringBuilder sb = new StringBuilder(
                     ConstraintDefinitionImpl.class.getSimpleName());
             sb.append("[");
-            sb.append("parent=" + parent);
-            sb.append(", whenCondition=" + whenCondition);
+            sb.append("whenCondition=" + whenCondition);
             sb.append(", mustConstraints=" + mustConstraints);
             sb.append(", mandatory=" + mandatory);
             sb.append(", minElements=" + minElements);
index cfe6effb6c5098fa0fb7066884c3bf474d824751..e99f8280e0891a628b3be26ef4517aaa2abd32b8 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.controller.yang.model.api.Deviation.Deviate;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.util.YangModelBuilderUtil;
+import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 public class DeviationBuilder implements Builder {
     private final DeviationImpl instance;
@@ -44,7 +45,7 @@ public class DeviationBuilder implements Builder {
         } else if ("delete".equals(deviate)) {
             instance.setDeviate(Deviate.DELETE);
         } else {
-            throw new IllegalArgumentException(
+            throw new YangParseException(line,
                     "Unsupported type of 'deviate' statement: " + deviate);
         }
     }
@@ -53,7 +54,7 @@ public class DeviationBuilder implements Builder {
         instance.setReference(reference);
     }
 
-    private static class DeviationImpl implements Deviation {
+    private class DeviationImpl implements Deviation {
         private final SchemaPath targetPath;
         private Deviate deviate;
         private String reference;
index 3e8fd8d0a4a7b24c018e39fffb282d4c84919202..2852a32aec45f193ac5919e828a2cf3f1f56aa1e 100644 (file)
@@ -98,7 +98,7 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
-    private static class ExtensionDefinitionImpl implements ExtensionDefinition {
+    private class ExtensionDefinitionImpl implements ExtensionDefinition {
         private final QName qname;
         private String argument;
         private SchemaPath schemaPath;
@@ -193,11 +193,6 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
             result = prime * result + ((qname == null) ? 0 : qname.hashCode());
             result = prime * result
                     + ((schemaPath == null) ? 0 : schemaPath.hashCode());
-            result = prime
-                    * result
-                    + ((unknownNodes == null) ? 0
-                            : unknownNodes.hashCode());
-            result = prime * result + (yin ? 1231 : 1237);
             return result;
         }
 
@@ -227,16 +222,6 @@ public class ExtensionBuilder implements SchemaNodeBuilder {
             } else if (!schemaPath.equals(other.schemaPath)) {
                 return false;
             }
-            if (unknownNodes == null) {
-                if (other.unknownNodes != null) {
-                    return false;
-                }
-            } else if (!unknownNodes.equals(other.unknownNodes)) {
-                return false;
-            }
-            if (yin != other.yin) {
-                return false;
-            }
             return true;
         }
 
index cdea33bb7f3cdf19bae5f36b2ebed919292bd45e..0f2c7f1d09d3795b62b15b5a667b91204e8c0568 100644 (file)
@@ -85,7 +85,7 @@ public class FeatureBuilder implements SchemaNodeBuilder {
         addedUnknownNodes.add(unknownNode);
     }
 
-    private static class FeatureDefinitionImpl implements FeatureDefinition {
+    private class FeatureDefinitionImpl implements FeatureDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
index b53d5b2dc2bc4804251fb40bca2355dc0ddb91cd..68fffd26b9444b18284e8770f5c313e0677cf492 100644 (file)
@@ -186,6 +186,7 @@ public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
             final int prime = 31;
             int result = 1;
             result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
             return result;
         }
 
@@ -208,6 +209,13 @@ public final class IdentitySchemaNodeBuilder implements SchemaNodeBuilder {
             } else if (!qname.equals(other.qname)) {
                 return false;
             }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
             return true;
         }
 
index b7043ce744a199e06e95709da0dd8341c08978e6..408f6612ea8a3864e9851e84c66e55dbcebf609e 100644 (file)
@@ -19,8 +19,8 @@ import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.util.IdentityrefType;
 import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 /**
  * Builder for YANG union type. User can add type to this union as
@@ -29,19 +29,26 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder
  * types.
  */
 public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
-        TypeDefinitionBuilder, Builder {
+        TypeDefinitionBuilder {
+    private static final String NAME = "identityref";
+
     private final int line;
     private final String baseString;
     private final SchemaPath schemaPath;
     private QName baseQName;
 
-
-    public IdentityrefTypeBuilder(final String baseString, final SchemaPath schemaPath, final int line) {
+    IdentityrefTypeBuilder(final String baseString,
+            final SchemaPath schemaPath, final int line) {
         this.line = line;
         this.baseString = baseString;
         this.schemaPath = schemaPath;
     }
 
+    @Override
+    public IdentityrefType build() {
+        return new IdentityrefType(baseQName, schemaPath);
+    }
+
     public String getBaseString() {
         return baseString;
     }
@@ -67,49 +74,38 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setType(final TypeDefinition<?> type) {
-        throw new IllegalStateException("Can not set type to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set type to " + NAME);
     }
 
     @Override
     public void setType(final TypeDefinitionBuilder tdb) {
-        throw new IllegalStateException("Can not set type to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
-    }
-
-    @Override
-    public IdentityrefType build() {
-        return new IdentityrefType(baseQName, schemaPath);
+        throw new YangParseException(line, "Can not set type to " + NAME);
     }
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        throw new IllegalStateException("Can not set path to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set path to " + NAME);
     }
 
     @Override
     public void setDescription(final String description) {
-        throw new IllegalStateException("Can not set description to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set description to " + NAME);
     }
 
     @Override
     public void setReference(final String reference) {
-        throw new IllegalStateException("Can not set reference to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set reference to " + NAME);
     }
 
     @Override
     public void setStatus(final Status status) {
-        throw new IllegalStateException("Can not set status to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set status to " + NAME);
     }
 
     @Override
     public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
-        throw new IllegalStateException("Can not add unknown node to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not add unknown node to "
+                + NAME);
     }
 
     @Override
@@ -144,8 +140,7 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setRanges(List<RangeConstraint> ranges) {
-        throw new IllegalStateException("Can not set ranges to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set ranges to " + NAME);
     }
 
     @Override
@@ -155,8 +150,7 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setLengths(List<LengthConstraint> lengths) {
-        throw new IllegalStateException("Can not set lengths to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set lengths to " + NAME);
     }
 
     @Override
@@ -166,8 +160,7 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setPatterns(List<PatternConstraint> patterns) {
-        throw new IllegalStateException("Can not set patterns to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set patterns to " + NAME);
     }
 
     @Override
@@ -177,8 +170,8 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setFractionDigits(Integer fractionDigits) {
-        throw new IllegalStateException("Can not set fraction digits to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set fraction digits to "
+                + NAME);
     }
 
     @Override
@@ -193,8 +186,8 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setDefaultValue(Object defaultValue) {
-        throw new IllegalStateException("Can not set default value to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set default value to "
+                + NAME);
     }
 
     @Override
@@ -204,8 +197,7 @@ public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setUnits(String units) {
-        throw new IllegalStateException("Can not set units to "
-                + IdentityrefTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set units to " + NAME);
     }
 
     @Override
index 5270e48c28ddae306a9c90327e50f969d4a91c85..b97399b00bccde419249da8a0cd229127638c2ae 100644 (file)
@@ -31,13 +31,12 @@ import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBui
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationTargetBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionAwareBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;
 
 public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
-        DataSchemaNodeBuilder, SchemaNodeBuilder, AugmentationTargetBuilder,
+        DataSchemaNodeBuilder, AugmentationTargetBuilder,
         TypeDefinitionAwareBuilder {
     private final ListSchemaNodeImpl instance;
     private final int line;
@@ -57,7 +56,7 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
     // AugmentationTarget args
     private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
     // ListSchemaNode args
-    private List<QName> keyDefinition;
+    private List<QName> keyDefinition = Collections.emptyList();
     private boolean userOrdered;
 
     public ListSchemaNodeBuilder(final QName qname, final int line) {
@@ -201,7 +200,9 @@ public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
     }
 
     public void setKeyDefinition(final List<QName> keyDefinition) {
-        this.keyDefinition = keyDefinition;
+        if (keyDefinition != null) {
+            this.keyDefinition = keyDefinition;
+        }
     }
 
     public boolean isAugmenting() {
index 1f281898a33ef0aee0c58700c2ca11081bd562a2..f88e8d1495ea8f153412e75d4df59ac6107e0018 100644 (file)
@@ -993,26 +993,12 @@ public class ModuleBuilder implements Builder {
         public String toString() {
             StringBuilder sb = new StringBuilder(
                     ModuleImpl.class.getSimpleName());
-            sb.append("[\n");
-            sb.append("name=" + name + ",\n");
-            sb.append("namespace=" + namespace + ",\n");
-            sb.append("revision=" + revision + ",\n");
-            sb.append("prefix=" + prefix + ",\n");
-            sb.append("yangVersion=" + yangVersion + ",\n");
-            sb.append("description=" + description + ",\n");
-            sb.append("reference=" + reference + ",\n");
-            sb.append("organization=" + organization + ",\n");
-            sb.append("contact=" + contact + ",\n");
-            sb.append("childNodes=" + childNodes.values() + ",\n");
-            sb.append("groupings=" + groupings + ",\n");
-            sb.append("imports=" + imports + ",\n");
-            sb.append("features=" + features + ",\n");
-            sb.append("typeDefinitions=" + typeDefinitions + ",\n");
-            sb.append("notifications=" + notifications + ",\n");
-            sb.append("augmentations=" + augmentations + ",\n");
-            sb.append("rpcs=" + rpcs + ",\n");
-            sb.append("deviations=" + deviations + "\n");
-            sb.append("uses=" + uses + "\n");
+            sb.append("[");
+            sb.append("name=" + name);
+            sb.append(", namespace=" + namespace);
+            sb.append(", revision=" + revision);
+            sb.append(", prefix=" + prefix);
+            sb.append(", yangVersion=" + yangVersion);
             sb.append("]");
             return sb.toString();
         }
index 39dde73680482a716de697e59d11dcb8ec13fac2..ac25f9bbffe7df7b3613d358c2caae17c4323234 100644 (file)
@@ -154,8 +154,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
         return true;
     }
 
-    private static class RpcDefinitionImpl implements RpcDefinition {
-
+    private class RpcDefinitionImpl implements RpcDefinition {
         private final QName qname;
         private SchemaPath path;
         private String description;
@@ -264,6 +263,7 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
             final int prime = 31;
             int result = 1;
             result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
             return result;
         }
 
@@ -286,6 +286,13 @@ public class RpcDefinitionBuilder implements SchemaNodeBuilder,
             } else if (!qname.equals(other.qname)) {
                 return false;
             }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
             return true;
         }
 
index a184e23e1b84f6dea74e814801aea5660a1a7d0a..811b77566836b0f95ad9844562117bc239b569a1 100644 (file)
@@ -22,8 +22,8 @@ import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.util.UnionType;
 import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.Builder;
 import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.parser.util.YangParseException;
 
 /**
  * Builder for YANG union type. User can add type to this union as
@@ -32,9 +32,8 @@ import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder
  * types.
  */
 public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
-        TypeDefinitionBuilder, Builder {
-    private final static String CLASS_NAME = UnionTypeBuilder.class
-            .getSimpleName();
+        TypeDefinitionBuilder {
+    private final static String NAME = "union";
 
     private final int line;
     private final List<TypeDefinition<?>> types;
@@ -106,30 +105,28 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        throw new IllegalStateException("Can not set path to " + CLASS_NAME);
+        throw new YangParseException(line, "Can not set path to " + NAME);
     }
 
     @Override
     public void setDescription(final String description) {
-        throw new IllegalStateException("Can not set description to "
-                + CLASS_NAME);
+        throw new YangParseException(line, "Can not set description to " + NAME);
     }
 
     @Override
     public void setReference(final String reference) {
-        throw new IllegalStateException("Can not set reference to "
-                + CLASS_NAME);
+        throw new YangParseException(line, "Can not set reference to " + NAME);
     }
 
     @Override
     public void setStatus(final Status status) {
-        throw new IllegalStateException("Can not set status to " + CLASS_NAME);
+        throw new YangParseException(line, "Can not set status to " + NAME);
     }
 
     @Override
     public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
-        throw new IllegalStateException("Can not add unknown node to "
-                + CLASS_NAME);
+        throw new YangParseException(line, "Can not add unknown node to "
+                + NAME);
     }
 
     @Override
@@ -164,8 +161,7 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setRanges(List<RangeConstraint> ranges) {
-        throw new IllegalStateException("Can not set ranges to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set ranges to " + NAME);
     }
 
     @Override
@@ -175,8 +171,7 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setLengths(List<LengthConstraint> lengths) {
-        throw new IllegalStateException("Can not set lengths to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set lengths to " + NAME);
     }
 
     @Override
@@ -186,8 +181,7 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setPatterns(List<PatternConstraint> patterns) {
-        throw new IllegalStateException("Can not set patterns to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set patterns to " + NAME);
     }
 
     @Override
@@ -197,8 +191,8 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setFractionDigits(Integer fractionDigits) {
-        throw new IllegalStateException("Can not set fraction digits to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set fraction digits to "
+                + NAME);
     }
 
     @Override
@@ -213,8 +207,8 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setDefaultValue(Object defaultValue) {
-        throw new IllegalStateException("Can not set default value to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set default value to "
+                + NAME);
     }
 
     @Override
@@ -224,8 +218,7 @@ public class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setUnits(String units) {
-        throw new IllegalStateException("Can not set units to "
-                + UnionTypeBuilder.class.getSimpleName());
+        throw new YangParseException(line, "Can not set units to " + NAME);
     }
 
     public List<String> getActualPath() {
index 3e7beda7565cb41df80c895b135fc9d81255a968..c54a0dc03673f315c349b98541d5465994db01e7 100644 (file)
@@ -21,12 +21,11 @@ import org.opendaylight.controller.yang.model.api.SchemaNode;
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.UsesNode;\r
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.yang.parser.builder.api.Builder;\r
 import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;\r
 import org.opendaylight.controller.yang.parser.builder.api.UsesNodeBuilder;\r
 import org.opendaylight.controller.yang.parser.util.RefineHolder;\r
 \r
-final class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
+final class UsesNodeBuilderImpl implements UsesNodeBuilder {\r
     private final UsesNodeImpl instance;\r
     private final int line;\r
     private final SchemaPath groupingPath;\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangValidationException.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangValidationException.java
deleted file mode 100644 (file)
index 854b072..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.yang.parser.impl;
-
-/**
- * Unchecked exception thrown if yang definition is not valid according to
- * {@link YangModelValidationListener}
- */
-public class YangValidationException extends RuntimeException {
-
-    private static final long serialVersionUID = 7414330400390825381L;
-
-    public YangValidationException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public YangValidationException(String message) {
-        super(message);
-    }
-
-}
\ No newline at end of file
index 72e364cca5ef0dc2baa611e81e1968eeecb3e287..0df5d2cbdfc1eaf99be41250b2f220995b8251de 100644 (file)
@@ -678,6 +678,13 @@ public final class YangModelBuilderUtil {
         return result;
     }
 
+    /**
+     * Parse type body and return pattern constraints.
+     *
+     * @param ctx
+     *            type body
+     * @return list of pattern constraints
+     */
     private static List<PatternConstraint> getPatternConstraint(
             final Type_body_stmtsContext ctx) {
         List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
@@ -748,7 +755,7 @@ public final class YangModelBuilderUtil {
     }
 
     /**
-     * Get fraction digits value from context.
+     * Get fraction digits value from type body.
      *
      * @param ctx
      *            type body context to parse
@@ -766,6 +773,13 @@ public final class YangModelBuilderUtil {
         return result;
     }
 
+    /**
+     * Parse decimal64 fraction-digits value.
+     *
+     * @param ctx
+     *            decimal64 context
+     * @return fraction-digits value as Integer
+     */
     private static Integer parseFractionDigits(
             Decimal64_specificationContext ctx) {
         Integer result = null;
@@ -946,7 +960,6 @@ public final class YangModelBuilderUtil {
     public static TypeDefinition<?> parseUnknownTypeBody(QName typedefQName,
             Type_body_stmtsContext ctx) {
         UnknownType.Builder unknownType = new UnknownType.Builder(typedefQName);
-
         if (ctx != null) {
             List<RangeConstraint> rangeStatements = getRangeConstraints(ctx);
             List<LengthConstraint> lengthStatements = getLengthConstraints(ctx);
@@ -958,7 +971,6 @@ public final class YangModelBuilderUtil {
             unknownType.patterns(patternStatements);
             unknownType.fractionDigits(fractionDigits);
         }
-
         return unknownType.build();
     }
 
@@ -996,30 +1008,30 @@ public final class YangModelBuilderUtil {
             type = new Decimal64(actualPath, namespace, revision,
                     fractionDigits);
         } else if (typeName.startsWith("int")) {
-            if (typeName.equals("int8")) {
+            if ("int8".equals(typeName)) {
                 type = new Int8(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("int16")) {
+            } else if ("int16".equals(typeName)) {
                 type = new Int16(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("int32")) {
+            } else if ("int32".equals(typeName)) {
                 type = new Int32(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("int64")) {
+            } else if ("int64".equals(typeName)) {
                 type = new Int64(actualPath, namespace, revision,
                         rangeStatements, null, null);
             }
         } else if (typeName.startsWith("uint")) {
-            if (typeName.equals("uint8")) {
+            if ("uint8".equals(typeName)) {
                 type = new Uint8(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("uint16")) {
+            } else if ("uint16".equals(typeName)) {
                 type = new Uint16(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("uint32")) {
+            } else if ("uint32".equals(typeName)) {
                 type = new Uint32(actualPath, namespace, revision,
                         rangeStatements, null, null);
-            } else if (typeName.equals("uint64")) {
+            } else if ("uint64".equals(typeName)) {
                 type = new Uint64(actualPath, namespace, revision,
                         rangeStatements, null, null);
             }
@@ -1050,6 +1062,13 @@ public final class YangModelBuilderUtil {
         return type;
     }
 
+    /**
+     * Parse given context and find identityref base value.
+     *
+     * @param ctx
+     *            type body
+     * @return identityref base value as String
+     */
     public static String getIdentityrefBase(Type_body_stmtsContext ctx) {
         String result = null;
         outer: for (int i = 0; i < ctx.getChildCount(); i++) {
@@ -1067,6 +1086,13 @@ public final class YangModelBuilderUtil {
         return result;
     }
 
+    /**
+     * Parse given context and find require-instance value.
+     *
+     * @param ctx
+     *            type body
+     * @return require-instance value
+     */
     private static boolean isRequireInstance(Type_body_stmtsContext ctx) {
         for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
@@ -1082,6 +1108,13 @@ public final class YangModelBuilderUtil {
         return false;
     }
 
+    /**
+     * Parse given context and find leafref path.
+     *
+     * @param ctx
+     *            type body
+     * @return leafref path as String
+     */
     private static String parseLeafrefPath(Type_body_stmtsContext ctx) {
         for (int i = 0; i < ctx.getChildCount(); i++) {
             ParseTree child = ctx.getChild(i);
@@ -1234,21 +1267,26 @@ public final class YangModelBuilderUtil {
         } else if ("leafref".equals(typeName)) {
             throw new YangParseException(moduleName, line,
                     "The 'path' statement MUST be present if the type is 'leafref'.");
-        } else if("bits".equals(typeName)) {
+        } else if ("bits".equals(typeName)) {
             throw new YangParseException(moduleName, line,
                     "The 'bit' statement MUST be present if the type is 'bits'.");
-        } else if("enumeration".equals(typeName)) {
+        } else if ("enumeration".equals(typeName)) {
             throw new YangParseException(moduleName, line,
                     "The 'enum' statement MUST be present if the type is 'enumeration'.");
         }
     }
 
-    public static RefineHolder parseRefine(Refine_stmtContext child) {
-        final String refineTarget = stringFromNode(child);
-        final RefineHolder refine = new RefineHolder(refineTarget, child
+    /**
+     * Parse refine statement.
+     * @param refineCtx refine statement
+     * @return
+     */
+    public static RefineHolder parseRefine(Refine_stmtContext refineCtx) {
+        final String refineTarget = stringFromNode(refineCtx);
+        final RefineHolder refine = new RefineHolder(refineTarget, refineCtx
                 .getStart().getLine());
-        for (int j = 0; j < child.getChildCount(); j++) {
-            ParseTree refinePom = child.getChild(j);
+        for (int j = 0; j < refineCtx.getChildCount(); j++) {
+            ParseTree refinePom = refineCtx.getChild(j);
             if (refinePom instanceof Refine_pomContext) {
                 for (int k = 0; k < refinePom.getChildCount(); k++) {
                     ParseTree refineStmt = refinePom.getChild(k);
index 71d14a57343c10245795581159711d715b021821..8435ff683a08c32cef4656962cdc19347a16cea4 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.Status;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
@@ -78,7 +79,8 @@ public class TypesResolutionTest {
 
     @Test
     public void testEnumeration() {
-        Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+        Module tested = TestUtils
+                .findModule(testedModules, "custom-types-test");
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
 
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
@@ -108,8 +110,7 @@ public class TypesResolutionTest {
         EnumPair value3 = values.get(3);
         assertEquals("default", value3.getName());
         assertEquals(20, (int) value3.getValue());
-        assertEquals("default ip",
-                value3.getDescription());
+        assertEquals("default ip", value3.getDescription());
     }
 
     @Test
@@ -254,20 +255,18 @@ public class TypesResolutionTest {
         assertEquals(502L, (long) bit4.getPosition());
     }
 
-
     @Test
     public void testIanaTimezones() {
         Module tested = TestUtils.findModule(testedModules, "iana-timezones");
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs,
                 "iana-timezone");
-        /*
-        // FIXME: Refactor sources not to be timezone specific.
-        String expectedDesc = "A timezone location as defined by the IANA timezone\n       database (http://www.iana.org/time-zones)";
-        assertEquals(expectedDesc, testedType.getDescription());
+
+        String expectedDesc = "A timezone location as defined by the IANA timezone";
+        assertTrue(testedType.getDescription().contains(expectedDesc));
         assertNull(testedType.getReference());
         assertEquals(Status.CURRENT, testedType.getStatus());
-        */
+
         QName testedTypeQName = testedType.getQName();
         assertEquals(URI.create("urn:ietf:params:xml:ns:yang:iana-timezones"),
                 testedTypeQName.getNamespace());
@@ -335,9 +334,10 @@ public class TypesResolutionTest {
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs,
                 "service-type-ref");
-        IdentityrefType baseType = (IdentityrefType)testedType.getBaseType();
+        IdentityrefType baseType = (IdentityrefType) testedType.getBaseType();
         QName identity = baseType.getIdentity();
-        assertEquals(URI.create("urn:simple.container.demo"), identity.getNamespace());
+        assertEquals(URI.create("urn:simple.container.demo"),
+                identity.getNamespace());
         assertEquals(TestUtils.createDate("2012-04-16"), identity.getRevision());
         assertEquals("iit", identity.getPrefix());
         assertEquals("service-type", identity.getLocalName());
index b2a93ea07ec8f1749d6523788d8d51afe00c25b4..f6240c9a3f9f2d203711a6e4d3f25053367614d8 100644 (file)
@@ -212,9 +212,15 @@ public class YangParserTest {
                 .getDataChildByName("ifEntry");
         ContainerSchemaNode augmentedContainer = (ContainerSchemaNode) ifEntry
                 .getDataChildByName("augment-holder");
-        // Set<AugmentationSchema> augmentedContainerAugments =
-        // augmentedContainer
-        // .getAvailableAugmentations();
+
+        // augmentation defined in testfile1 and augmentation returned from
+        // augmented container have to be same
+        Set<AugmentationSchema> augmentedContainerAugments = augmentedContainer
+                .getAvailableAugmentations();
+        AugmentationSchema augmentDefinition = augmentedContainerAugments
+                .iterator().next();
+        assertEquals(augment1, augmentDefinition);
+
         LeafSchemaNode augmentedLeaf = (LeafSchemaNode) augmentedContainer
                 .getDataChildByName("ds0ChannelNumber");
         assertTrue(augmentedLeaf.isAugmenting());
@@ -230,18 +236,22 @@ public class YangParserTest {
         Set<AugmentationSchema> module3Augmentations = module3
                 .getAugmentations();
         assertEquals(2, module3Augmentations.size());
-        // AugmentationSchema augment3 = module3Augmentations.iterator().next();
-        // ContainerSchemaNode augmentedContainerDefinition =
-        // (ContainerSchemaNode) augment3
-        // .getDataChildByName("augment-holder");
-        // assertTrue(augmentedContainerDefinition.isAugmenting());
-        //
-        // // check
-        // assertEquals(augmentedContainer, augmentedContainerDefinition);
-        // assertEquals(augmentedContainerAugments.iterator().next(), augment1);
-        //
-        // assertEquals(augmentedLeaf, augmentedLeafDefinition);
-        // assertEquals(ifEntryAugments.iterator().next(), augment3);
+        AugmentationSchema augment3 = null;
+        for (AugmentationSchema as : module3Augmentations) {
+            if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
+                augment3 = as;
+            }
+        }
+        ContainerSchemaNode augmentedContainerDefinition = (ContainerSchemaNode) augment3
+                .getDataChildByName("augment-holder");
+        assertTrue(augmentedContainerDefinition.isAugmenting());
+
+        // check
+        assertEquals(augmentedContainer, augmentedContainerDefinition);
+        assertEquals(augmentedContainerAugments.iterator().next(), augment1);
+
+        assertEquals(augmentedLeaf, augmentedLeafDefinition);
+        assertEquals(ifEntryAugments.iterator().next(), augment3);
     }
 
     @Test
@@ -256,17 +266,21 @@ public class YangParserTest {
                 .getAvailableAugmentations();
         assertEquals(2, augmentations.size());
 
-        // AugmentationSchema augment = augmentations.iterator().next();
-
-        // ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment
-        // .getDataChildByName("augment-holder");
-        // assertNotNull(augmentHolder);
-        // assertTrue(augmentHolder.isAugmenting());
-        // QName augmentHolderQName = augmentHolder.getQName();
-        // assertEquals("augment-holder", augmentHolderQName.getLocalName());
-        // assertEquals("t3", augmentHolderQName.getPrefix());
-        // assertEquals("Description for augment holder",
-        // augmentHolder.getDescription());
+        AugmentationSchema augment = null;
+        for (AugmentationSchema as : augmentations) {
+            if ("if:ifType='ds0'".equals(as.getWhenCondition().toString())) {
+                augment = as;
+            }
+        }
+        ContainerSchemaNode augmentHolder = (ContainerSchemaNode) augment
+                .getDataChildByName("augment-holder");
+        assertNotNull(augmentHolder);
+        assertTrue(augmentHolder.isAugmenting());
+        QName augmentHolderQName = augmentHolder.getQName();
+        assertEquals("augment-holder", augmentHolderQName.getLocalName());
+        assertEquals("t3", augmentHolderQName.getPrefix());
+        assertEquals("Description for augment holder",
+                augmentHolder.getDescription());
     }
 
     @Test
@@ -285,7 +299,7 @@ public class YangParserTest {
         List<RangeConstraint> ranges = leafType.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
-        assertEquals(11L, range.getMin());
+        assertEquals(3L, range.getMin());
         assertEquals(20L, range.getMax());
     }
 
index 1a7b45ecb153e71d33c90036b26e14d2b1fba45d..783c89b6177540fc4150eb2d861fd741f1649a31 100644 (file)
@@ -20,7 +20,7 @@ module types2 {
 
     typedef my-type1 {
         type my-base-int32-type {
-            range "11..max";
+            range "3..9|11..max";
         }
         units "mile";
         default "11";
index 16e8b9e84639820d046e67b6b380ddadfb5f846a..31e0ad682d2b2b9e92473b103bb5d94191257bc1 100644 (file)
@@ -7,20 +7,42 @@
  */\r
 package org.opendaylight.controller.yang.model.api;\r
 \r
-import java.util.Set;\r
-\r
+/**\r
+ * AugmentationSchema represents augment definition. The "augment" statement\r
+ * allows a module or submodule to add to the schema tree defined in an external\r
+ * module, or the current module and its submodules, and to add to the nodes\r
+ * from a grouping in a "uses" statement.\r
+ */\r
 public interface AugmentationSchema extends DataNodeContainer {\r
 \r
+    /**\r
+     * @return when statement\r
+     */\r
     RevisionAwareXPath getWhenCondition();\r
 \r
+    /**\r
+     * @return textual description of this augment.\r
+     */\r
     String getDescription();\r
 \r
+    /**\r
+     * @return textual cross-reference to an external document that provides\r
+     *         additional information relevant to this node.\r
+     */\r
     String getReference();\r
 \r
+    /**\r
+     * @return actual status of this node.\r
+     */\r
     Status getStatus();\r
 \r
+    /**\r
+     * @return SchemaPath that identifies a node in the schema tree. This node\r
+     *         is called the augment's target node. The target node MUST be\r
+     *         either a container, list, choice, case, input, output, or\r
+     *         notification node. It is augmented with the nodes defined as\r
+     *         child nodes of this AugmentationSchema.\r
+     */\r
     SchemaPath getTargetPath();\r
 \r
-    Set<UsesNode> getUses();\r
-\r
 }\r
index 77ab5a3674fcd1737186a56ca95a2fb375aafa07..7e29c6210d93ad475c2e3d58f8ab2dd524e030e3 100644 (file)
@@ -9,11 +9,16 @@ package org.opendaylight.controller.yang.model.api;
 \r
 import java.util.Set;\r
 \r
+/**\r
+ * Interface for all nodes which are possible targets of augmentation. The\r
+ * target node of augmentation MUST be either a container, list, choice, case,\r
+ * input, output, or notification node.\r
+ */\r
 public interface AugmentationTarget {\r
+\r
     /**\r
-     * Returns a set of augmentations targeting this element.\r
-     * \r
-     * @return\r
+     * @return set of augmentations targeting this element.\r
      */\r
     Set<AugmentationSchema> getAvailableAugmentations();\r
+\r
 }\r
index 0fcbda9adcd92417c92fa394b11bf3be466c2cd6..2421e122088ef59fd1c3aed1f9171969d810ade8 100644 (file)
@@ -7,6 +7,9 @@
  */\r
 package org.opendaylight.controller.yang.model.api;\r
 \r
+/**\r
+ * The ChoiceCaseNode interface is used to define branches of the ChoiceNode.\r
+ */\r
 public interface ChoiceCaseNode extends DataSchemaNode, DataNodeContainer,\r
         AugmentationTarget {\r
 \r
index fd3c640b5e33d2ae8d10e07cef46d6b5d18abb7e..b67da660cc0dcca222d7d44ddc380fc091fbbb0d 100644 (file)
@@ -9,7 +9,15 @@ package org.opendaylight.controller.yang.model.api;
 
 import java.util.Set;
 
+/**
+ * The ChoiceNode defines a set of alternatives. It consists of a number of
+ * branches defined as ChoiceCaseNode objects.
+ */
 public interface ChoiceNode extends DataSchemaNode, AugmentationTarget {
 
+    /**
+     * @return ChoiceCaseNode objects defined in this node
+     */
     Set<ChoiceCaseNode> getCases();
+
 }
index 2143324825c511796c76f9cea523bf66eb458505..a48e6afdef936988fa7d5a465380e184c42069e0 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.yang.model.api;
 import java.util.Set;\r
 \r
 public interface ConstraintDefinition {\r
-    DataSchemaNode getParent();\r
 \r
     RevisionAwareXPath getWhenCondition();\r
 \r
index 62df36e28d63f123fda47a7ab541328d6d227cd9..f60fc160d8bea95ba16a61873a53379939a200f7 100644 (file)
@@ -7,9 +7,19 @@
  */\r
 package org.opendaylight.controller.yang.model.api;\r
 \r
+/**\r
+ * The ContainerSchemaNode is used to define an interior data node in the schema\r
+ * tree. There are two styles of containers, those that exist only for\r
+ * organizing the hierarchy of data nodes, and those whose presence in the\r
+ * configuration has an explicit meaning.\r
+ */\r
 public interface ContainerSchemaNode extends DataNodeContainer,\r
         AugmentationTarget, DataSchemaNode {\r
 \r
+    /**\r
+     * @return true, if presence of this container has an explicit meaning,\r
+     *         false otherwise\r
+     */\r
     boolean isPresenceContainer();\r
 \r
 }\r
index 8888208cc287a0239952e57319d027b0a8eaf68b..e8c814e20804eadea4ec916ec834a4b3310c7e82 100644 (file)
@@ -11,18 +11,45 @@ import java.util.Set;
 \r
 import org.opendaylight.controller.yang.common.QName;\r
 \r
+/**\r
+ * Node which can contains other nodes.\r
+ */\r
 public interface DataNodeContainer {\r
 \r
+    /**\r
+     * @return Set of all newly defined types within this DataNodeContainer\r
+     */\r
     Set<TypeDefinition<?>> getTypeDefinitions();\r
 \r
+    /**\r
+     * Set of all child nodes defined within this DataNodeContainer\r
+     */\r
     Set<DataSchemaNode> getChildNodes();\r
 \r
+    /**\r
+     * Set of all groupings defined within this DataNodeContainer\r
+     */\r
     Set<GroupingDefinition> getGroupings();\r
 \r
+    /**\r
+     * @param name\r
+     *            QName of seeked child\r
+     * @return child node of this DataNodeContainer if child with given name is\r
+     *         present, null otherwise\r
+     */\r
     DataSchemaNode getDataChildByName(QName name);\r
 \r
+    /**\r
+     * @param name\r
+     *            name of seeked child as String\r
+     * @return child node of this DataNodeContainer if child with given name is\r
+     *         present, null otherwise\r
+     */\r
     DataSchemaNode getDataChildByName(String name);\r
 \r
+    /**\r
+     * @return Set of all uses nodes defined within this DataNodeContainer\r
+     */\r
     Set<UsesNode> getUses();\r
 \r
 }\r
index 4d3c48654db23dfc6bb7fe53887c002c2bbb03b2..94ccd5dde6d2de1318e4071588fa06a475303f20 100644 (file)
@@ -11,17 +11,34 @@ import java.util.List;
 \r
 import org.opendaylight.controller.yang.common.QName;\r
 \r
+/**\r
+ * SchemaNode represents a node in schema tree.\r
+ */\r
 public interface SchemaNode {\r
 \r
     public QName getQName();\r
 \r
     public SchemaPath getPath();\r
 \r
+    /**\r
+     * @return textual description of this node.\r
+     */\r
     public String getDescription();\r
 \r
+    /**\r
+     * @return textual cross-reference to an external document that provides\r
+     *         additional information relevant to this node.\r
+     */\r
     public String getReference();\r
 \r
+    /**\r
+     * @return actual status of this node.\r
+     */\r
     public Status getStatus();\r
 \r
+    /**\r
+     * @return collection of all unknown nodes defined under this schema node.\r
+     */\r
     public List<UnknownSchemaNode> getUnknownSchemaNodes();\r
+\r
 }\r
index ec59ab740b76e14ca69b6e39643b4a20761fc1ae..bec194bf1cc67432a53320cd8fc4911af98977f2 100644 (file)
@@ -89,66 +89,77 @@ public class Devices implements IDaylightWeb {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
         List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
-        for (Switch device : switchManager.getNetworkDevices()) {
-            HashMap<String, String> nodeDatum = new HashMap<String, String>();
-            Node node = device.getNode();
-            Tier tier = (Tier) switchManager.getNodeProp(node,
-                    Tier.TierPropName);
-
-            nodeDatum.put("containerName", containerName);
-            nodeDatum.put("nodeName", switchManager.getNodeDescription(node));
-            nodeDatum.put("nodeId", node.toString());
-            int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
-                    : tier.getValue();
-            nodeDatum.put("tierName", TierHelper.getTierName(tierNumber)
-                    + " (Tier-" + tierNumber + ")");
-            nodeDatum.put("tier", tierNumber + "");
-            SwitchConfig sc = switchManager.getSwitchConfig(device.getNode()
-                    .toString());
-            String modeStr = (sc != null) ? sc.getMode() : "0";
-            nodeDatum.put("mode", modeStr);
-
-            nodeDatum.put("json", gson.toJson(nodeDatum));
-            nodeDatum.put("mac",
-                    HexEncode.bytesToHexString(device.getDataLayerAddress()));
-            StringBuffer sb1 = new StringBuffer();
-            Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
-            if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
-                Map<Short, String> portList = new HashMap<Short, String>();
-                for (NodeConnector nodeConnector : nodeConnectorSet) {
-                    String nodeConnectorNumberToStr = nodeConnector.getID().toString();
-                    Name ncName = ((Name) switchManager.getNodeConnectorProp(
-                            nodeConnector, Name.NamePropName));
-                    Config portStatus = ((Config) switchManager
-                            .getNodeConnectorProp(nodeConnector,
-                                    Config.ConfigPropName));
-                    
-                    String nodeConnectorName = (ncName != null) ? ncName.getValue()
-                            : "";
-                    nodeConnectorName += " ("+nodeConnector.getID()+")";
-                    
-                    if (portStatus != null) {
-                        if (portStatus.getValue() == Config.ADMIN_UP) {
-                            nodeConnectorName = "<span style='color:green;'>"+nodeConnectorName+"</span>";
-                        } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
-                            nodeConnectorName = "<span style='color:red;'>"+nodeConnectorName+"</span>";
+        if (switchManager != null) {
+            for (Switch device : switchManager.getNetworkDevices()) {
+                HashMap<String, String> nodeDatum = new HashMap<String, String>();
+                Node node = device.getNode();
+                Tier tier = (Tier) switchManager.getNodeProp(node,
+                        Tier.TierPropName);
+
+                nodeDatum.put("containerName", containerName);
+                nodeDatum.put("nodeName",
+                        switchManager.getNodeDescription(node));
+                nodeDatum.put("nodeId", node.toString());
+                int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
+                        : tier.getValue();
+                nodeDatum.put("tierName", TierHelper.getTierName(tierNumber)
+                        + " (Tier-" + tierNumber + ")");
+                nodeDatum.put("tier", tierNumber + "");
+                SwitchConfig sc = switchManager.getSwitchConfig(device
+                        .getNode().toString());
+                String modeStr = (sc != null) ? sc.getMode() : "0";
+                nodeDatum.put("mode", modeStr);
+
+                nodeDatum.put("json", gson.toJson(nodeDatum));
+                nodeDatum.put("mac", HexEncode.bytesToHexString(device
+                        .getDataLayerAddress()));
+                StringBuffer sb1 = new StringBuffer();
+                Set<NodeConnector> nodeConnectorSet = device
+                        .getNodeConnectors();
+                if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
+                    Map<Short, String> portList = new HashMap<Short, String>();
+                    for (NodeConnector nodeConnector : nodeConnectorSet) {
+                        String nodeConnectorNumberToStr = nodeConnector.getID()
+                                .toString();
+                        Name ncName = ((Name) switchManager
+                                .getNodeConnectorProp(nodeConnector,
+                                        Name.NamePropName));
+                        Config portStatus = ((Config) switchManager
+                                .getNodeConnectorProp(nodeConnector,
+                                        Config.ConfigPropName));
+
+                        String nodeConnectorName = (ncName != null) ? ncName
+                                .getValue() : "";
+                        nodeConnectorName += " (" + nodeConnector.getID() + ")";
+
+                        if (portStatus != null) {
+                            if (portStatus.getValue() == Config.ADMIN_UP) {
+                                nodeConnectorName = "<span style='color:green;'>"
+                                        + nodeConnectorName + "</span>";
+                            } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
+                                nodeConnectorName = "<span style='color:red;'>"
+                                        + nodeConnectorName + "</span>";
+                            }
                         }
+
+                        portList.put(
+                                Short.parseShort(nodeConnectorNumberToStr),
+                                nodeConnectorName);
                     }
-                    
-                    portList.put(Short.parseShort(nodeConnectorNumberToStr),
-                            nodeConnectorName);
-                }
 
-                Map<Short, String> sortedPortList = new TreeMap<Short, String>(portList);
+                    Map<Short, String> sortedPortList = new TreeMap<Short, String>(
+                            portList);
 
-                for (Entry<Short, String> e : sortedPortList.entrySet()) {
-                    sb1.append(e.getValue());
-                    sb1.append("<br>");
+                    for (Entry<Short, String> e : sortedPortList.entrySet()) {
+                        sb1.append(e.getValue());
+                        sb1.append("<br>");
+                    }
                 }
+                nodeDatum.put("ports", sb1.toString());
+                nodeData.add(nodeDatum);
             }
-            nodeDatum.put("ports", sb1.toString());
-            nodeData.add(nodeDatum);
         }
+
         DevicesJsonBean result = new DevicesJsonBean();
         result.setNodeData(nodeData);
         List<String> columnNames = new ArrayList<String>();
@@ -312,12 +323,14 @@ public class Devices implements IDaylightWeb {
         String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this);
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
-        for (SubnetConfig conf : switchManager.getSubnetsConfigList()) {
-            Map<String, String> subnet = new HashMap<String, String>();
-            subnet.put("name", conf.getName());
-            subnet.put("subnet", conf.getSubnet());
-            subnet.put("json", gson.toJson(conf));
-            subnets.add(subnet);
+        if (switchManager != null) {
+            for (SubnetConfig conf : switchManager.getSubnetsConfigList()) {
+                Map<String, String> subnet = new HashMap<String, String>();
+                subnet.put("name", conf.getName());
+                subnet.put("subnet", conf.getSubnet());
+                subnet.put("json", gson.toJson(conf));
+                subnets.add(subnet);
+            }
         }
         DevicesJsonBean result = new DevicesJsonBean();
         result.setColumnNames(SubnetConfig.getGuiFieldsNames());
@@ -464,8 +477,10 @@ public class Devices implements IDaylightWeb {
         String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this);
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
-        for (SpanConfig conf : switchManager.getSpanConfigList()) {
-            spanConfigs_json.add(gson.toJson(conf));
+        if (switchManager != null) {
+            for (SpanConfig conf : switchManager.getSpanConfigList()) {
+                spanConfigs_json.add(gson.toJson(conf));
+            }
         }
         ObjectMapper mapper = new ObjectMapper();
         List<Map<String, String>> spanConfigs = new ArrayList<Map<String, String>>();
@@ -499,8 +514,9 @@ public class Devices implements IDaylightWeb {
         String containerName = DaylightWebUtil.getAuthorizedContainer(request, container, this);
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
-        if (switchManager == null)
+        if (switchManager == null) {
             return null;
+        }
 
         Map<String, Object> nodes = new HashMap<String, Object>();
         Map<Short, String> port;