Added capability to resolve Enumeration type definitions; 28/228/1
authorlsedlak <lsedlak@cisco.com>
Tue, 23 Apr 2013 13:48:53 +0000 (15:48 +0200)
committerlsedlak <lsedlak@cisco.com>
Tue, 23 Apr 2013 14:38:34 +0000 (16:38 +0200)
Added ReferencedTypeImpl for resolving of referenced enumeration types;
Modified GeneratedTypeBuilder for setting correct package name for
enumeration types defined as inner enums in Generated Types;
Modified EnumBuilder added extends of Type interface in
binding-model-api;
Added test case for resolving of Leaf Enumeration in GeneratedTypesTest;

Modified BindingGeneratorImpl accordingly:
Added Implementation to resolve Enumeration type,
The Schema Tree traversal methods removed - replaced by
DataNodeIterator,

Refactored TypeProviderImpl - resolving of leafrefs now through
SchemaContextUtil methods;

Chenged package name in code-generator-demo to
org.opendaylight.controller.yang;

Added DataNodeIterator and SchemaContextUtil into yang-model-util

Fixed Raw TypeDefinition in ExtendedType implementation;
Fixed SchemaPath setting in EnumerationType implementation - added two
parametric constructors that contains SchemaPath parameter;
Updated parseTypeBody method in YangModelBuilderUtil in
yang-model-parser-impl - added Enumeration constructor call with schema
path parameter;
Fixed constructor with XPath parameter visbility in Leafref
implementation;

Added extension of AugmentationTarget for ChoiceNode in yang-model-api;

Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
19 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/BindingGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/EnumerationBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ReferencedTypeImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/TypeProviderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/yang/types/test/GeneratedTypesTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/iana-if-type@2012-06-05.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-interfaces@2012-11-15.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-yang-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/EnumBuilder.java
opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/Demo.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/yang/Demo.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.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-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EnumerationType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/ExtendedType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Leafref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java [new file with mode: 0644]

index f959865212a53da8684075d0fc5df85ec9439590..d36f97244f7cb7cdab44cf9cbed6e9a08b13a1bd 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.EnumBuilder;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
@@ -32,42 +33,45 @@ import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSign
 import org.opendaylight.controller.sal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.controller.yang.model.api.DataNodeContainer;
 import org.opendaylight.controller.yang.model.api.DataSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
 import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.NotificationDefinition;
+import org.opendaylight.controller.yang.model.api.RpcDefinition;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
+import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.controller.yang.model.util.DataNodeIterator;
+import org.opendaylight.controller.yang.model.util.ExtendedType;
 
 public class BindingGeneratorImpl implements BindingGenerator {
-    
+
     private static final String[] SET_VALUES = new String[] { "abstract",
-        "assert", "boolean", "break", "byte", "case", "catch", "char",
-        "class", "const", "continue", "default", "double", "do", "else",
-        "enum", "extends", "false", "final", "finally", "float", "for",
-        "goto", "if", "implements", "import", "instanceof", "int",
-        "interface", "long", "native", "new", "null", "package", "private",
-        "protected", "public", "return", "short", "static", "strictfp",
-        "super", "switch", "synchronized", "this", "throw", "throws",
-        "transient", "true", "try", "void", "volatile", "while" };
+            "assert", "boolean", "break", "byte", "case", "catch", "char",
+            "class", "const", "continue", "default", "double", "do", "else",
+            "enum", "extends", "false", "final", "finally", "float", "for",
+            "goto", "if", "implements", "import", "instanceof", "int",
+            "interface", "long", "native", "new", "null", "package", "private",
+            "protected", "public", "return", "short", "static", "strictfp",
+            "super", "switch", "synchronized", "this", "throw", "throws",
+            "transient", "true", "try", "void", "volatile", "while" };
 
     public static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(
             Arrays.asList(SET_VALUES));
-    
+
     private static Calendar calendar = new GregorianCalendar();
     private Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;
-    private List<ContainerSchemaNode> schemaContainers;
-    private List<ListSchemaNode> schemaLists;
     private TypeProvider typeProvider;
     private String basePackageName;
 
     public BindingGeneratorImpl() {
         super();
     }
-    
+
     private static String validatePackage(final String packageName) {
         if (packageName != null) {
             final String[] packNameParts = packageName.split("\\.");
@@ -76,7 +80,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 for (int i = 0; i < packNameParts.length; ++i) {
                     if (JAVA_RESERVED_WORDS.contains(packNameParts[i])) {
                         packNameParts[i] = "_" + packNameParts[i];
-                    } 
+                    }
                     if (i > 0) {
                         builder.append(".");
                     }
@@ -87,53 +91,207 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         return packageName;
     }
-    
+
     @Override
     public List<Type> generateTypes(final SchemaContext context) {
         final List<Type> genTypes = new ArrayList<Type>();
-        
+
         typeProvider = new TypeProviderImpl(context);
         if (context != null) {
             final Set<Module> modules = context.getModules();
-            
+
             if (modules != null) {
                 for (final Module module : modules) {
-                    genTypeBuilders = new HashMap<String, Map<String, GeneratedTypeBuilder>>();
-                    schemaContainers = new ArrayList<ContainerSchemaNode>();
-                    schemaLists = new ArrayList<ListSchemaNode>();
+                    DataNodeIterator moduleIterator = new DataNodeIterator(module);
                     
-                    basePackageName = resolveBasePackageName(module.getNamespace(),
-                            module.getYangVersion());
+                    genTypeBuilders = new HashMap<String, Map<String, GeneratedTypeBuilder>>();
+                    final List<ContainerSchemaNode> schemaContainers = moduleIterator.allContainers();
+                    final List<ListSchemaNode> schemaLists = moduleIterator.allLists();
+
+                    basePackageName = resolveBasePackageName(
+                            module.getNamespace(), module.getYangVersion());
 
-                    traverseModule(module);
                     if (schemaContainers.size() > 0) {
                         for (final ContainerSchemaNode container : schemaContainers) {
                             genTypes.add(containerToGenType(container));
                         }
                     }
-
                     if (schemaLists.size() > 0) {
                         for (final ListSchemaNode list : schemaLists) {
                             genTypes.addAll(listToGenType(list));
                         }
                     }
+
+                    final GeneratedType genDataType = moduleToDataType(module);
+                    final GeneratedType genRpcType = rpcMethodsToGenType(module);
+                    final GeneratedType genNotifyType = notifycationsToGenType(module);
+
+                    if (genDataType != null) {
+                        genTypes.add(genDataType);
+                    }
+                    if (genRpcType != null) {
+                        genTypes.add(genRpcType);
+                    }
+                    if (genNotifyType != null) {
+                        genTypes.add(genNotifyType);
+                    }
                 }
             }
         }
-
         return genTypes;
     }
-    
+
+    private GeneratedType moduleToDataType(final Module module) {
+        if (module != null) {
+            final Set<TypeDefinition<?>> typeDefinitions = module
+                    .getTypeDefinitions();
+            final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(
+                    module, "Data");
+
+            if (moduleDataTypeBuilder != null) {
+                if (typeDefinitions != null) {
+                    for (final TypeDefinition<?> typedef : typeDefinitions) {
+                        if (isDerivedFromEnumerationType(typedef)) {
+                            final EnumTypeDefinition enumBaseType = enumTypeDefFromExtendedType(typedef);
+                            resolveEnumFromTypeDefinition(enumBaseType, typedef
+                                    .getQName().getLocalName(),
+                                    moduleDataTypeBuilder);
+                        }
+                    }
+                }
+
+                final Set<DataSchemaNode> dataNodes = module.getChildNodes();
+                resolveTypesFromDataSchemaNode(moduleDataTypeBuilder, dataNodes);
+                return moduleDataTypeBuilder.toInstance();
+            }
+        }
+        return null;
+    }
+
+    private boolean isDerivedFromEnumerationType(
+            final TypeDefinition<?> typeDefinition) {
+        if (typeDefinition != null) {
+            if (typeDefinition.getBaseType() instanceof EnumTypeDefinition) {
+                return true;
+            } else if (typeDefinition.getBaseType() instanceof ExtendedType) {
+                return isDerivedFromEnumerationType(typeDefinition
+                        .getBaseType());
+            }
+        }
+        return false;
+    }
+
+    private EnumTypeDefinition enumTypeDefFromExtendedType(
+            final TypeDefinition<?> typeDefinition) {
+        if (typeDefinition != null) {
+            if (typeDefinition.getBaseType() instanceof EnumTypeDefinition) {
+                return (EnumTypeDefinition) typeDefinition.getBaseType();
+            } else if (typeDefinition.getBaseType() instanceof ExtendedType) {
+                return enumTypeDefFromExtendedType(typeDefinition.getBaseType());
+            }
+        }
+        return null;
+    }
+
+    private EnumBuilder resolveEnumFromTypeDefinition(
+            final EnumTypeDefinition enumTypeDef, final String enumName,
+            final GeneratedTypeBuilder typeBuilder) {
+        if ((enumTypeDef != null) && (typeBuilder != null)
+                && (enumTypeDef.getQName() != null)
+                && (enumTypeDef.getQName().getLocalName() != null)) {
+
+            final String enumerationName = CodeGeneratorHelper
+                    .parseToClassName(enumName);
+            final EnumBuilder enumBuilder = typeBuilder
+                    .addEnumeration(enumerationName);
+
+            if (enumBuilder != null) {
+                final List<EnumPair> enums = enumTypeDef.getValues();
+                if (enums != null) {
+                    int listIndex = 0;
+                    for (final EnumPair enumPair : enums) {
+                        if (enumPair != null) {
+                            final String enumPairName = CodeGeneratorHelper
+                                    .parseToClassName(enumPair.getName());
+                            Integer enumPairValue = enumPair.getValue();
+
+                            if (enumPairValue == null) {
+                                enumPairValue = listIndex;
+                            }
+                            enumBuilder.addValue(enumPairName, enumPairValue);
+                            listIndex++;
+                        }
+                    }
+                }
+                return enumBuilder;
+            }
+        }
+        return null;
+    }
+
+    private GeneratedTypeBuilder moduleTypeBuilder(final Module module,
+            final String postfix) {
+        if (module != null) {
+            String packageName = resolveBasePackageName(module.getNamespace(),
+                    module.getYangVersion());
+            final String moduleName = CodeGeneratorHelper
+                    .parseToClassName(module.getName()) + postfix;
+
+            if (packageName != null) {
+                packageName = validatePackage(packageName);
+                return new GeneratedTypeBuilderImpl(packageName, moduleName);
+            }
+        }
+        return null;
+    }
+
+    private GeneratedType rpcMethodsToGenType(final Module module) {
+        if (module != null) {
+            final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
+
+            if ((rpcDefinitions != null) && !rpcDefinitions.isEmpty()) {
+                final GeneratedTypeBuilder rpcTypeBuilder = moduleTypeBuilder(
+                        module, "Rpc");
+
+                for (final RpcDefinition rpc : rpcDefinitions) {
+                    if (rpc != null) {
+
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private GeneratedType notifycationsToGenType(final Module module) {
+        if (module != null) {
+            final Set<NotificationDefinition> notifications = module
+                    .getNotifications();
+
+            if ((notifications != null) && !notifications.isEmpty()) {
+                final GeneratedTypeBuilder notifyTypeBuilder = moduleTypeBuilder(
+                        module, "Notification");
+
+                for (final NotificationDefinition notification : notifications) {
+                    if (notification != null) {
+
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     private String resolveGeneratedTypePackageName(final SchemaPath schemaPath) {
         final StringBuilder builder = new StringBuilder();
         builder.append(basePackageName);
         if ((schemaPath != null) && (schemaPath.getPath() != null)) {
             final List<QName> pathToNode = schemaPath.getPath();
-            final int traversalSteps = (pathToNode.size() - 1); 
+            final int traversalSteps = (pathToNode.size() - 1);
             for (int i = 0; i < traversalSteps; ++i) {
                 builder.append(".");
                 String nodeLocalName = pathToNode.get(i).getLocalName();
-                
+
                 // TODO: create method
                 nodeLocalName = nodeLocalName.replace(":", ".");
                 nodeLocalName = nodeLocalName.replace("-", ".");
@@ -151,22 +309,32 @@ public class BindingGeneratorImpl implements BindingGenerator {
         final Set<DataSchemaNode> schemaNodes = container.getChildNodes();
         final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(container);
 
-        for (final DataSchemaNode node : schemaNodes) {
-            if (node instanceof LeafSchemaNode) {
-                resolveLeafSchemaNodeAsMethod(typeBuilder,
-                        (LeafSchemaNode) node);
-            } else if (node instanceof LeafListSchemaNode) {
-                resolveLeafListSchemaNode(typeBuilder,
-                        (LeafListSchemaNode) node);
+        resolveTypesFromDataSchemaNode(typeBuilder, schemaNodes);
+        return typeBuilder.toInstance();
+    }
 
-            } else if (node instanceof ContainerSchemaNode) {
-                resolveContainerSchemaNode(typeBuilder,
-                        (ContainerSchemaNode) node);
-            } else if (node instanceof ListSchemaNode) {
-                resolveListSchemaNode(typeBuilder, (ListSchemaNode) node);
+    private GeneratedTypeBuilder resolveTypesFromDataSchemaNode(
+            final GeneratedTypeBuilder typeBuilder,
+            final Set<DataSchemaNode> schemaNodes) {
+
+        if ((schemaNodes != null) && (typeBuilder != null)) {
+            for (final DataSchemaNode node : schemaNodes) {
+                if (node instanceof LeafSchemaNode) {
+                    resolveLeafSchemaNodeAsMethod(typeBuilder,
+                            (LeafSchemaNode) node);
+                } else if (node instanceof LeafListSchemaNode) {
+                    resolveLeafListSchemaNode(typeBuilder,
+                            (LeafListSchemaNode) node);
+
+                } else if (node instanceof ContainerSchemaNode) {
+                    resolveContainerSchemaNode(typeBuilder,
+                            (ContainerSchemaNode) node);
+                } else if (node instanceof ListSchemaNode) {
+                    resolveListSchemaNode(typeBuilder, (ListSchemaNode) node);
+                }
             }
         }
-        return typeBuilder.toInstance();
+        return typeBuilder;
     }
 
     private boolean resolveLeafSchemaNodeAsMethod(
@@ -180,12 +348,29 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
             if (leafName != null) {
                 final TypeDefinition<?> typeDef = leaf.getType();
-                final Type javaType = typeProvider
-                        .javaTypeForSchemaDefinitionType(typeDef);
 
-                constructGetter(typeBuilder, leafName, leafDesc, javaType);
+                Type type = null;
+                if (!(typeDef instanceof EnumTypeDefinition)
+                        && !isDerivedFromEnumerationType(typeDef)) {
+                    type = typeProvider
+                            .javaTypeForSchemaDefinitionType(typeDef);
+                } else {
+                    if (isImported(leaf.getPath(), typeDef.getPath())) {
+                        //TODO: resolving of imported enums as references to GeneratedTypeData interface
+                    } else {
+                        final EnumTypeDefinition enumTypeDef = enumTypeDefFromExtendedType(typeDef);
+                        final EnumBuilder enumBuilder = resolveEnumFromTypeDefinition(enumTypeDef, leafName,
+                                typeBuilder);
+                        
+                        if (enumBuilder != null) {
+                            type = new ReferencedTypeImpl(enumBuilder.getPackageName(), enumBuilder.getName());
+                        }
+                    }
+                }
+
+                constructGetter(typeBuilder, leafName, leafDesc, type);
                 if (!leaf.isConfiguration()) {
-                    constructSetter(typeBuilder, leafName, leafDesc, javaType);
+                    constructSetter(typeBuilder, leafName, leafDesc, type);
                 }
                 return true;
             }
@@ -193,6 +378,26 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return false;
     }
 
+    private boolean isImported(final SchemaPath leafPath,
+            final SchemaPath typeDefPath) {
+        if ((leafPath != null) && (leafPath.getPath() != null)
+                && (typeDefPath != null) && (typeDefPath.getPath() != null)) {
+
+            final QName leafPathQName = leafPath.getPath().get(0);
+            final QName typePathQName = typeDefPath.getPath().get(0);
+
+            if ((leafPathQName != null)
+                    && (leafPathQName.getNamespace() != null)
+                    && (typePathQName != null)
+                    && (typePathQName.getNamespace() != null)) {
+                
+                return !leafPathQName.getNamespace().equals(
+                        typePathQName.getNamespace());
+            }
+        }
+        return false;
+    }
+
     private boolean resolveLeafSchemaNodeAsProperty(
             final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf,
             boolean isReadOnly) {
@@ -205,8 +410,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
             if (leafName != null) {
                 final TypeDefinition<?> typeDef = leaf.getType();
-                
-                //TODO: properly resolve enum types
+
+                // TODO: properly resolve enum types
                 final Type javaType = typeProvider
                         .javaTypeForSchemaDefinitionType(typeDef);
 
@@ -419,7 +624,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
         final List<Type> genTypes = new ArrayList<Type>();
         if (genTOBuilder != null) {
             final GeneratedTransferObject genTO = genTOBuilder.toInstance();
-            constructGetter(typeBuilder, genTO.getName(), "Returns Primary Key of Yang List Type", genTO);
+            constructGetter(typeBuilder, genTO.getName(),
+                    "Returns Primary Key of Yang List Type", genTO);
             genTypes.add(genTO);
         }
         genTypes.add(typeBuilder.toInstance());
@@ -462,7 +668,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         if (list.getKeyDefinition() != null) {
             final List<QName> keyDefinitions = list.getKeyDefinition();
-            
+
             for (final QName keyDefinition : keyDefinitions) {
                 listKeys.add(keyDefinition.getLocalName());
             }
@@ -489,63 +695,4 @@ public class BindingGeneratorImpl implements BindingGenerator {
         }
         return typeBuilder;
     }
-
-    private void traverseModule(final Module module) {
-        final Set<DataSchemaNode> schemaNodes = module.getChildNodes();
-
-        for (DataSchemaNode node : schemaNodes) {
-            if (node instanceof ContainerSchemaNode) {
-                schemaContainers.add((ContainerSchemaNode) node);
-                traverse((ContainerSchemaNode) node);
-            }
-        }
-    }
-
-    private void traverse(final DataNodeContainer dataNode) {
-        if (!containChildDataNodeContainer(dataNode)) {
-            return;
-        }
-
-        final Set<DataSchemaNode> childs = dataNode.getChildNodes();
-        if (childs != null) {
-            for (DataSchemaNode childNode : childs) {
-                if (childNode instanceof ContainerSchemaNode) {
-                    final ContainerSchemaNode container = (ContainerSchemaNode) childNode;
-                    schemaContainers.add(container);
-                    traverse(container);
-                }
-
-                if (childNode instanceof ListSchemaNode) {
-                    final ListSchemaNode list = (ListSchemaNode) childNode;
-                    schemaLists.add(list);
-                    traverse(list);
-                }
-            }
-        }
-    }
-
-    /**
-     * Returns <code>true</code> if and only if the child node contain at least
-     * one child container schema node or child list schema node, otherwise will
-     * always returns <code>false</code>
-     * 
-     * @param container
-     * @return <code>true</code> if and only if the child node contain at least
-     *         one child container schema node or child list schema node,
-     *         otherwise will always returns <code>false</code>
-     */
-    private boolean containChildDataNodeContainer(
-            final DataNodeContainer container) {
-        if (container != null) {
-            final Set<DataSchemaNode> childs = container.getChildNodes();
-            if ((childs != null) && (childs.size() > 0)) {
-                for (final DataSchemaNode childNode : childs) {
-                    if (childNode instanceof DataNodeContainer) {
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
 }
index e58a0adeaa1c241319f75272bc8952d13cdd397a..4dde4599118343649019b9bf1331e8ed2073f5e3 100644 (file)
@@ -26,7 +26,17 @@ final class EnumerationBuilderImpl implements EnumBuilder {
         this.name = name;
         values = new ArrayList<Enumeration.Pair>();
     }
+    
+    @Override
+    public String getPackageName() {
+        return packageName;
+    }
 
+    @Override
+    public String getName() {
+        return name;
+    }
+    
     @Override
     public void addValue(final String name, final Integer value) {
         values.add(new EnumPairImpl(name, value));
index 2de2aaa332f20d2462e464a6162afd4bb3126408..2e4ed89c7b5003ab0a0e4ec5b8192037bd7f6288 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedT
 import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
 
 public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
-    
+
     private final String packageName;
     private String comment;
     private final String name;
@@ -35,7 +35,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         this.packageName = packageName;
         this.name = name;
     }
-    
+
     @Override
     public Type getParentType() {
         return this;
@@ -67,7 +67,8 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
 
     @Override
     public EnumBuilder addEnumeration(final String name) {
-        final EnumBuilder builder = new EnumerationBuilderImpl(packageName,
+        final String innerPackageName = packageName + "." + this.name;
+        final EnumBuilder builder = new EnumerationBuilderImpl(innerPackageName,
                 name);
         enumDefinitions.add(builder);
         return builder;
@@ -94,16 +95,16 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         private final List<MethodSignature.Parameter> parameters;
         private String comment = "";
         private final Type parent;
-        
+
         public MethodSignatureBuilderImpl(final Type parent, final String name) {
             super();
             this.name = name;
             this.parent = parent;
             parameters = new ArrayList<MethodSignature.Parameter>();
-            //TODO: move implementation elsewhere!
-            
+            // TODO: move implementation elsewhere!
+
         }
-        
+
         @Override
         public void addReturnType(Type returnType) {
             if (returnType != null) {
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ReferencedTypeImpl.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ReferencedTypeImpl.java
new file mode 100644 (file)
index 0000000..3a101cd
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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.sal.binding.generator.impl;
+
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+
+final class ReferencedTypeImpl implements Type {
+    
+    private final String packageName;
+    private final String name;
+    
+    public ReferencedTypeImpl(String packageName, String name) {
+        super();
+        this.packageName = packageName;
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.opendaylight.controller.sal.binding.model.api.Type#getPackageName()
+     */
+    @Override
+    public String getPackageName() {
+        return packageName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.opendaylight.controller.sal.binding.model.api.Type#getName()
+     */
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result
+                + ((packageName == null) ? 0 : packageName.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ReferencedTypeImpl other = (ReferencedTypeImpl) obj;
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (packageName == null) {
+            if (other.packageName != null) {
+                return false;
+            }
+        } else if (!packageName.equals(other.packageName)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ReferencedTypeImpl [packageName=");
+        builder.append(packageName);
+        builder.append(", name=");
+        builder.append(name);
+        builder.append("]");
+        return builder.toString();
+    }
+}
index bb5e80a5257e0153d9ccc24384f319381744eb50..076edd07a486a850acb5cae9bfd7567ec4eb0621 100644 (file)
@@ -7,38 +7,28 @@
  */
 package org.opendaylight.controller.sal.binding.yang.types;
 
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-
 import org.opendaylight.controller.binding.generator.util.Types;
 import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
 import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.controller.yang.model.api.DataNodeContainer;
 import org.opendaylight.controller.yang.model.api.DataSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
-import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.ModuleImport;
 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.Leafref;
+import org.opendaylight.controller.yang.model.util.SchemaContextUtil;
 
 public class TypeProviderImpl implements TypeProvider {
 
-    private SchemaContext schemaContext;
+    private SchemaContextUtil schemaContextUtil;
 
     public TypeProviderImpl(SchemaContext schemaContext) {
-        this.schemaContext = schemaContext;
+        schemaContextUtil = new SchemaContextUtil(schemaContext);
     }
 
     /*
@@ -55,7 +45,8 @@ public class TypeProviderImpl implements TypeProvider {
     }
 
     @Override
-    public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> typeDefinition) {
+    public Type javaTypeForSchemaDefinitionType(
+            final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
         if (typeDefinition != null) {
             if (typeDefinition instanceof Leafref) {
@@ -64,21 +55,20 @@ public class TypeProviderImpl implements TypeProvider {
             } else if (typeDefinition instanceof IdentityrefTypeDefinition) {
 
             } else if (typeDefinition instanceof ExtendedType) {
-                final TypeDefinition<?> baseType = typeDefinition.getBaseType(); 
+                final TypeDefinition<?> baseType = typeDefinition.getBaseType();
                 return javaTypeForSchemaDefinitionType(baseType);
-            }
-            else {
+            } else {
                 returnType = baseTypeForExtendedType(typeDefinition);
             }
         }
         return returnType;
     }
-    
+
     public Type baseTypeForExtendedType(final TypeDefinition<?> typeDefinition) {
         Type returnType = null;
         if (typeDefinition != null) {
             if (typeDefinition instanceof ExtendedType) {
-                final TypeDefinition<?> extType = typeDefinition.getBaseType(); 
+                final TypeDefinition<?> extType = typeDefinition.getBaseType();
                 return baseTypeForExtendedType(extType);
             } else {
                 returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
@@ -87,7 +77,7 @@ public class TypeProviderImpl implements TypeProvider {
         }
         return returnType;
     }
-    
+
     public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType) {
         Type returnType = null;
         if ((leafrefType != null) && (leafrefType.getPathStatement() != null)
@@ -100,22 +90,19 @@ public class TypeProviderImpl implements TypeProvider {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
                     returnType = Types.typeForClass(Object.class);
                 } else {
-                    final Module module = resolveModuleFromSchemaPath(leafrefType
-                            .getPath());
+                    final Module module = schemaContextUtil
+                            .resolveModuleFromSchemaPath(leafrefType.getPath());
                     if (module != null) {
-                        Queue<String> leafrefPath;
-                        if (!xpath.isAbsolute()) {
-                            leafrefPath = resolveRelativeXPath(xpath,
-                                    leafrefType.getPath());
+                        final DataSchemaNode dataNode;
+                        if (xpath.isAbsolute()) {
+                            dataNode = schemaContextUtil.findDataSchemaNode(
+                                    module, xpath);
                         } else {
-                            leafrefPath = xpathToPrefixedPath(strXPath,
-                                    module.getName());
-                        }
-                        if (leafrefPath != null) {
-                            final DataSchemaNode dataNode = findSchemaNodeForGivenPath(
-                                    module, leafrefPath);
-                            returnType = resolveTypeFromDataSchemaNode(dataNode);
+                            dataNode = schemaContextUtil
+                                    .findDataSchemaNodeForRelativeXPath(module,
+                                            leafrefType, xpath);
                         }
+                        returnType = resolveTypeFromDataSchemaNode(dataNode);
                     }
                 }
             }
@@ -136,150 +123,4 @@ public class TypeProviderImpl implements TypeProvider {
         }
         return returnType;
     }
-
-    /**
-     * Search which starts from root of Module.
-     * 
-     * @param module
-     * @param prefixedPath
-     * @return
-     */
-    private DataSchemaNode findSchemaNodeForGivenPath(final Module module,
-            final Queue<String> prefixedPath) {
-        if ((module != null) && (prefixedPath != null)) {
-            DataNodeContainer nextContainer = module;
-            final String modulePrefix = module.getPrefix();
-            
-            String childNodeName = null;
-            DataSchemaNode schemaNode = null;
-            while ((nextContainer != null) && (prefixedPath.size() > 0)) {
-                childNodeName = prefixedPath.poll();
-                if (childNodeName.contains(":")) {
-                    final String[] prefixedChildNode = childNodeName.split(":");
-                    if ((modulePrefix != null)
-                            && modulePrefix.equals(prefixedChildNode[0])) {
-
-                        childNodeName = prefixedChildNode[1];
-                    } else {
-                        final Module nextModule = resolveModuleForPrefix(
-                                prefixedChildNode[0], module);
-                        final Queue<String> nextModulePrefixedPath = new LinkedList<String>();
-                        nextModulePrefixedPath.add(childNodeName);
-                        nextModulePrefixedPath.addAll(prefixedPath);
-                        prefixedPath.clear();
-
-                        schemaNode = findSchemaNodeForGivenPath(nextModule,
-                                nextModulePrefixedPath);
-
-                        return schemaNode;
-                    }
-                }
-
-                schemaNode = nextContainer.getDataChildByName(childNodeName);
-                if (schemaNode instanceof ContainerSchemaNode) {
-                    nextContainer = (ContainerSchemaNode) schemaNode;
-                } else if (schemaNode instanceof ListSchemaNode) {
-                    nextContainer = (ListSchemaNode) schemaNode;
-                } else {
-                    return schemaNode;
-                }
-            }
-        }
-
-        return null;
-    }
-
-    private Module resolveModuleFromSchemaPath(final SchemaPath schemaPath) {
-        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
-            final QName qname = schemaPath.getPath().get(0);
-
-            if ((qname != null) && (qname.getNamespace() != null)) {
-                return schemaContext
-                        .findModuleByNamespace(qname.getNamespace());
-            }
-        }
-        return null;
-    }
-
-    private Queue<String> xpathToPrefixedPath(final String xpath,
-            final String moduleName) {
-        final Queue<String> retQueue = new LinkedList<String>();
-        if ((xpath != null) && (moduleName != null)) {
-            final String[] prefixedPath = xpath.split("/");
-
-            if (prefixedPath != null) {
-                for (int i = 0; i < prefixedPath.length; ++i) {
-                    if (!prefixedPath[i].isEmpty()) {
-                        retQueue.add(prefixedPath[i]);
-                    }
-                }
-            }
-        }
-        return retQueue;
-    }
-
-    private Module resolveModuleForPrefix(final String prefix,
-            final Module parent) {
-        if ((prefix != null) && (parent != null)) {
-            final Set<ModuleImport> imports = parent.getImports();
-
-            if (imports != null) {
-                for (final ModuleImport impModule : imports) {
-                    final String impModPrefix = impModule.getPrefix();
-                    if ((impModPrefix != null) && prefix.equals(impModPrefix)) {
-                        return resolveModuleFromContext(prefix,
-                                impModule.getModuleName());
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    private Module resolveModuleFromContext(final String prefix,
-            final String moduleName) {
-        final Set<Module> modules = schemaContext.getModules();
-
-        if ((prefix != null) && (moduleName != null) && (modules != null)) {
-            for (Module module : modules) {
-                if ((module != null) && prefix.equals(module.getPrefix())
-                        && moduleName.equals(module.getName())) {
-                    return module;
-                }
-            }
-        }
-        return null;
-    }
-
-    private Queue<String> resolveRelativeXPath(
-            final RevisionAwareXPath relativeXPath,
-            final SchemaPath leafrefSchemaPath) {
-        final Queue<String> absolutePath = new LinkedList<String>();
-
-        if ((relativeXPath != null) && !relativeXPath.isAbsolute()
-                && (leafrefSchemaPath != null)) {
-            final String strXPath = relativeXPath.toString();
-            if (strXPath != null) {
-                final String[] xpaths = strXPath.split("/");
-
-                if (xpaths != null) {
-                    int colCount = 0;
-                    while (xpaths[colCount].contains("..")) {
-                        ++colCount;
-                    }
-                    final List<QName> path = leafrefSchemaPath.getPath();
-                    if (path != null) {
-                        int lenght = path.size() - colCount;
-                        for (int i = 0; i < lenght; ++i) {
-                            absolutePath.add(path.get(i).getLocalName());
-                        }
-                        for (int i = colCount; i < xpaths.length; ++i) {
-                            absolutePath.add(xpaths[i]);
-                        }
-                    }
-                }
-            }
-        }
-        return absolutePath;
-    }
 }
index 425c23246d98a5e4e90ed708e8eeca6187d78860..bd7fcb9ce661fa2f0a648f9182df723579044e3a 100644 (file)
@@ -17,6 +17,7 @@ import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.controller.sal.binding.generator.impl.BindingGeneratorImpl;
+import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
@@ -37,6 +38,47 @@ public class GeneratedTypesTest {
         return parser.resolveSchemaContext(modules);
     }
 
+    @Test
+    public void testLeafEnumResolving() {
+        final String ietfInterfacesPath = getClass().getResource(
+                "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();
+        final String ifTypePath = getClass().getResource(
+                "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();
+        final String yangTypesPath = getClass().getResource(
+                "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(
+                ietfInterfacesPath, ifTypePath, yangTypesPath);
+        assertTrue(context != null);
+        
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertTrue(genTypes != null);
+    }
+
+    @Test
+    public void testTypedefEnumResolving() {
+        final String ianaIfTypePath = getClass().getResource(
+                "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
+        assertTrue(context != null);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+        assertTrue(genTypes != null);
+        assertEquals(1, genTypes.size());
+
+        final Type type = genTypes.get(0);
+        assertTrue(type instanceof GeneratedType);
+
+        final GeneratedType genType = (GeneratedType) type;
+        assertEquals(1, genType.getEnumDefintions().size());
+
+        final Enumeration enumer = genType.getEnumDefintions().get(0);
+        assertEquals(272, enumer.getValues().size());
+    }
+
     @Test
     public void testMultipleModulesResolving() {
         final String topologyPath = getClass().getResource(
@@ -51,7 +93,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(11, genTypes.size());
+        assertEquals(13, genTypes.size());
     }
 
     @Test
@@ -88,9 +130,9 @@ public class GeneratedTypesTest {
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertEquals(21, genTypes.size());
+        assertEquals(25, genTypes.size());
         assertTrue(genTypes != null);
-        
+
         int resolvedLeafrefCount = 0;
         for (final Type type : genTypes) {
             if (type.getName().equals("InterfaceKey")
@@ -98,7 +140,7 @@ public class GeneratedTypesTest {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
                 final List<GeneratedProperty> properties = genTO
                         .getProperties();
-                
+
                 assertTrue(properties != null);
                 for (final GeneratedProperty property : properties) {
                     if (property.getName().equals("InterfaceId")) {
@@ -217,7 +259,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(2, genTypes.size());
+        assertEquals(3, genTypes.size());
 
         final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
         final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
@@ -295,7 +337,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(2, genTypes.size());
+        assertEquals(3, genTypes.size());
 
         final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
         final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
@@ -368,7 +410,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(4, genTypes.size());
+        assertEquals(5, genTypes.size());
 
         int genTypesCount = 0;
         int genTOsCount = 0;
@@ -451,7 +493,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(6, genTypes.size());
+        assertEquals(7, genTypes.size());
 
         int genTypesCount = 0;
         int genTOsCount = 0;
@@ -483,7 +525,7 @@ public class GeneratedTypesTest {
             }
         }
 
-        assertEquals(4, genTypesCount);
+        assertEquals(5, genTypesCount);
         assertEquals(2, genTOsCount);
     }
 
@@ -498,7 +540,7 @@ public class GeneratedTypesTest {
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(13, genTypes.size());
+        assertEquals(14, genTypes.size());
 
         int genTypesCount = 0;
         int genTOsCount = 0;
@@ -510,7 +552,7 @@ public class GeneratedTypesTest {
             }
         }
 
-        assertEquals(10, genTypesCount);
+        assertEquals(11, genTypesCount);
         assertEquals(3, genTOsCount);
     }
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/iana-if-type@2012-06-05.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/iana-if-type@2012-06-05.yang
new file mode 100644 (file)
index 0000000..a7fa137
--- /dev/null
@@ -0,0 +1,1516 @@
+module iana-if-type {
+  namespace "urn:ietf:params:xml:ns:yang:iana-if-type";
+  prefix ianaift;
+
+  organization "IANA";
+  contact
+    "        Internet Assigned Numbers Authority
+
+     Postal: ICANN
+             4676 Admiralty Way, Suite 330
+             Marina del Rey, CA 90292
+
+     Tel:    +1 310 823 9358
+     E-Mail: iana&iana.org";
+  description
+    "This YANG module defines the iana-if-type typedef, which
+     contains YANG definitions for IANA-registered interface types.
+
+     This YANG module is maintained by IANA, and reflects the
+     'ifType definitions' registry.
+
+     The latest revision of this YANG module can be obtained from
+     the IANA web site.
+
+     Copyright (c) 2011 IETF Trust and the persons identified as
+     authors of the code.  All rights reserved.
+
+     Redistribution and use in source and binary forms, with or
+     without modification, is permitted pursuant to, and subject
+     to the license terms contained in, the Simplified BSD License
+     set forth in Section 4.c of the IETF Trust's Legal Provisions
+     Relating to IETF Documents
+     (http://trustee.ietf.org/license-info).
+
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2012-06-05 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: TITLE";
+  }
+
+  typedef iana-if-type {
+    type enumeration {
+      enum "other" {
+        value 1;
+        description
+          "None of the following";
+      }
+      enum "regular1822" {
+        value 2;
+      }
+      enum "hdh1822" {
+        value 3;
+      }
+      enum "ddnX25" {
+        value 4;
+      }
+      enum "rfc877x25" {
+        value 5;
+        reference
+          "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer";
+      }
+      enum "ethernetCsmacd" {
+        value 6;
+        description
+          "For all ethernet-like interfaces, regardless of speed,
+           as per RFC3635.";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "iso88023Csmacd" {
+        value 7;
+        status deprecated;
+        description
+          "Deprecated via RFC3635.
+           Use ethernetCsmacd(6) instead.";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "iso88024TokenBus" {
+        value 8;
+      }
+      enum "iso88025TokenRing" {
+        value 9;
+      }
+      enum "iso88026Man" {
+        value 10;
+      }
+      enum "starLan" {
+        value 11;
+        status deprecated;
+        description
+          "Deprecated via RFC3635.
+           Use ethernetCsmacd(6) instead.";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "proteon10Mbit" {
+        value 12;
+      }
+      enum "proteon80Mbit" {
+        value 13;
+      }
+      enum "hyperchannel" {
+        value 14;
+      }
+      enum "fddi" {
+        value 15;
+        reference
+          "RFC 1512 - FDDI Management Information Base";
+      }
+      enum "lapb" {
+        value 16;
+        reference
+          "RFC 1381 - SNMP MIB Extension for X.25 LAPB";
+      }
+      enum "sdlc" {
+        value 17;
+      }
+      enum "ds1" {
+        value 18;
+        description
+          "DS1-MIB";
+        reference
+          "RFC 4805 - Definitions of Managed Objects for the
+                      DS1, J1, E1, DS2, and E2 Interface Types";
+      }
+      enum "e1" {
+        value 19;
+        status obsolete;
+        description
+          "Obsolete see DS1-MIB";
+        reference
+          "RFC 4805 - Definitions of Managed Objects for the
+                      DS1, J1, E1, DS2, and E2 Interface Types";
+      }
+      enum "basicISDN" {
+        value 20;
+        description
+          "see also RFC2127";
+      }
+      enum "primaryISDN" {
+        value 21;
+      }
+      enum "propPointToPointSerial" {
+        value 22;
+        description
+          "proprietary serial";
+      }
+      enum "ppp" {
+        value 23;
+      }
+      enum "softwareLoopback" {
+        value 24;
+      }
+      enum "eon" {
+        value 25;
+        description
+          "CLNP over IP";
+      }
+      enum "ethernet3Mbit" {
+        value 26;
+      }
+      enum "nsip" {
+        value 27;
+        description
+          "XNS over IP";
+      }
+      enum "slip" {
+        value 28;
+        description
+          "generic SLIP";
+      }
+      enum "ultra" {
+        value 29;
+        description
+          "ULTRA technologies";
+      }
+      enum "ds3" {
+        value 30;
+        description
+          "DS3-MIB";
+        reference
+          "RFC 3896 - Definitions of Managed Objects for the
+                      DS3/E3 Interface Type";
+      }
+      enum "sip" {
+        value 31;
+        description
+          "SMDS, coffee";
+        reference
+          "RFC 1694 - Definitions of Managed Objects for SMDS
+                      Interfaces using SMIv2";
+      }
+      enum "frameRelay" {
+        value 32;
+        description
+          "DTE only.";
+        reference
+          "RFC 2115 - Management Information Base for Frame Relay
+                      DTEs Using SMIv2";
+      }
+      enum "rs232" {
+        value 33;
+        reference
+          "RFC 1659 - Definitions of Managed Objects for RS-232-like
+                      Hardware Devices using SMIv2";
+      }
+      enum "para" {
+        value 34;
+        description
+          "parallel-port";
+        reference
+          "RFC 1660 - Definitions of Managed Objects for
+                      Parallel-printer-like Hardware Devices using
+                      SMIv2";
+      }
+      enum "arcnet" {
+        value 35;
+        description
+          "arcnet";
+      }
+      enum "arcnetPlus" {
+        value 36;
+        description
+          "arcnet plus";
+      }
+      enum "atm" {
+        value 37;
+        description
+          "ATM cells";
+      }
+      enum "miox25" {
+        value 38;
+        reference
+          "RFC 1461 - SNMP MIB extension for Multiprotocol
+                      Interconnect over X.25";
+      }
+      enum "sonet" {
+        value 39;
+        description
+          "SONET or SDH";
+      }
+      enum "x25ple" {
+        value 40;
+        reference
+          "RFC 2127 - ISDN Management Information Base using SMIv2";
+      }
+      enum "iso88022llc" {
+        value 41;
+      }
+      enum "localTalk" {
+        value 42;
+      }
+      enum "smdsDxi" {
+        value 43;
+      }
+      enum "frameRelayService" {
+        value 44;
+        description
+          "FRNETSERV-MIB";
+        reference
+          "RFC 2954 - Definitions of Managed Objects for Frame
+                      Relay Service";
+      }
+      enum "v35" {
+        value 45;
+      }
+      enum "hssi" {
+        value 46;
+      }
+      enum "hippi" {
+        value 47;
+      }
+      enum "modem" {
+        value 48;
+        description
+          "Generic modem";
+      }
+      enum "aal5" {
+        value 49;
+        description
+          "AAL5 over ATM";
+      }
+      enum "sonetPath" {
+        value 50;
+      }
+      enum "sonetVT" {
+        value 51;
+      }
+      enum "smdsIcip" {
+        value 52;
+        description
+          "SMDS InterCarrier Interface";
+      }
+      enum "propVirtual" {
+        value 53;
+        description
+          "proprietary virtual/internal";
+        reference
+          "RFC 2863 - The Interfaces Group MIB";
+      }
+      enum "propMultiplexor" {
+        value 54;
+        description
+          "proprietary multiplexing";
+        reference
+          "RFC 2863 - The Interfaces Group MIB";
+      }
+      enum "ieee80212" {
+        value 55;
+        description
+          "100BaseVG";
+      }
+      enum "fibreChannel" {
+        value 56;
+        description
+          "Fibre Channel";
+      }
+      enum "hippiInterface" {
+        value 57;
+        description
+          "HIPPI interfaces";
+      }
+      enum "frameRelayInterconnect" {
+        value 58;
+        status obsolete;
+        description
+          "Obsolete use either
+           frameRelay(32) or frameRelayService(44).";
+      }
+      enum "aflane8023" {
+        value 59;
+        description
+          "ATM Emulated LAN for 802.3";
+      }
+      enum "aflane8025" {
+        value 60;
+        description
+          "ATM Emulated LAN for 802.5";
+      }
+      enum "cctEmul" {
+        value 61;
+        description
+         "ATM Emulated circuit";
+      }
+      enum "fastEther" {
+        value 62;
+        status deprecated;
+        description
+          "Obsoleted via RFC3635.
+          ethernetCsmacd(6) should be used instead";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "isdn" {
+        value 63;
+        description
+          "ISDN and X.25";
+        reference
+          "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN
+                      in the Packet Mode";
+      }
+      enum "v11" {
+        value 64;
+        description
+         "CCITT V.11/X.21";
+      }
+      enum "v36" {
+        value 65;
+        description
+          "CCITT V.36";
+      }
+      enum "g703at64k" {
+        value 66;
+        description
+          "CCITT G703 at 64Kbps";
+      }
+      enum "g703at2mb" {
+        value 67;
+        status obsolete;
+        description
+          "Obsolete see DS1-MIB";
+      }
+      enum "qllc" {
+        value 68;
+        description
+          "SNA QLLC";
+      }
+      enum "fastEtherFX" {
+        value 69;
+        status deprecated;
+        description
+          "Obsoleted via RFC3635
+          ethernetCsmacd(6) should be used instead";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "channel" {
+        value 70;
+        description
+          "channel";
+      }
+      enum "ieee80211" {
+        value 71;
+        description
+          "radio spread spectrum";
+      }
+      enum "ibm370parChan" {
+        value 72;
+        description
+          "IBM System 360/370 OEMI Channel";
+      }
+      enum "escon" {
+        value 73;
+        description
+          "IBM Enterprise Systems Connection";
+      }
+      enum "dlsw" {
+        value 74;
+        description
+          "Data Link Switching";
+      }
+      enum "isdns" {
+        value 75;
+        description
+          "ISDN S/T interface";
+      }
+      enum "isdnu" {
+        value 76;
+        description
+          "ISDN U interface";
+      }
+      enum "lapd" {
+        value 77;
+        description
+          "Link Access Protocol D";
+      }
+      enum "ipSwitch" {
+        value 78;
+        description
+          "IP Switching Objects";
+      }
+      enum "rsrb" {
+        value 79;
+        description
+          "Remote Source Route Bridging";
+      }
+      enum "atmLogical" {
+        value 80;
+        description
+          "ATM Logical Port";
+        reference
+          "RFC 3606 - Definitions of Supplemental Managed Objects
+                      for ATM Interface";
+      }
+      enum "ds0" {
+        value 81;
+        description
+          "Digital Signal Level 0";
+        reference
+          "RFC 2494 - Definitions of Managed Objects for the DS0
+                      and DS0 Bundle Interface Type";
+      }
+      enum "ds0Bundle" {
+        value 82;
+        description
+          "group of ds0s on the same ds1";
+        reference
+          "RFC 2494 - Definitions of Managed Objects for the DS0
+                      and DS0 Bundle Interface Type";
+      }
+      enum "bsc" {
+        value 83;
+        description
+          "Bisynchronous Protocol";
+      }
+      enum "async" {
+        value 84;
+        description
+          "Asynchronous Protocol";
+      }
+      enum "cnr" {
+        value 85;
+        description
+          "Combat Net Radio";
+      }
+      enum "iso88025Dtr" {
+        value 86;
+        description
+          "ISO 802.5r DTR";
+      }
+      enum "eplrs" {
+        value 87;
+        description
+          "Ext Pos Loc Report Sys";
+      }
+      enum "arap" {
+        value 88;
+        description
+          "Appletalk Remote Access Protocol";
+      }
+      enum "propCnls" {
+        value 89;
+        description
+          "Proprietary Connectionless Protocol";
+      }
+      enum "hostPad" {
+        value 90;
+        description
+          "CCITT-ITU X.29 PAD Protocol";
+      }
+      enum "termPad" {
+        value 91;
+        description
+          "CCITT-ITU X.3 PAD Facility";
+      }
+      enum "frameRelayMPI" {
+        value 92;
+        description
+          "Multiproto Interconnect over FR";
+      }
+      enum "x213" {
+        value 93;
+        description
+          "CCITT-ITU X213";
+      }
+      enum "adsl" {
+        value 94;
+        description
+          "Asymmetric Digital Subscriber Loop";
+      }
+      enum "radsl" {
+        value 95;
+        description
+          "Rate-Adapt. Digital Subscriber Loop";
+      }
+      enum "sdsl" {
+        value 96;
+        description
+          "Symmetric Digital Subscriber Loop";
+      }
+      enum "vdsl" {
+        value 97;
+        description
+          "Very H-Speed Digital Subscrib. Loop";
+      }
+      enum "iso88025CRFPInt" {
+        value 98;
+        description
+          "ISO 802.5 CRFP";
+      }
+      enum "myrinet" {
+        value 99;
+        description
+          "Myricom Myrinet";
+      }
+      enum "voiceEM" {
+        value 100;
+        description
+          "voice recEive and transMit";
+      }
+      enum "voiceFXO" {
+        value 101;
+        description
+          "voice Foreign Exchange Office";
+      }
+      enum "voiceFXS" {
+        value 102;
+        description
+          "voice Foreign Exchange Station";
+      }
+      enum "voiceEncap" {
+        value 103;
+        description
+          "voice encapsulation";
+      }
+      enum "voiceOverIp" {
+        value 104;
+        description
+          "voice over IP encapsulation";
+      }
+      enum "atmDxi" {
+        value 105;
+        description
+          "ATM DXI";
+      }
+      enum "atmFuni" {
+        value 106;
+        description
+          "ATM FUNI";
+      }
+      enum "atmIma" {
+        value 107;
+        description
+          "ATM IMA";
+      }
+      enum "pppMultilinkBundle" {
+        value 108;
+        description
+          "PPP Multilink Bundle";
+      }
+      enum "ipOverCdlc" {
+        value 109;
+        description
+          "IBM ipOverCdlc";
+      }
+      enum "ipOverClaw" {
+        value 110;
+        description
+          "IBM Common Link Access to Workstn";
+      }
+      enum "stackToStack" {
+        value 111;
+        description
+          "IBM stackToStack";
+      }
+      enum "virtualIpAddress" {
+        value 112;
+        description
+          "IBM VIPA";
+      }
+      enum "mpc" {
+        value 113;
+        description
+          "IBM multi-protocol channel support";
+      }
+      enum "ipOverAtm" {
+        value 114;
+        description
+          "IBM ipOverAtm";
+        reference
+          "RFC 2320 - Definitions of Managed Objects for Classical IP
+                      and ARP Over ATM Using SMIv2 (IPOA-MIB)";
+      }
+      enum "iso88025Fiber" {
+        value 115;
+        description
+          "ISO 802.5j Fiber Token Ring";
+      }
+      enum "tdlc" {
+        value 116;
+        description
+          "IBM twinaxial data link control";
+      }
+      enum "gigabitEthernet" {
+        value 117;
+        status deprecated;
+        description
+          "Obsoleted via RFC3635
+           ethernetCsmacd(6) should be used instead";
+        reference
+          "RFC 3635 - Definitions of Managed Objects for the
+                      Ethernet-like Interface Types.";
+      }
+      enum "hdlc" {
+        value 118;
+        description
+          "HDLC";
+      }
+      enum "lapf" {
+        value 119;
+        description
+          "LAP F";
+      }
+      enum "v37" {
+        value 120;
+        description
+          "V.37";
+      }
+      enum "x25mlp" {
+        value 121;
+        description
+          "Multi-Link Protocol";
+      }
+      enum "x25huntGroup" {
+        value 122;
+        description
+          "X25 Hunt Group";
+      }
+      enum "transpHdlc" {
+        value 123;
+        description
+          "Transp HDLC";
+      }
+      enum "interleave" {
+        value 124;
+        description
+          "Interleave channel";
+      }
+      enum "fast" {
+        value 125;
+        description
+          "Fast channel";
+      }
+      enum "ip" {
+        value 126;
+        description
+          "IP (for APPN HPR in IP networks)";
+      }
+      enum "docsCableMaclayer" {
+        value 127;
+        description
+          "CATV Mac Layer";
+      }
+      enum "docsCableDownstream" {
+        value 128;
+        description
+          "CATV Downstream interface";
+      }
+      enum "docsCableUpstream" {
+        value 129;
+        description
+          "CATV Upstream interface";
+      }
+      enum "a12MppSwitch" {
+        value 130;
+        description
+          "Avalon Parallel Processor";
+      }
+      enum "tunnel" {
+        value 131;
+        description
+          "Encapsulation interface";
+      }
+      enum "coffee" {
+        value 132;
+        description
+          "coffee pot";
+        reference
+          "RFC 2325 - Coffee MIB";
+      }
+      enum "ces" {
+        value 133;
+        description
+          "Circuit Emulation Service";
+      }
+      enum "atmSubInterface" {
+        value 134;
+        description
+          "ATM Sub Interface";
+      }
+      enum "l2vlan" {
+        value 135;
+        description
+          "Layer 2 Virtual LAN using 802.1Q";
+      }
+      enum "l3ipvlan" {
+        value 136;
+        description
+          "Layer 3 Virtual LAN using IP";
+      }
+      enum "l3ipxvlan" {
+        value 137;
+        description
+          "Layer 3 Virtual LAN using IPX";
+      }
+      enum "digitalPowerline" {
+        value 138;
+        description
+          "IP over Power Lines";
+      }
+      enum "mediaMailOverIp" {
+        value 139;
+        description
+          "Multimedia Mail over IP";
+      }
+      enum "dtm" {
+        value 140;
+        description
+          "Dynamic syncronous Transfer Mode";
+      }
+      enum "dcn" {
+        value 141;
+        description
+          "Data Communications Network";
+      }
+      enum "ipForward" {
+        value 142;
+        description
+          "IP Forwarding Interface";
+      }
+      enum "msdsl" {
+        value 143;
+        description
+          "Multi-rate Symmetric DSL";
+      }
+      enum "ieee1394" {
+        value 144;
+        description
+          "IEEE1394 High Performance Serial Bus";
+      }
+      enum "if-gsn" {
+        value 145;
+        description
+          "HIPPI-6400";
+      }
+      enum "dvbRccMacLayer" {
+        value 146;
+        description
+          "DVB-RCC MAC Layer";
+      }
+      enum "dvbRccDownstream" {
+        value 147;
+        description
+          "DVB-RCC Downstream Channel";
+      }
+      enum "dvbRccUpstream" {
+        value 148;
+        description
+          "DVB-RCC Upstream Channel";
+      }
+      enum "atmVirtual" {
+        value 149;
+        description
+          "ATM Virtual Interface";
+      }
+      enum "mplsTunnel" {
+        value 150;
+        description
+          "MPLS Tunnel Virtual Interface";
+      }
+      enum "srp" {
+        value 151;
+        description
+          "Spatial Reuse Protocol       ";
+      }
+      enum "voiceOverAtm" {
+        value 152;
+        description
+          "Voice Over ATM";
+      }
+      enum "voiceOverFrameRelay" {
+        value 153;
+        description
+          "Voice Over Frame Relay";
+      }
+      enum "idsl" {
+        value 154;
+        description
+          "Digital Subscriber Loop over ISDN";
+      }
+      enum "compositeLink" {
+        value 155;
+        description
+          "Avici Composite Link Interface";
+      }
+      enum "ss7SigLink" {
+        value 156;
+        description
+          "SS7 Signaling Link";
+      }
+      enum "propWirelessP2P" {
+        value 157;
+        description
+          "Prop. P2P wireless interface";
+      }
+      enum "frForward" {
+        value 158;
+        description
+          "Frame Forward Interface";
+      }
+      enum "rfc1483" {
+        value 159;
+        description
+          "Multiprotocol over ATM AAL5";
+        reference
+          "RFC 1483 - Multiprotocol Encapsulation over ATM
+                      Adaptation Layer 5";
+      }
+      enum "usb" {
+        value 160;
+        description
+          "USB Interface";
+      }
+      enum "ieee8023adLag" {
+        value 161;
+        description
+          "IEEE 802.3ad Link Aggregate";
+      }
+      enum "bgppolicyaccounting" {
+        value 162;
+        description
+          "BGP Policy Accounting";
+      }
+      enum "frf16MfrBundle" {
+        value 163;
+        description
+          "FRF .16 Multilink Frame Relay";
+      }
+      enum "h323Gatekeeper" {
+        value 164;
+        description
+          "H323 Gatekeeper";
+      }
+      enum "h323Proxy" {
+        value 165;
+        description
+          "H323 Voice and Video Proxy";
+      }
+      enum "mpls" {
+        value 166;
+        description
+          "MPLS";
+      }
+      enum "mfSigLink" {
+        value 167;
+        description
+          "Multi-frequency signaling link";
+      }
+      enum "hdsl2" {
+        value 168;
+        description
+          "High Bit-Rate DSL - 2nd generation";
+      }
+      enum "shdsl" {
+        value 169;
+        description
+          "Multirate HDSL2";
+      }
+      enum "ds1FDL" {
+        value 170;
+        description
+          "Facility Data Link 4Kbps on a DS1";
+      }
+      enum "pos" {
+        value 171;
+        description
+          "Packet over SONET/SDH Interface";
+      }
+      enum "dvbAsiIn" {
+        value 172;
+        description
+          "DVB-ASI Input";
+      }
+      enum "dvbAsiOut" {
+        value 173;
+        description
+          "DVB-ASI Output";
+      }
+      enum "plc" {
+        value 174;
+        description
+          "Power Line Communtications";
+      }
+      enum "nfas" {
+        value 175;
+        description
+          "Non Facility Associated Signaling";
+      }
+      enum "tr008" {
+        value 176;
+        description
+          "TR008";
+      }
+      enum "gr303RDT" {
+        value 177;
+        description
+          "Remote Digital Terminal";
+      }
+      enum "gr303IDT" {
+        value 178;
+        description
+          "Integrated Digital Terminal";
+      }
+      enum "isup" {
+        value 179;
+        description
+          "ISUP";
+      }
+      enum "propDocsWirelessMaclayer" {
+        value 180;
+        description
+          "Cisco proprietary Maclayer";
+      }
+      enum "propDocsWirelessDownstream" {
+        value 181;
+        description
+          "Cisco proprietary Downstream";
+      }
+      enum "propDocsWirelessUpstream" {
+        value 182;
+        description
+          "Cisco proprietary Upstream";
+      }
+      enum "hiperlan2" {
+        value 183;
+        description
+          "HIPERLAN Type 2 Radio Interface";
+      }
+      enum "propBWAp2Mp" {
+        value 184;
+        description
+          "PropBroadbandWirelessAccesspt2multipt use of this value
+           for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f
+           is deprecated and ieee80216WMAN(237) should be used
+           instead.";
+      }
+      enum "sonetOverheadChannel" {
+        value 185;
+        description
+          "SONET Overhead Channel";
+      }
+      enum "digitalWrapperOverheadChannel" {
+        value 186;
+        description
+          "Digital Wrapper";
+      }
+      enum "aal2" {
+        value 187;
+        description
+          "ATM adaptation layer 2";
+      }
+      enum "radioMAC" {
+        value 188;
+        description
+          "MAC layer over radio links";
+      }
+      enum "atmRadio" {
+        value 189;
+        description
+          "ATM over radio links";
+      }
+      enum "imt" {
+        value 190;
+        description
+          "Inter Machine Trunks";
+      }
+      enum "mvl" {
+        value 191;
+        description
+          "Multiple Virtual Lines DSL";
+      }
+      enum "reachDSL" {
+        value 192;
+        description
+          "Long Reach DSL";
+      }
+      enum "frDlciEndPt" {
+        value 193;
+        description
+          "Frame Relay DLCI End Point";
+      }
+      enum "atmVciEndPt" {
+        value 194;
+        description
+          "ATM VCI End Point";
+      }
+      enum "opticalChannel" {
+        value 195;
+        description
+          "Optical Channel";
+      }
+      enum "opticalTransport" {
+        value 196;
+        description
+          "Optical Transport";
+      }
+      enum "propAtm" {
+        value 197;
+        description
+          "Proprietary ATM";
+      }
+      enum "voiceOverCable" {
+        value 198;
+        description
+          "Voice Over Cable Interface";
+      }
+      enum "infiniband" {
+        value 199;
+        description
+          "Infiniband";
+      }
+      enum "teLink" {
+        value 200;
+        description
+          "TE Link";
+      }
+      enum "q2931" {
+        value 201;
+        description
+          "Q.2931";
+      }
+      enum "virtualTg" {
+        value 202;
+        description
+          "Virtual Trunk Group";
+      }
+      enum "sipTg" {
+        value 203;
+        description
+          "SIP Trunk Group";
+      }
+      enum "sipSig" {
+        value 204;
+        description
+          "SIP Signaling";
+      }
+      enum "docsCableUpstreamChannel" {
+        value 205;
+        description
+          "CATV Upstream Channel";
+      }
+      enum "econet" {
+        value 206;
+        description
+          "Acorn Econet";
+      }
+      enum "pon155" {
+        value 207;
+        description
+          "FSAN 155Mb Symetrical PON interface";
+      }
+      enum "pon622" {
+        value 208;
+        description
+          "FSAN622Mb Symetrical PON interface";
+      }
+      enum "bridge" {
+        value 209;
+        description
+          "Transparent bridge interface";
+      }
+      enum "linegroup" {
+        value 210;
+        description
+          "Interface common to multiple lines";
+      }
+      enum "voiceEMFGD" {
+        value 211;
+        description
+          "voice E&M Feature Group D";
+      }
+      enum "voiceFGDEANA" {
+        value 212;
+        description
+          "voice FGD Exchange Access North American";
+      }
+      enum "voiceDID" {
+        value 213;
+        description
+          "voice Direct Inward Dialing";
+      }
+      enum "mpegTransport" {
+        value 214;
+        description
+          "MPEG transport interface";
+      }
+      enum "sixToFour" {
+        value 215;
+        status deprecated;
+        description
+          "6to4 interface (DEPRECATED)";
+        reference
+          "RFC 4087 - IP Tunnel MIB";
+      }
+      enum "gtp" {
+        value 216;
+        description
+          "GTP (GPRS Tunneling Protocol)";
+      }
+      enum "pdnEtherLoop1" {
+        value 217;
+        description
+          "Paradyne EtherLoop 1";
+      }
+      enum "pdnEtherLoop2" {
+        value 218;
+        description
+          "Paradyne EtherLoop 2";
+      }
+      enum "opticalChannelGroup" {
+        value 219;
+        description
+          "Optical Channel Group";
+      }
+      enum "homepna" {
+        value 220;
+        description
+          "HomePNA ITU-T G.989";
+      }
+      enum "gfp" {
+        value 221;
+        description
+          "Generic Framing Procedure (GFP)";
+      }
+      enum "ciscoISLvlan" {
+        value 222;
+        description
+          "Layer 2 Virtual LAN using Cisco ISL";
+      }
+      enum "actelisMetaLOOP" {
+        value 223;
+        description
+          "Acteleis proprietary MetaLOOP High Speed Link";
+      }
+      enum "fcipLink" {
+        value 224;
+        description
+          "FCIP Link";
+      }
+      enum "rpr" {
+        value 225;
+        description
+          "Resilient Packet Ring Interface Type";
+      }
+      enum "qam" {
+        value 226;
+        description
+          "RF Qam Interface";
+      }
+      enum "lmp" {
+        value 227;
+        description
+          "Link Management Protocol";
+        reference
+          "RFC 4327 - Link Management Protocol (LMP) Management
+                      Information Base (MIB)";
+      }
+      enum "cblVectaStar" {
+        value 228;
+        description
+          "Cambridge Broadband Networks Limited VectaStar";
+      }
+      enum "docsCableMCmtsDownstream" {
+        value 229;
+        description
+          "CATV Modular CMTS Downstream Interface";
+      }
+      enum "adsl2" {
+        value 230;
+        status deprecated;
+        description
+          "Asymmetric Digital Subscriber Loop Version 2
+           (DEPRECATED/OBSOLETED - please use adsl2plus(238)
+           instead)";
+        reference
+          "RFC 4706 - Definitions of Managed Objects for Asymmetric
+                      Digital Subscriber Line 2 (ADSL2)";
+      }
+      enum "macSecControlledIF" {
+        value 231;
+        description
+          "MACSecControlled";
+      }
+      enum "macSecUncontrolledIF" {
+        value 232;
+        description
+          "MACSecUncontrolled";
+      }
+      enum "aviciOpticalEther" {
+        value 233;
+        description
+         "Avici Optical Ethernet Aggregate";
+      }
+      enum "atmbond" {
+        value 234;
+        description
+          "atmbond";
+      }
+      enum "voiceFGDOS" {
+        value 235;
+        description
+          "voice FGD Operator Services";
+      }
+      enum "mocaVersion1" {
+        value 236;
+        description
+          "MultiMedia over Coax Alliance (MoCA) Interface
+           as documented in information provided privately to IANA";
+      }
+      enum "ieee80216WMAN" {
+        value 237;
+        description
+          "IEEE 802.16 WMAN interface";
+      }
+      enum "adsl2plus" {
+        value 238;
+        description
+          "Asymmetric Digital Subscriber Loop Version 2,
+           Version 2 Plus and all variants";
+      }
+      enum "dvbRcsMacLayer" {
+        value 239;
+        description
+          "DVB-RCS MAC Layer";
+        reference
+          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
+      }
+      enum "dvbTdm" {
+        value 240;
+        description
+          "DVB Satellite TDM";
+        reference
+          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
+      }
+      enum "dvbRcsTdma" {
+        value 241;
+        description
+          "DVB-RCS TDMA";
+        reference
+          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
+      }
+      enum "x86Laps" {
+        value 242;
+        description
+          "LAPS based on ITU-T X.86/Y.1323";
+      }
+      enum "wwanPP" {
+        value 243;
+        description
+          "3GPP WWAN";
+      }
+      enum "wwanPP2" {
+        value 244;
+        description
+          "3GPP2 WWAN";
+      }
+      enum "voiceEBS" {
+        value 245;
+        description
+          "voice P-phone EBS physical interface";
+      }
+      enum "ifPwType" {
+        value 246;
+        description
+          "Pseudowire interface type";
+        reference
+          "RFC 5601 - Pseudowire (PW) Management Information Base";
+      }
+      enum "ilan" {
+        value 247;
+        description
+          "Internal LAN on a bridge per IEEE 802.1ap";
+      }
+      enum "pip" {
+        value 248;
+        description
+          "Provider Instance Port on a bridge per IEEE 802.1ah PBB";
+      }
+      enum "aluELP" {
+        value 249;
+        description
+          "Alcatel-Lucent Ethernet Link Protection";
+      }
+      enum "gpon" {
+        value 250;
+        description
+          "Gigabit-capable passive optical networks (G-PON) as per
+           ITU-T G.948";
+      }
+      enum "vdsl2" {
+        value 251;
+        description
+          "Very high speed digital subscriber line Version 2
+           (as per ITU-T Recommendation G.993.2)";
+        reference
+          "RFC 5650 - Definitions of Managed Objects for Very High
+                      Speed Digital Subscriber Line 2 (VDSL2)";
+      }
+      enum "capwapDot11Profile" {
+        value 252;
+        description
+          "WLAN Profile Interface";
+        reference
+          "RFC 5834 - Control and Provisioning of Wireless Access
+                      Points (CAPWAP) Protocol Binding MIB for
+                      IEEE 802.11";
+      }
+      enum "capwapDot11Bss" {
+        value 253;
+        description
+          "WLAN BSS Interface";
+        reference
+          "RFC 5834 - Control and Provisioning of Wireless Access
+                      Points (CAPWAP) Protocol Binding MIB for
+                      IEEE 802.11";
+      }
+      enum "capwapWtpVirtualRadio" {
+        value 254;
+        description
+          "WTP Virtual Radio Interface";
+        reference
+          "RFC 5833 - Control and Provisioning of Wireless Access
+                      Points (CAPWAP) Protocol Base MIB";
+      }
+      enum "bits" {
+        value 255;
+        description
+          "bitsport";
+      }
+      enum "docsCableUpstreamRfPort" {
+        value 256;
+        description
+          "DOCSIS CATV Upstream RF Port";
+      }
+      enum "cableDownstreamRfPort" {
+        value 257;
+        description
+          "CATV downstream RF port";
+      }
+      enum "vmwareVirtualNic" {
+        value 258;
+        description
+          "VMware Virtual Network Interface";
+      }
+      enum "ieee802154" {
+        value 259;
+        description
+          "IEEE 802.15.4 WPAN interface";
+        reference
+          "IEEE 802.15.4-2006";
+      }
+      enum "otnOdu" {
+        value 260;
+        description
+          "OTN Optical Data Unit";
+      }
+      enum "otnOtu" {
+        value 261;
+        description
+          "OTN Optical channel Transport Unit";
+      }
+      enum "ifVfiType" {
+        value 262;
+        description
+          "VPLS Forwarding Instance Interface Type";
+      }
+      enum "g9981" {
+        value 263;
+        description
+          "G.998.1 bonded interface";
+      }
+      enum "g9982" {
+        value 264;
+        description
+          "G.998.2 bonded interface";
+      }
+      enum "g9983" {
+        value 265;
+        description
+          "G.998.3 bonded interface";
+      }
+      enum "aluEpon" {
+        value 266;
+        description
+          "Ethernet Passive Optical Networks (E-PON)";
+      }
+      enum "aluEponOnu" {
+        value 267;
+        description
+          "EPON Optical Network Unit";
+      }
+      enum "aluEponPhysicalUni" {
+        value 268;
+        description
+          "EPON physical User to Network interface";
+      }
+      enum "aluEponLogicalLink" {
+        value 269;
+        description
+          "The emulation of a point-to-point link over the EPON
+           layer";
+      }
+      enum "aluGponOnu" {
+        value 270;
+        description
+          "GPON Optical Network Unit";
+        reference
+          "ITU-T G.984.2";
+      }
+      enum "aluGponPhysicalUni" {
+        value 271;
+        description
+          "GPON physical User to Network interface";
+        reference
+          "ITU-T G.984.2";
+      }
+      enum "vmwareNicTeam" {
+        value 272;
+        description
+          "VMware NIC Team";
+      }
+    }
+    description
+      "This data type is used as the syntax of the 'type'
+       leaf in the 'interface' list in the YANG module
+       ietf-interface.
+
+       The definition of this typedef with the
+       addition of newly assigned values is published
+       periodically by the IANA, in either the Assigned
+       Numbers RFC, or some derivative of it specific to
+       Internet Network Management number assignments.  (The
+       latest arrangements can be obtained by contacting the
+       IANA.)
+
+       Requests for new values should be made to IANA via
+       email (iana&iana.org).";
+    reference
+      "ifType definitions registry.
+       <http://www.iana.org/assignments/smi-numbers>";
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-interfaces@2012-11-15.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-interfaces@2012-11-15.yang
new file mode 100644 (file)
index 0000000..b9117d0
--- /dev/null
@@ -0,0 +1,565 @@
+module ietf-interfaces {
+
+  namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
+  prefix if;
+
+  import ietf-yang-types {
+    prefix yang;
+  }
+  import iana-if-type {
+    prefix ianaift;
+  }
+
+  organization
+    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+  contact
+    "WG Web:   <http://tools.ietf.org/wg/netmod/>
+     WG List:  <mailto:netmod@ietf.org>
+
+     WG Chair: David Kessens
+               <mailto:david.kessens@nsn.com>
+
+     WG Chair: Juergen Schoenwaelder
+               <mailto:j.schoenwaelder@jacobs-university.de>
+
+     Editor:   Martin Bjorklund
+               <mailto:mbj@tail-f.com>";
+
+  description
+    "This module contains a collection of YANG definitions for
+     managing network interfaces.
+
+     Copyright (c) 2012 IETF Trust and the persons identified as
+     authors of the code.  All rights reserved.
+
+     Redistribution and use in source and binary forms, with or
+     without modification, is permitted pursuant to, and subject
+     to the license terms contained in, the Simplified BSD License
+     set forth in Section 4.c of the IETF Trust's Legal Provisions
+     Relating to IETF Documents
+     (http://trustee.ietf.org/license-info).
+
+     This version of this YANG module is part of RFC XXXX; see
+     the RFC itself for full legal notices.";
+
+  // RFC Ed.: replace XXXX with actual RFC number and remove this
+  // note.
+
+  // RFC Ed.: update the date below with the date of RFC publication
+  // and remove this note.
+  revision 2012-11-15 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: A YANG Data Model for Interface Management";
+  }
+
+  /* Typedefs */
+
+  typedef interface-ref {
+    type leafref {
+      path "/if:interfaces/if:interface/if:name";
+    }
+    description
+      "This type is used by data models that need to reference
+       interfaces.";
+  }
+
+  /* Features */
+
+  feature arbitrary-names {
+    description
+      "This feature indicates that the server allows interfaces to
+       be named arbitrarily.";
+  }
+
+  feature if-mib {
+    description
+      "This feature indicates that the server implements IF-MIB.";
+    reference
+      "RFC 2863: The Interfaces Group MIB";
+  }
+
+  /* Data nodes */
+
+  container interfaces {
+    description
+      "Interface parameters.";
+
+    list interface {
+      key "name";
+      unique "type location";
+
+      description
+        "The list of interfaces on the device.";
+
+      leaf name {
+        type string;
+        description
+          "The name of the interface.
+
+           A device MAY restrict the allowed values for this leaf,
+           possibly depending on the type and location.
+
+           If the device allows arbitrarily named interfaces, the
+           feature 'arbitrary-names' is advertised.
+
+           This leaf MAY be mapped to ifName by an implementation.
+           Such an implementation MAY restrict the allowed values for
+           this leaf so that it matches the restrictions of ifName.
+           If a NETCONF server that implements this restriction is
+           sent a value that doesn't match the restriction, it MUST
+           reply with an rpc-error with the error-tag
+           'invalid-value'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifName";
+      }
+
+      leaf description {
+        type string;
+        description
+          "A textual description of the interface.
+
+           This leaf MAY be mapped to ifAlias by an implementation.
+           Such an implementation MAY restrict the allowed values for
+           this leaf so that it matches the restrictions of ifAlias.
+           If a NETCONF server that implements this restriction is
+           sent a value that doesn't match the restriction, it MUST
+           reply with an rpc-error with the error-tag
+           'invalid-value'.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifAlias";
+      }
+
+      leaf type {
+        type ianaift:iana-if-type;
+        mandatory true;
+        description
+          "The type of the interface.
+
+           When an interface entry is created, a server MAY
+           initialize the type leaf with a valid value, e.g., if it
+           is possible to derive the type from the name of the
+           interface.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifType";
+      }
+
+      leaf location {
+        type string;
+        description
+          "The device-specific location of the interface of a
+           particular type.  The format of the location string
+           depends on the interface type and the device.
+
+           If the interface's type represents a physical interface,
+           this leaf MUST be set.
+
+           When an interface entry is created, a server MAY
+           initialize the location leaf with a valid value, e.g., if
+           it is possible to derive the location from the name of
+           the interface.";
+      }
+
+      leaf enabled {
+        type boolean;
+        default "true";
+        description
+          "The desired state of the interface.
+
+           This leaf contains the configured, desired state of the
+           interface.  Systems that implement the IF-MIB use the
+           value of this leaf to set IF-MIB.ifAdminStatus to 'up' or
+           'down' after an ifEntry has been initialized, as described
+           in RFC 2863.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
+      }
+
+      leaf oper-status {
+        type enumeration {
+          enum up {
+            value 1;
+            description
+              "Ready to pass packets.";
+          }
+          enum down {
+            value 2;
+            description
+              "The interface does not pass any packets.";
+          }
+          enum testing {
+            value 3;
+            description
+              "In some test mode.  No operational packets can
+               be passed.";
+          }
+          enum unknown {
+            value 4;
+            description
+              "Status cannot be determined for some reason.";
+          }
+          enum dormant {
+            value 5;
+            description
+              "Waiting for some external event.";
+          }
+          enum not-present {
+            value 6;
+            description
+              "Some component is missing.";
+          }
+          enum lower-layer-down {
+            value 7;
+            description
+              "Down due to state of lower-layer interface(s).";
+          }
+        }
+        config false;
+        description
+          "The current operational state of the interface.
+
+           If 'enabled' is 'false' then 'oper-status'
+           should be 'down'.  If 'enabled' is changed to 'true'
+           then 'oper-status' should change to 'up' if the interface
+           is ready to transmit and receive network traffic; it
+           should change to 'dormant' if the interface is waiting for
+           external actions (such as a serial line waiting for an
+           incoming connection); it should remain in the 'down' state
+           if and only if there is a fault that prevents it from
+           going to the 'up' state; it should remain in the
+           'not-present' state if the interface has missing
+           (typically, hardware) components.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifOperStatus";
+      }
+
+      leaf last-change {
+        type yang:date-and-time;
+        config false;
+        description
+          "The time the interface entered its current operational
+           state.  If the current state was entered prior to the
+           last re-initialization of the local network management
+           subsystem, then this node is not present.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifLastChange";
+      }
+
+      leaf if-index {
+        if-feature if-mib;
+        type int32 {
+          range "1..2147483647";
+        }
+        config false;
+        description
+          "The ifIndex value for the ifEntry represented by this
+           interface.
+
+           Media-specific modules must specify how the type is
+           mapped to entries in the ifTable.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifIndex";
+      }
+
+      leaf link-up-down-trap-enable {
+        if-feature if-mib;
+        type enumeration {
+          enum enabled {
+            value 1;
+          }
+          enum disabled {
+            value 2;
+          }
+        }
+        description
+          "Indicates whether linkUp/linkDown SNMP notifications
+           should be generated for this interface.
+           If this node is not configured, the value 'enabled' is
+           operationally used by the server for interfaces which do
+           not operate on top of any other interface (i.e., there are
+           no 'lower-layer-if' entries), and 'disabled' otherwise.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifLinkUpDownTrapEnable";
+      }
+
+      leaf phys-address {
+        type yang:phys-address;
+        config false;
+        description
+          "The interface's address at its protocol sub-layer.  For
+          example, for an 802.x interface, this object normally
+          contains a MAC address.  The interface's media-specific
+          modules must define the bit and byte ordering and the
+          format of the value of this object.  For interfaces that do
+          not have such an address (e.g., a serial line), this node
+          is not present.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
+      }
+
+      leaf-list higher-layer-if {
+        type interface-ref;
+        config false;
+        description
+          "A list of references to interfaces layered on top of this
+           interface.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifStackTable";
+      }
+
+      leaf-list lower-layer-if {
+        type interface-ref;
+        config false;
+        description
+          "A list of references to interfaces layered underneath this
+           interface.";
+        reference
+          "RFC 2863: The Interfaces Group MIB - ifStackTable";
+      }
+
+      leaf speed {
+        type yang:gauge64;
+        units "bits / second";
+        config false;
+        description
+            "An estimate of the interface's current bandwidth in bits
+             per second.  For interfaces which do not vary in
+             bandwidth or for those where no accurate estimation can
+             be made, this node should contain the nominal bandwidth.
+             For interfaces that has no concept of bandwidth, this
+             node is not present.";
+        reference
+          "RFC 2863: The Interfaces Group MIB -
+                     ifSpeed, ifHighSpeed";
+      }
+
+      container statistics {
+        config false;
+        description
+          "A collection of interface-related statistics objects.";
+
+        leaf discontinuity-time {
+          type yang:date-and-time;
+          description
+            "The time on the most recent occasion at which any one or
+             more of this interface's counters suffered a
+             discontinuity.  If no such discontinuities have occurred
+             since the last re-initialization of the local management
+             subsystem, then this node contains the time the local
+             management subsystem re-initialized itself.";
+        }
+
+        leaf in-octets {
+          type yang:counter64;
+          description
+            "The total number of octets received on the interface,
+             including framing characters.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
+        }
+        leaf in-unicast-pkts {
+          type yang:counter64;
+          description
+            "The number of packets, delivered by this sub-layer to a
+             higher (sub-)layer, which were not addressed to a
+             multicast or broadcast address at this sub-layer.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
+        }
+        leaf in-broadcast-pkts {
+          type yang:counter64;
+          description
+            "The number of packets, delivered by this sub-layer to a
+             higher (sub-)layer, which were addressed to a broadcast
+             address at this sub-layer.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB -
+                       ifHCInBroadcastPkts";
+        }
+        leaf in-multicast-pkts {
+          type yang:counter64;
+          description
+            "The number of packets, delivered by this sub-layer to a
+             higher (sub-)layer, which were addressed to a multicast
+             address at this sub-layer.  For a MAC layer protocol,
+             this includes both Group and Functional addresses.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB -
+                       ifHCInMulticastPkts";
+        }
+        leaf in-discards {
+          type yang:counter32;
+          description
+            "The number of inbound packets which were chosen to be
+             discarded even though no errors had been detected to
+             prevent their being deliverable to a higher-layer
+             protocol.  One possible reason for discarding such a
+             packet could be to free up buffer space.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifInDiscards";
+        }
+        leaf in-errors {
+          type yang:counter32;
+          description
+            "For packet-oriented interfaces, the number of inbound
+             packets that contained errors preventing them from being
+             deliverable to a higher-layer protocol.  For character-
+             oriented or fixed-length interfaces, the number of
+             inbound transmission units that contained errors
+             preventing them from being deliverable to a higher-layer
+             protocol.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifInErrors";
+        }
+        leaf in-unknown-protos {
+          type yang:counter32;
+          description
+            "For packet-oriented interfaces, the number of packets
+             received via the interface which were discarded because
+             of an unknown or unsupported protocol.  For
+             character-oriented or fixed-length interfaces that
+             support protocol multiplexing the number of transmission
+             units received via the interface which were discarded
+             because of an unknown or unsupported protocol.  For any
+             interface that does not support protocol multiplexing,
+             this counter is not present.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
+        }
+
+        leaf out-octets {
+          type yang:counter64;
+          description
+            "The total number of octets transmitted out of the
+             interface, including framing characters.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
+        }
+        leaf out-unicast-pkts {
+          type yang:counter64;
+          description
+            "The total number of packets that higher-level protocols
+             requested be transmitted, and which were not addressed
+             to a multicast or broadcast address at this sub-layer,
+             including those that were discarded or not sent.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
+        }
+        leaf out-broadcast-pkts {
+          type yang:counter64;
+          description
+            "The total number of packets that higher-level protocols
+             requested be transmitted, and which were addressed to a
+             broadcast address at this sub-layer, including those
+             that were discarded or not sent.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB -
+                       ifHCOutBroadcastPkts";
+        }
+        leaf out-multicast-pkts {
+          type yang:counter64;
+          description
+            "The total number of packets that higher-level protocols
+             requested be transmitted, and which were addressed to a
+             multicast address at this sub-layer, including those
+             that were discarded or not sent.  For a MAC layer
+             protocol, this includes both Group and Functional
+             addresses.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB -
+                       ifHCOutMulticastPkts";
+        }
+        leaf out-discards {
+          type yang:counter32;
+          description
+            "The number of outbound packets which were chosen to be
+             discarded even though no errors had been detected to
+             prevent their being transmitted.  One possible reason
+             for discarding such a packet could be to free up buffer
+             space.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
+        }
+        leaf out-errors {
+          type yang:counter32;
+          description
+            "For packet-oriented interfaces, the number of outbound
+             packets that could not be transmitted because of errors.
+             For character-oriented or fixed-length interfaces, the
+             number of outbound transmission units that could not be
+             transmitted because of errors.
+
+             Discontinuities in the value of this counter can occur
+             at re-initialization of the management system, and at
+             other times as indicated by the value of
+             'discontinuity-time'.";
+          reference
+            "RFC 2863: The Interfaces Group MIB - ifOutErrors";
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-yang-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/enum-test-models/ietf-yang-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..e9d88ab
--- /dev/null
@@ -0,0 +1,396 @@
+ module ietf-yang-types {
+
+   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
+   prefix "yang";
+
+   organization
+    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+   contact
+    "WG Web:   <http://tools.ietf.org/wg/netmod/>
+     WG List:  <mailto:netmod@ietf.org>
+
+     WG Chair: David Partain
+               <mailto:david.partain@ericsson.com>
+
+     WG Chair: David Kessens
+               <mailto:david.kessens@nsn.com>
+
+     Editor:   Juergen Schoenwaelder
+               <mailto:j.schoenwaelder@jacobs-university.de>";
+
+   description
+    "This module contains a collection of generally useful derived
+     YANG data types.
+
+     Copyright (c) 2010 IETF Trust and the persons identified as
+     authors of the code.  All rights reserved.
+
+     Redistribution and use in source and binary forms, with or without
+     modification, is permitted pursuant to, and subject to the license
+     terms contained in, the Simplified BSD License set forth in Section
+     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
+     (http://trustee.ietf.org/license-info).
+
+     This version of this YANG module is part of RFC 6021; see
+     the RFC itself for full legal notices.";
+
+   revision 2010-09-24 {
+     description
+      "Initial revision.";
+     reference
+      "RFC 6021: Common YANG Data Types";
+   }
+
+   /*** collection of counter and gauge types ***/
+
+   typedef counter32 {
+     type uint32;
+     description
+      "The counter32 type represents a non-negative integer
+       that monotonically increases until it reaches a
+       maximum value of 2^32-1 (4294967295 decimal), when it
+       wraps around and starts increasing again from zero.
+
+       Counters have no defined 'initial' value, and thus, a
+       single value of a counter has (in general) no information
+       content.  Discontinuities in the monotonically increasing
+       value normally occur at re-initialization of the
+       management system, and at other times as specified in the
+       description of a schema node using this type.  If such
+       other times can occur, for example, the creation of
+       a schema node of type counter32 at times other than
+       re-initialization, then a corresponding schema node
+       should be defined, with an appropriate type, to indicate
+       the last discontinuity.
+
+       The counter32 type should not be used for configuration
+       schema nodes.  A default statement SHOULD NOT be used in
+       combination with the type counter32.
+
+       In the value set and its semantics, this type is equivalent
+       to the Counter32 type of the SMIv2.";
+     reference
+      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
+   }
+
+   typedef zero-based-counter32 {
+     type yang:counter32;
+     default "0";
+     description
+      "The zero-based-counter32 type represents a counter32
+       that has the defined 'initial' value zero.
+
+       A schema node of this type will be set to zero (0) on creation
+       and will thereafter increase monotonically until it reaches
+       a maximum value of 2^32-1 (4294967295 decimal), when it
+       wraps around and starts increasing again from zero.
+
+       Provided that an application discovers a new schema node
+       of this type within the minimum time to wrap, it can use the
+       'initial' value as a delta.  It is important for a management
+       station to be aware of this minimum time and the actual time
+       between polls, and to discard data if the actual time is too
+       long or there is no defined minimum time.
+
+       In the value set and its semantics, this type is equivalent
+       to the ZeroBasedCounter32 textual convention of the SMIv2.";
+     reference
+       "RFC 4502: Remote Network Monitoring Management Information
+                  Base Version 2";
+   }
+
+   typedef counter64 {
+     type uint64;
+     description
+      "The counter64 type represents a non-negative integer
+       that monotonically increases until it reaches a
+       maximum value of 2^64-1 (18446744073709551615 decimal),
+       when it wraps around and starts increasing again from zero.
+
+       Counters have no defined 'initial' value, and thus, a
+       single value of a counter has (in general) no information
+       content.  Discontinuities in the monotonically increasing
+       value normally occur at re-initialization of the
+       management system, and at other times as specified in the
+       description of a schema node using this type.  If such
+       other times can occur, for example, the creation of
+       a schema node of type counter64 at times other than
+       re-initialization, then a corresponding schema node
+       should be defined, with an appropriate type, to indicate
+       the last discontinuity.
+
+       The counter64 type should not be used for configuration
+       schema nodes.  A default statement SHOULD NOT be used in
+       combination with the type counter64.
+
+       In the value set and its semantics, this type is equivalent
+       to the Counter64 type of the SMIv2.";
+     reference
+      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
+   }
+
+   typedef zero-based-counter64 {
+     type yang:counter64;
+     default "0";
+     description
+      "The zero-based-counter64 type represents a counter64 that
+       has the defined 'initial' value zero.
+
+       A schema node of this type will be set to zero (0) on creation
+       and will thereafter increase monotonically until it reaches
+       a maximum value of 2^64-1 (18446744073709551615 decimal),
+       when it wraps around and starts increasing again from zero.
+
+       Provided that an application discovers a new schema node
+       of this type within the minimum time to wrap, it can use the
+       'initial' value as a delta.  It is important for a management
+       station to be aware of this minimum time and the actual time
+       between polls, and to discard data if the actual time is too
+       long or there is no defined minimum time.
+
+       In the value set and its semantics, this type is equivalent
+       to the ZeroBasedCounter64 textual convention of the SMIv2.";
+     reference
+      "RFC 2856: Textual Conventions for Additional High Capacity
+                 Data Types";
+   }
+
+   typedef gauge32 {
+     type uint32;
+     description
+      "The gauge32 type represents a non-negative integer, which
+       may increase or decrease, but shall never exceed a maximum
+       value, nor fall below a minimum value.  The maximum value
+       cannot be greater than 2^32-1 (4294967295 decimal), and
+       the minimum value cannot be smaller than 0.  The value of
+       a gauge32 has its maximum value whenever the information
+       being modeled is greater than or equal to its maximum
+       value, and has its minimum value whenever the information
+       being modeled is smaller than or equal to its minimum value.
+       If the information being modeled subsequently decreases
+       below (increases above) the maximum (minimum) value, the
+       gauge32 also decreases (increases).
+
+       In the value set and its semantics, this type is equivalent
+       to the Gauge32 type of the SMIv2.";
+     reference
+      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
+   }
+
+   typedef gauge64 {
+     type uint64;
+     description
+      "The gauge64 type represents a non-negative integer, which
+       may increase or decrease, but shall never exceed a maximum
+       value, nor fall below a minimum value.  The maximum value
+       cannot be greater than 2^64-1 (18446744073709551615), and
+       the minimum value cannot be smaller than 0.  The value of
+       a gauge64 has its maximum value whenever the information
+       being modeled is greater than or equal to its maximum
+       value, and has its minimum value whenever the information
+       being modeled is smaller than or equal to its minimum value.
+       If the information being modeled subsequently decreases
+       below (increases above) the maximum (minimum) value, the
+       gauge64 also decreases (increases).
+
+       In the value set and its semantics, this type is equivalent
+       to the CounterBasedGauge64 SMIv2 textual convention defined
+       in RFC 2856";
+     reference
+      "RFC 2856: Textual Conventions for Additional High Capacity
+                 Data Types";
+   }
+
+   /*** collection of identifier related types ***/
+
+   typedef object-identifier {
+     type string {
+       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
+             + '(\.(0|([1-9]\d*)))*';
+     }
+     description
+      "The object-identifier type represents administratively
+       assigned names in a registration-hierarchical-name tree.
+
+       Values of this type are denoted as a sequence of numerical
+       non-negative sub-identifier values.  Each sub-identifier
+       value MUST NOT exceed 2^32-1 (4294967295).  Sub-identifiers
+       are separated by single dots and without any intermediate
+       whitespace.
+
+       The ASN.1 standard restricts the value space of the first
+       sub-identifier to 0, 1, or 2.  Furthermore, the value space
+       of the second sub-identifier is restricted to the range
+       0 to 39 if the first sub-identifier is 0 or 1.  Finally,
+       the ASN.1 standard requires that an object identifier
+       has always at least two sub-identifier.  The pattern
+       captures these restrictions.
+
+       Although the number of sub-identifiers is not limited,
+       module designers should realize that there may be
+       implementations that stick with the SMIv2 limit of 128
+       sub-identifiers.
+
+       This type is a superset of the SMIv2 OBJECT IDENTIFIER type
+       since it is not restricted to 128 sub-identifiers.  Hence,
+       this type SHOULD NOT be used to represent the SMIv2 OBJECT
+       IDENTIFIER type, the object-identifier-128 type SHOULD be
+       used instead.";
+     reference
+      "ISO9834-1: Information technology -- Open Systems
+       Interconnection -- Procedures for the operation of OSI
+       Registration Authorities: General procedures and top
+       arcs of the ASN.1 Object Identifier tree";
+   }
+
+
+
+
+   typedef object-identifier-128 {
+     type object-identifier {
+       pattern '\d*(\.\d*){1,127}';
+     }
+     description
+      "This type represents object-identifiers restricted to 128
+       sub-identifiers.
+
+       In the value set and its semantics, this type is equivalent
+       to the OBJECT IDENTIFIER type of the SMIv2.";
+     reference
+      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
+   }
+
+   /*** collection of date and time related types ***/
+
+   typedef date-and-time {
+     type string {
+       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
+             + '(Z|[\+\-]\d{2}:\d{2})';
+     }
+     description
+      "The date-and-time type is a profile of the ISO 8601
+       standard for representation of dates and times using the
+       Gregorian calendar.  The profile is defined by the
+       date-time production in Section 5.6 of RFC 3339.
+
+       The date-and-time type is compatible with the dateTime XML
+       schema type with the following notable exceptions:
+
+       (a) The date-and-time type does not allow negative years.
+
+       (b) The date-and-time time-offset -00:00 indicates an unknown
+           time zone (see RFC 3339) while -00:00 and +00:00 and Z all
+           represent the same time zone in dateTime.
+
+       (c) The canonical format (see below) of data-and-time values
+           differs from the canonical format used by the dateTime XML
+           schema type, which requires all times to be in UTC using the
+           time-offset 'Z'.
+
+       This type is not equivalent to the DateAndTime textual
+       convention of the SMIv2 since RFC 3339 uses a different
+       separator between full-date and full-time and provides
+       higher resolution of time-secfrac.
+
+       The canonical format for date-and-time values with a known time
+       zone uses a numeric time zone offset that is calculated using
+       the device's configured known offset to UTC time.  A change of
+       the device's offset to UTC time will cause date-and-time values
+       to change accordingly.  Such changes might happen periodically
+       in case a server follows automatically daylight saving time
+       (DST) time zone offset changes.  The canonical format for
+       date-and-time values with an unknown time zone (usually referring
+       to the notion of local time) uses the time-offset -00:00.";
+     reference
+      "RFC 3339: Date and Time on the Internet: Timestamps
+       RFC 2579: Textual Conventions for SMIv2
+       XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
+   }
+
+   typedef timeticks {
+     type uint32;
+     description
+      "The timeticks type represents a non-negative integer that
+       represents the time, modulo 2^32 (4294967296 decimal), in
+       hundredths of a second between two epochs.  When a schema
+       node is defined that uses this type, the description of
+       the schema node identifies both of the reference epochs.
+
+       In the value set and its semantics, this type is equivalent
+       to the TimeTicks type of the SMIv2.";
+     reference
+      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
+   }
+
+   typedef timestamp {
+     type yang:timeticks;
+     description
+      "The timestamp type represents the value of an associated
+       timeticks schema node at which a specific occurrence happened.
+       The specific occurrence must be defined in the description
+       of any schema node defined using this type.  When the specific
+       occurrence occurred prior to the last time the associated
+       timeticks attribute was zero, then the timestamp value is
+       zero.  Note that this requires all timestamp values to be
+       reset to zero when the value of the associated timeticks
+       attribute reaches 497+ days and wraps around to zero.
+
+       The associated timeticks schema node must be specified
+       in the description of any schema node using this type.
+
+       In the value set and its semantics, this type is equivalent
+       to the TimeStamp textual convention of the SMIv2.";
+     reference
+      "RFC 2579: Textual Conventions for SMIv2";
+   }
+
+   /*** collection of generic address types ***/
+
+   typedef phys-address {
+     type string {
+       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+     }
+     description
+      "Represents media- or physical-level addresses represented
+       as a sequence octets, each octet represented by two hexadecimal
+       numbers.  Octets are separated by colons.  The canonical
+       representation uses lowercase characters.
+
+       In the value set and its semantics, this type is equivalent
+       to the PhysAddress textual convention of the SMIv2.";
+     reference
+      "RFC 2579: Textual Conventions for SMIv2";
+   }
+
+   typedef mac-address {
+     type string {
+       pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
+     }
+     description
+      "The mac-address type represents an IEEE 802 MAC address.
+       The canonical representation uses lowercase characters.
+
+       In the value set and its semantics, this type is equivalent
+       to the MacAddress textual convention of the SMIv2.";
+     reference
+      "IEEE 802: IEEE Standard for Local and Metropolitan Area
+                 Networks: Overview and Architecture
+       RFC 2579: Textual Conventions for SMIv2";
+   }
+
+   /*** collection of XML specific types ***/
+
+   typedef xpath1.0 {
+     type string;
+     description
+      "This type represents an XPATH 1.0 expression.
+
+       When a schema node is defined that uses this type, the
+       description of the schema node MUST specify the XPath
+       context in which the XPath expression is evaluated.";
+     reference
+      "XPATH: XML Path Language (XPath) Version 1.0";
+   }
+
+ }
\ No newline at end of file
index e9c077effd9a92138ec3e90be94c55ab2215ffdf..114a82ac0fd93b685987f77832c5dd08cf4784dd 100644 (file)
@@ -1,22 +1,22 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.controller.sal.binding.model.api.Type;\r
-\r
-/**\r
-\r
- *\r
- */\r
-public interface EnumBuilder {\r
-\r
-    public void addValue(final String name, final Integer value);\r
-\r
-    public Enumeration toInstance(final Type definingType);\r
-}\r
+/*
+ * 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.sal.binding.model.api.type.builder;
+
+import org.opendaylight.controller.sal.binding.model.api.Enumeration;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+/**
+
+ *
+ */
+public interface EnumBuilder extends Type {
+    
+    public void addValue(final String name, final Integer value);
+
+    public Enumeration toInstance(final Type definingType);
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/Demo.java b/opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/Demo.java
deleted file mode 100644 (file)
index 2d38c7d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller;\r
-\r
-import java.io.File;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.yang.model.api.Module;\r
-import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;\r
-\r
-public class Demo {\r
-\r
-    public static void main(String[] args) throws Exception {\r
-\r
-        String yangFilesDir;\r
-        if (args.length > 0) {\r
-            yangFilesDir = args[0];\r
-        } else {\r
-            yangFilesDir = "src/main/resources/demo";\r
-        }\r
-\r
-        File resourceDir = new File(yangFilesDir);\r
-        if (!resourceDir.exists()) {\r
-            throw new IllegalArgumentException(\r
-                    "Specified resource directory does not exists: "\r
-                            + resourceDir.getAbsolutePath());\r
-        }\r
-\r
-        String[] dirList = resourceDir.list();\r
-        String[] absFiles = new String[dirList.length];\r
-\r
-        int i = 0;\r
-        for (String fileName : dirList) {\r
-            File abs = new File(resourceDir, fileName);\r
-            absFiles[i] = abs.getAbsolutePath();\r
-            i++;\r
-        }\r
-\r
-        YangModelParserImpl parser = new YangModelParserImpl();\r
-        Set<Module> builtModules = parser.parseYangModels(absFiles);\r
-\r
-        System.out.println("Modules built: " + builtModules.size());\r
-    }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/yang/Demo.java b/opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/yang/Demo.java
new file mode 100644 (file)
index 0000000..60af153
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.generator.impl.BindingGeneratorImpl;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.java.api.generator.GeneratorJavaFile;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;
+
+public class Demo {
+    private static final String ERR_MSG = "2 parameters expected: 1. -f=<path-to-input-folder>, 2. -o=<output-folder>";
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 2) {
+            System.err.println(ERR_MSG);
+            return;
+        }
+
+        String inputFilesDir = null;
+        String outputFilesDir = null;
+        if (args[0].startsWith("-f=")) {
+            inputFilesDir = args[0].substring(3);
+        } else {
+            System.err.println("Missing input-folder declaration (-f=)");
+        }
+
+        if (args[1].startsWith("-o=")) {
+            outputFilesDir = args[1].substring(3);
+        } else {
+            System.err.println("Missing output-folder declaration (-o=)");
+        }
+
+        File resourceDir = new File(inputFilesDir);
+        if (!resourceDir.exists()) {
+            throw new IllegalArgumentException(
+                    "Specified input-folder does not exists: "
+                            + resourceDir.getAbsolutePath());
+        }
+
+        String[] dirList = resourceDir.list();
+        String[] absFiles = new String[dirList.length];
+
+        int i = 0;
+        for (String fileName : dirList) {
+            File abs = new File(resourceDir, fileName);
+            absFiles[i] = abs.getAbsolutePath();
+            i++;
+        }
+
+        final YangModelParserImpl parser = new YangModelParserImpl();
+        final BindingGenerator bindingGenerator = new BindingGeneratorImpl();
+        final Set<Module> modulesToBuild = parser.parseYangModels(absFiles);
+
+        final SchemaContext context = parser
+                .resolveSchemaContext(modulesToBuild);
+        final List<Type> types = bindingGenerator.generateTypes(context);
+        final Set<GeneratedType> typesToGenerate = new HashSet<GeneratedType>();
+        final Set<GeneratedTransferObject> tosToGenerate = new HashSet<GeneratedTransferObject>();
+        for (Type type : types) {
+            if (type instanceof GeneratedType) {
+                typesToGenerate.add((GeneratedType) type);
+            }
+
+            if (type instanceof GeneratedTransferObject) {
+                tosToGenerate.add((GeneratedTransferObject) type);
+            }
+        }
+
+        final GeneratorJavaFile generator = new GeneratorJavaFile(typesToGenerate, tosToGenerate);
+        
+        generator.generateToFile(outputFilesDir);
+        System.out.println("Modules built: " + modulesToBuild.size());
+    }
+}
index 8a032ca12c34b2660936e48be10d9a22e1f39d68..c802d3bf740720258b2db80b8ec493b43cfafcf3 100644 (file)
@@ -963,7 +963,7 @@ public final class YangModelBuilderUtil {
             type = YangTypesConverter.javaTypeForBaseYangUnsignedIntegerType(
                     typeName, rangeStatements);
         } else if ("enumeration".equals(typeName)) {
-            type = new EnumerationType(enumConstants);
+            type = new EnumerationType(actualPath, namespace, revision, enumConstants);
         } else if ("string".equals(typeName)) {
             type = new StringType(lengthStatements, patternStatements);
         } else if ("bits".equals(typeName)) {
index f289048fcb771255899fa8e6abcb64fbab400b31..fd3c640b5e33d2ae8d10e07cef46d6b5d18abb7e 100644 (file)
@@ -1,15 +1,15 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.yang.model.api;\r
-\r
-import java.util.Set;\r
-\r
-public interface ChoiceNode extends DataSchemaNode {\r
-\r
-    Set<ChoiceCaseNode> getCases();\r
-}\r
+/*
+ * 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.model.api;
+
+import java.util.Set;
+
+public interface ChoiceNode extends DataSchemaNode, AugmentationTarget {
+
+    Set<ChoiceCaseNode> getCases();
+}
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java
new file mode 100644 (file)
index 0000000..ded4a75
--- /dev/null
@@ -0,0 +1,130 @@
+package org.opendaylight.controller.yang.model.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.DataNodeContainer;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
+import org.opendaylight.controller.yang.model.api.ListSchemaNode;
+
+public class DataNodeIterator implements Iterator<DataSchemaNode> {
+    
+    private final DataNodeContainer container;
+    private final List<ListSchemaNode> allLists;
+    private final List<ContainerSchemaNode> allContainers;
+    private final List<LeafSchemaNode> allLeafs;
+    private final List<LeafListSchemaNode> allLeafLists;
+    private final List<DataSchemaNode> allChilds;
+    
+    public DataNodeIterator(final DataNodeContainer container) {
+        if (container == null) {
+            throw new IllegalArgumentException("Data Node Container MUST be specified!");
+        }
+        
+        this.allContainers = new ArrayList<ContainerSchemaNode>();
+        this.allLists = new ArrayList<ListSchemaNode>();
+        this.allLeafs = new ArrayList<LeafSchemaNode>();
+        this.allLeafLists = new ArrayList<LeafListSchemaNode>();
+        this.allChilds = new ArrayList<DataSchemaNode>();
+        
+        this.container = container;
+        
+        traverse(this.container);
+    }
+    
+    public List<ContainerSchemaNode> allContainers() {
+        return allContainers;
+    }
+    
+    public List<ListSchemaNode> allLists() {
+        return allLists;
+    }
+    
+    public List<LeafSchemaNode> allLeafs() {
+        return allLeafs;
+    }
+    
+    public List<LeafListSchemaNode> allLeafLists() {
+        return allLeafLists;
+    }
+    
+    private void traverse(final DataNodeContainer dataNode) {
+        if (!containChildDataNodeContainer(dataNode)) {
+            return;
+        }
+
+        final Set<DataSchemaNode> childs = dataNode.getChildNodes();
+        if (childs != null) {
+            for (DataSchemaNode childNode : childs) {
+                allChilds.add(childNode);
+                if (childNode instanceof ContainerSchemaNode) {
+                    final ContainerSchemaNode container = (ContainerSchemaNode) childNode;
+                    allContainers.add(container);
+                    traverse(container);
+                } else if (childNode instanceof ListSchemaNode) {
+                    final ListSchemaNode list = (ListSchemaNode) childNode;
+                    allLists.add(list);
+                    traverse(list);
+                } else if (childNode instanceof LeafSchemaNode) {
+                    final LeafSchemaNode leaf = (LeafSchemaNode) childNode;
+                    allLeafs.add(leaf);
+                } else if (childNode instanceof LeafListSchemaNode) {
+                    final LeafListSchemaNode leafList = (LeafListSchemaNode) childNode;
+                    allLeafLists.add(leafList);
+                }
+            }
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if and only if the child node contain at least
+     * one child container schema node or child list schema node, otherwise will
+     * always returns <code>false</code>
+     * 
+     * @param container
+     * @return <code>true</code> if and only if the child node contain at least
+     *         one child container schema node or child list schema node,
+     *         otherwise will always returns <code>false</code>
+     */
+    private boolean containChildDataNodeContainer(
+            final DataNodeContainer container) {
+        if (container != null) {
+            final Set<DataSchemaNode> childs = container.getChildNodes();
+            if ((childs != null) && (childs.size() > 0)) {
+                for (final DataSchemaNode childNode : childs) {
+                    if (childNode instanceof DataNodeContainer) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+    
+    @Override
+    public boolean hasNext() {
+        if (container.getChildNodes() != null) {
+            Set<DataSchemaNode> childs = container.getChildNodes();
+            
+            if ((childs != null) && !childs.isEmpty()) {
+                return childs.iterator().hasNext();
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public DataSchemaNode next() {
+        return allChilds.iterator().next();
+    }
+
+    @Override
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+}
index 696ec4f39e255277bf2c1ca055b972618b640cc0..c825390f38d98415c8fab8250a27f213816edbbc 100644 (file)
@@ -7,7 +7,9 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
+import java.net.URI;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
@@ -24,24 +26,38 @@ import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
 public class EnumerationType implements EnumTypeDefinition {
 
     private final QName name = BaseTypes.constructQName("enumeration");
-    private final SchemaPath path = BaseTypes.schemaPath(name);
+    private final SchemaPath path;
     private final String description = "The enumeration built-in type represents values from a set of assigned names.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.6";
 
-    private final List<EnumPair> defaultEnum;
+    private final EnumPair defaultEnum;
     private final List<EnumPair> enums;
     private String units = "";
-
-    public EnumerationType(final List<EnumPair> enums) {
+    private final EnumTypeDefinition baseType;
+    
+    private EnumerationType(final List<EnumPair> enums) {
+        this.path = BaseTypes.schemaPath(name);
+        this.enums = Collections.unmodifiableList(enums);
+        this.defaultEnum = null;
+        baseType = this;
+    }
+    
+    public EnumerationType(final List<String> actualPath, final URI namespace,
+            final Date revision, final List<EnumPair> enums) {
         super();
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
         this.enums = Collections.unmodifiableList(enums);
-        defaultEnum = Collections.emptyList();
+        this.defaultEnum = null;
+        baseType = new EnumerationType(enums);
     }
 
-    public EnumerationType(final List<EnumPair> defaultEnum,
+    public EnumerationType(final List<String> actualPath, final URI namespace,
+            final Date revision, final EnumTypeDefinition baseType, final EnumPair defaultEnum,
             final List<EnumPair> enums, final String units) {
         super();
-        this.defaultEnum = Collections.unmodifiableList(defaultEnum);
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.baseType = baseType;
+        this.defaultEnum = defaultEnum;
         this.enums = Collections.unmodifiableList(enums);
         this.units = units;
     }
@@ -53,7 +69,7 @@ public class EnumerationType implements EnumTypeDefinition {
      */
     @Override
     public EnumTypeDefinition getBaseType() {
-        return this;
+        return baseType;
     }
 
     /*
index 03f06387f1d70a251c82510dbdc5ec61dd3d1a95..2057a42eb6490bf659d11149ff85bb138326634b 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
 import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
-public class ExtendedType implements TypeDefinition {
+public class ExtendedType implements TypeDefinition<TypeDefinition<?>> {
 
     private final QName typeName;
     private final TypeDefinition<?> baseType;
index 9253895e3fec79af913029a020a3bc0e3113c057..a143f5a629a90c8440b0bd850e927963bb19dbf9 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.yang.model.util;\r
-\r
-import java.net.URI;\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\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.UnknownSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;\r
-\r
-/**\r
- * The <code>default</code> implementation of Instance Leafref Type Definition\r
- * interface.\r
- *\r
- * @see LeafrefTypeDefinition\r
- */\r
-public class Leafref implements LeafrefTypeDefinition {\r
-    private static final QName name = BaseTypes.constructQName("leafref");\r
-    private static final String description = "The leafref type is used to reference a "\r
-            + "particular leaf instance in the data tree.";\r
-    private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";\r
-    private final SchemaPath path;\r
-    private final RevisionAwareXPath xpath;\r
-    private final String units = "";\r
-    private final LeafrefTypeDefinition baseType;\r
-\r
-    public Leafref(final RevisionAwareXPath xpath) {\r
-        this.xpath = xpath;\r
-        this.path = BaseTypes.schemaPath(name);\r
-        this.baseType = this;\r
-    }\r
-\r
-    public Leafref(final List<String> actualPath, final URI namespace,\r
-            final Date revision, final RevisionAwareXPath xpath) {\r
-        super();\r
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);\r
-        this.xpath = xpath;\r
-        baseType = new Leafref(xpath);\r
-    }\r
-\r
-    public Leafref(final List<String> actualPath, final URI namespace,\r
-            final Date revision, final LeafrefTypeDefinition baseType,\r
-            final RevisionAwareXPath xpath) {\r
-        super();\r
-        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);\r
-        this.xpath = xpath;\r
-        this.baseType = baseType;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
-     */\r
-    @Override\r
-    public LeafrefTypeDefinition getBaseType() {\r
-        return baseType;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
-     */\r
-    @Override\r
-    public String getUnits() {\r
-        return units;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue\r
-     * ()\r
-     */\r
-    @Override\r
-    public Object getDefaultValue() {\r
-        return this;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
-     */\r
-    @Override\r
-    public QName getQName() {\r
-        return name;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
-     */\r
-    @Override\r
-    public SchemaPath getPath() {\r
-        return path;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
-     */\r
-    @Override\r
-    public String getDescription() {\r
-        return description;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
-     */\r
-    @Override\r
-    public String getReference() {\r
-        return reference;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
-     */\r
-    @Override\r
-    public Status getStatus() {\r
-        return Status.CURRENT;\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes\r
-     * ()\r
-     */\r
-    @Override\r
-    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
-        return Collections.emptyList();\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see\r
-     * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition\r
-     * #getPathStatement()\r
-     */\r
-    @Override\r
-    public RevisionAwareXPath getPathStatement() {\r
-        return xpath;\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result + ((path == null) ? 0 : path.hashCode());\r
-        result = prime * result + ((units == null) ? 0 : units.hashCode());\r
-        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (getClass() != obj.getClass()) {\r
-            return false;\r
-        }\r
-        Leafref other = (Leafref) obj;\r
-        if (path == null) {\r
-            if (other.path != null) {\r
-                return false;\r
-            }\r
-        } else if (!path.equals(other.path)) {\r
-            return false;\r
-        }\r
-        if (units == null) {\r
-            if (other.units != null) {\r
-                return false;\r
-            }\r
-        } else if (!units.equals(other.units)) {\r
-            return false;\r
-        }\r
-        if (xpath == null) {\r
-            if (other.xpath != null) {\r
-                return false;\r
-            }\r
-        } else if (!xpath.equals(other.xpath)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("Leafref [path=");\r
-        builder.append(path);\r
-        builder.append(", xpath=");\r
-        builder.append(xpath);\r
-        builder.append(", units=");\r
-        builder.append(units);\r
-        builder.append("]");\r
-        return builder.toString();\r
-    }\r
-}\r
+/*
+ * 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.model.util;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
+
+/**
+ * The <code>default</code> implementation of Instance Leafref Type Definition
+ * interface.
+ *
+ * @see LeafrefTypeDefinition
+ */
+public class Leafref implements LeafrefTypeDefinition {
+    private static final QName name = BaseTypes.constructQName("leafref");
+    private static final String description = "The leafref type is used to reference a "
+            + "particular leaf instance in the data tree.";
+    private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";
+    private final SchemaPath path;
+    private final RevisionAwareXPath xpath;
+    private final String units = "";
+    private final LeafrefTypeDefinition baseType;
+
+    private Leafref(final RevisionAwareXPath xpath) {
+        this.xpath = xpath;
+        this.path = BaseTypes.schemaPath(name);
+        this.baseType = this;
+    }
+
+    public Leafref(final List<String> actualPath, final URI namespace,
+            final Date revision, final RevisionAwareXPath xpath) {
+        super();
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.xpath = xpath;
+        baseType = new Leafref(xpath);
+    }
+
+    public Leafref(final List<String> actualPath, final URI namespace,
+            final Date revision, final LeafrefTypeDefinition baseType,
+            final RevisionAwareXPath xpath) {
+        super();
+        this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+        this.xpath = xpath;
+        this.baseType = baseType;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+     */
+    @Override
+    public LeafrefTypeDefinition getBaseType() {
+        return baseType;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
+     */
+    @Override
+    public String getUnits() {
+        return units;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+     * ()
+     */
+    @Override
+    public Object getDefaultValue() {
+        return this;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
+     */
+    @Override
+    public QName getQName() {
+        return name;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
+     */
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+     */
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
+     */
+    @Override
+    public String getReference() {
+        return reference;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
+     */
+    @Override
+    public Status getStatus() {
+        return Status.CURRENT;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes
+     * ()
+     */
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return Collections.emptyList();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition
+     * #getPathStatement()
+     */
+    @Override
+    public RevisionAwareXPath getPathStatement() {
+        return xpath;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((path == null) ? 0 : path.hashCode());
+        result = prime * result + ((units == null) ? 0 : units.hashCode());
+        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        Leafref other = (Leafref) obj;
+        if (path == null) {
+            if (other.path != null) {
+                return false;
+            }
+        } else if (!path.equals(other.path)) {
+            return false;
+        }
+        if (units == null) {
+            if (other.units != null) {
+                return false;
+            }
+        } else if (!units.equals(other.units)) {
+            return false;
+        }
+        if (xpath == null) {
+            if (other.xpath != null) {
+                return false;
+            }
+        } else if (!xpath.equals(other.xpath)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("Leafref [path=");
+        builder.append(path);
+        builder.append(", xpath=");
+        builder.append(xpath);
+        builder.append(", units=");
+        builder.append(units);
+        builder.append("]");
+        return builder.toString();
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java
new file mode 100644 (file)
index 0000000..ab50982
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * 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.model.util;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.DataNodeContainer;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.ListSchemaNode;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.api.SchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+
+public final class SchemaContextUtil {
+
+    private final SchemaContext context;
+
+    public SchemaContextUtil(final SchemaContext context) {
+        this.context = context;
+    }
+
+    public DataSchemaNode findDataSchemaNode(final Module module,
+            final RevisionAwareXPath nonCondXPath) {
+        if (nonCondXPath != null) {
+            final String strXPath = nonCondXPath.toString();
+
+            if (strXPath != null) {
+                if (strXPath.matches(".*//[.* | .*//].*")) {
+                    // TODO: function to escape conditions in path   
+                }
+                if (nonCondXPath.isAbsolute()) {
+                    final Queue<String> queuedPath = xpathToQueuedPath(strXPath);
+                    if (queuedPath != null) {
+                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(
+                                module, queuedPath);
+                        return dataNode;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    public DataSchemaNode findDataSchemaNodeForRelativeXPath(
+            final Module module, final SchemaNode actualSchemaNode,
+            final RevisionAwareXPath relativeXPath) {
+        if ((actualSchemaNode != null) && (relativeXPath != null)
+                && !relativeXPath.isAbsolute()) {
+
+            final SchemaPath actualNodePath = actualSchemaNode.getPath();
+            if (actualNodePath != null) {
+                final Queue<String> queuedPath = resolveRelativeXPath(
+                        relativeXPath, actualNodePath);
+
+                if (queuedPath != null) {
+                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(
+                            module, queuedPath);
+                    return dataNode;
+                }
+            }
+        }
+
+        return null;
+    }
+    
+    public Module resolveModuleFromSchemaPath(final SchemaPath schemaPath) {
+        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
+            final QName qname = schemaPath.getPath().get(0);
+
+            if ((qname != null) && (qname.getNamespace() != null)) {
+                return context
+                        .findModuleByNamespace(qname.getNamespace());
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * Search which starts from root of Module.
+     * 
+     * @param module
+     * @param prefixedPath
+     * @return
+     */
+    private DataSchemaNode findSchemaNodeForGivenPath(final Module module,
+            final Queue<String> prefixedPath) {
+        if ((module != null) && (prefixedPath != null)) {
+            DataNodeContainer nextContainer = module;
+            final String modulePrefix = module.getPrefix();
+
+            String childNodeName = null;
+            DataSchemaNode schemaNode = null;
+            while ((nextContainer != null) && (prefixedPath.size() > 0)) {
+                childNodeName = prefixedPath.poll();
+                if (childNodeName.contains(":")) {
+                    final String[] prefixedChildNode = childNodeName.split(":");
+                    if ((modulePrefix != null)
+                            && modulePrefix.equals(prefixedChildNode[0])) {
+
+                        childNodeName = prefixedChildNode[1];
+                    } else {
+                        final Module nextModule = resolveModuleForPrefix(
+                                prefixedChildNode[0], module);
+                        final Queue<String> nextModulePrefixedPath = new LinkedList<String>();
+                        nextModulePrefixedPath.add(childNodeName);
+                        nextModulePrefixedPath.addAll(prefixedPath);
+                        prefixedPath.clear();
+
+                        schemaNode = findSchemaNodeForGivenPath(nextModule,
+                                nextModulePrefixedPath);
+
+                        return schemaNode;
+                    }
+                }
+
+                schemaNode = nextContainer.getDataChildByName(childNodeName);
+                if (schemaNode instanceof ContainerSchemaNode) {
+                    nextContainer = (ContainerSchemaNode) schemaNode;
+                } else if (schemaNode instanceof ListSchemaNode) {
+                    nextContainer = (ListSchemaNode) schemaNode;
+                } else {
+                    return schemaNode;
+                }
+            }
+        }
+        return null;
+    }
+
+    private Module resolveModuleForPrefix(final String prefix,
+            final Module parent) {
+        if ((prefix != null) && (parent != null)) {
+            final Set<ModuleImport> imports = parent.getImports();
+
+            if (imports != null) {
+                for (final ModuleImport impModule : imports) {
+                    final String impModPrefix = impModule.getPrefix();
+                    if ((impModPrefix != null) && prefix.equals(impModPrefix)) {
+                        return resolveModuleFromContext(prefix,
+                                impModule.getModuleName());
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private Module resolveModuleFromContext(final String prefix,
+            final String moduleName) {
+        final Set<Module> modules = context.getModules();
+
+        if ((prefix != null) && (moduleName != null) && (modules != null)) {
+            for (Module module : modules) {
+                if ((module != null) && prefix.equals(module.getPrefix())
+                        && moduleName.equals(module.getName())) {
+                    return module;
+                }
+            }
+        }
+        return null;
+    }
+
+    private Queue<String> xpathToQueuedPath(final String xpath) {
+        final Queue<String> retQueue = new LinkedList<String>();
+        if ((xpath != null)) {
+            final String[] prefixedPath = xpath.split("/");
+
+            if (prefixedPath != null) {
+                for (int i = 0; i < prefixedPath.length; ++i) {
+                    if (!prefixedPath[i].isEmpty()) {
+                        retQueue.add(prefixedPath[i]);
+                    }
+                }
+            }
+        }
+        return retQueue;
+    }
+
+    private Queue<String> resolveRelativeXPath(
+            final RevisionAwareXPath relativeXPath,
+            final SchemaPath leafrefSchemaPath) {
+        final Queue<String> absolutePath = new LinkedList<String>();
+
+        if ((relativeXPath != null) && !relativeXPath.isAbsolute()
+                && (leafrefSchemaPath != null)) {
+            final String strXPath = relativeXPath.toString();
+            if (strXPath != null) {
+                final String[] xpaths = strXPath.split("/");
+
+                if (xpaths != null) {
+                    int colCount = 0;
+                    while (xpaths[colCount].contains("..")) {
+                        ++colCount;
+                    }
+                    final List<QName> path = leafrefSchemaPath.getPath();
+                    if (path != null) {
+                        int lenght = path.size() - colCount;
+                        for (int i = 0; i < lenght; ++i) {
+                            absolutePath.add(path.get(i).getLocalName());
+                        }
+                        for (int i = colCount; i < xpaths.length; ++i) {
+                            absolutePath.add(xpaths[i]);
+                        }
+                    }
+                }
+            }
+        }
+        return absolutePath;
+    }
+}