Fixed YANG union type resolving in yang model parser. 99/99/1
authormvitez <mvitez@cisco.com>
Wed, 3 Apr 2013 13:28:38 +0000 (15:28 +0200)
committermvitez <mvitez@cisco.com>
Wed, 3 Apr 2013 13:28:38 +0000 (15:28 +0200)
Signed-off-by: mvitez <mvitez@cisco.com>
14 files changed:
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/YangModelParser.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnionTypeBuilder.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/impl/YangModelParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/TypesResolutionTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/abstract-topology.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-afn-safi@2012-06-04.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-if-type@2012-06-05.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-timezones@2012-07-09.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-inet-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-yang-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnionType.java [new file with mode: 0644]

index 8faf73e3b476845325cc7642ce48dadf230c3009..1dda17af300635e36bf18aa8925b20faab2be924 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.parser.api;
 
+import java.io.InputStream;
 import java.util.Set;
 
 import org.opendaylight.controller.model.api.type.UnknownTypeDefinition;
@@ -14,16 +15,16 @@ import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 
 /**
- * Yang Model Parser interface is designed for parsing yang models and 
- * convert the information to Data Schema Tree.
- * 
+ * Yang Model Parser interface is designed for parsing yang models and convert
+ * the information to Data Schema Tree.
+ *
  */
 public interface YangModelParser {
 
     /**
      * Parse single Yang model file and return the schema definition of Yang
      * module defined in *.Yang file.
-     * 
+     *
      * @param yangFile
      *            yang file to parse
      * @return the schema definition of Yang module defined in .Yang file.
@@ -32,16 +33,19 @@ public interface YangModelParser {
 
     /**
      * Parse one or more Yang model files and return the definitions of Yang
-     * modules defined in *.Yang files;
-     * <br>
+     * modules defined in *.Yang files; <br>
      * This method SHOULD be used if user need to parse multiple yang models
      * that are referenced either through import or include statements.
-     * 
-     * @param yangFiles yang files to parse
+     *
+     * @param yangFiles
+     *            yang files to parse
      * @return Set of Yang Modules
      */
     public Set<Module> parseYangModels(final String... yangFiles);
 
+    public Set<Module> parseYangModelsFromStreams(
+            final InputStream... yangModelStreams);
+
     /**
      * Creates {@link SchemaContext} from specified Modules. The modules SHOULD
      * not contain any unresolved Schema Nodes or Type Definitions. By
@@ -49,7 +53,7 @@ public interface YangModelParser {
      * should not contain ANY Schema Nodes that contains
      * {@link UnknownTypeDefinition} and all dependencies although via import or
      * include definitions are resolved.
-     * 
+     *
      * @param modules
      *            Set of Yang Modules
      * @return Schema Context instance constructed from whole Set of Modules.
index 5f89e864559fd9f8d74dadc691150b367b16168f..90a4547f38f90054c139eaa2f8f753e20c28883e 100644 (file)
-/*
- * 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.parser.builder.impl;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;
-import org.opendaylight.controller.yang.model.api.Deviation;
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
-import org.opendaylight.controller.yang.model.api.FeatureDefinition;
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.ModuleImport;
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;
-import org.opendaylight.controller.yang.model.api.RpcDefinition;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
-import org.opendaylight.controller.yang.model.api.UsesNode;
-import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
-import org.opendaylight.controller.yang.model.parser.builder.api.ChildNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
-
-/**
- * This builder builds Module object. If this module is dependent on external
- * module/modules, these dependencies must be resolved before module is built,
- * otherwise result may not be valid.
- */
-public class ModuleBuilder implements Builder {
-
-    private final ModuleImpl instance;
-    private final String name;
-    private String prefix;
-    private Date revision;
-
-    private final Set<ModuleImport> imports = new HashSet<ModuleImport>();
-    private Set<AugmentationSchema> augmentations;
-
-    /**
-     * All nodes, that can contain other nodes
-     */
-    private final Map<List<String>, Builder> moduleNodes = new HashMap<List<String>, Builder>();
-
-    /**
-     * Holds all child (DataSchemaNode) nodes: anyxml, choice, case, container,
-     * list, leaf, leaf-list.
-     */
-    private final Map<List<String>, DataSchemaNodeBuilder> addedChilds = new HashMap<List<String>, DataSchemaNodeBuilder>();
-
-    private final Map<List<String>, GroupingBuilder> addedGroupings = new HashMap<List<String>, GroupingBuilder>();
-    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();
-    private final Map<List<String>, UsesNodeBuilder> addedUsesNodes = new HashMap<List<String>, UsesNodeBuilder>();
-    private final Map<List<String>, RpcDefinitionBuilder> addedRpcs = new HashMap<List<String>, RpcDefinitionBuilder>();
-    private final Set<NotificationBuilder> addedNotifications = new HashSet<NotificationBuilder>();
-    private final Map<List<String>, FeatureBuilder> addedFeatures = new HashMap<List<String>, FeatureBuilder>();
-    private final Map<String, DeviationBuilder> addedDeviations = new HashMap<String, DeviationBuilder>();
-    private final Map<List<String>, TypeDefinitionBuilder> addedTypedefs = new HashMap<List<String>, TypeDefinitionBuilder>();
-    private final List<ExtensionBuilder> addedExtensions = new ArrayList<ExtensionBuilder>();
-
-    private final Map<List<String>, TypeAwareBuilder> dirtyNodes = new HashMap<List<String>, TypeAwareBuilder>();
-
-    public ModuleBuilder(String name) {
-        this.name = name;
-        instance = new ModuleImpl(name);
-    }
-
-
-
-    /**
-     * Build new Module object based on this builder.
-     */
-    @Override
-    public Module build() {
-        instance.setImports(imports);
-
-        // TYPEDEFS
-        final Set<TypeDefinition<?>> typedefs = buildModuleTypedefs(addedTypedefs);
-        instance.setTypeDefinitions(typedefs);
-
-        // CHILD NODES
-        final Map<QName, DataSchemaNode> childNodes = buildModuleChildNodes(addedChilds);
-        instance.setChildNodes(childNodes);
-
-        // GROUPINGS
-        final Set<GroupingDefinition> groupings = buildModuleGroupings(addedGroupings);
-        instance.setGroupings(groupings);
-
-        // USES
-        final Set<UsesNode> usesNodeDefinitions = buildUsesNodes(addedUsesNodes);
-        instance.setUses(usesNodeDefinitions);
-
-        // FEATURES
-        final Set<FeatureDefinition> features = buildModuleFeatures(addedFeatures);
-        instance.setFeatures(features);
-
-        // NOTIFICATIONS
-        final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();
-        for (NotificationBuilder entry : addedNotifications) {
-            notifications.add((NotificationDefinition) entry.build());
-        }
-        instance.setNotifications(notifications);
-
-        // AUGMENTATIONS
-        instance.setAugmentations(augmentations);
-
-        // RPCs
-        final Set<RpcDefinition> rpcs = buildModuleRpcs(addedRpcs);
-        instance.setRpcs(rpcs);
-
-        // DEVIATIONS
-        final Set<Deviation> deviations = new HashSet<Deviation>();
-        for (Map.Entry<String, DeviationBuilder> entry : addedDeviations
-                .entrySet()) {
-            deviations.add(entry.getValue().build());
-        }
-        instance.setDeviations(deviations);
-
-        // EXTENSIONS
-        final List<ExtensionDefinition> extensions = new ArrayList<ExtensionDefinition>();
-        for(ExtensionBuilder b : addedExtensions) {
-            extensions.add(b.build());
-        }
-        instance.setExtensionSchemaNodes(extensions);
-
-        return instance;
-    }
-
-    public Builder getNode(List<String> path) {
-        return moduleNodes.get(path);
-    }
-
-    public Map<List<String>, TypeAwareBuilder> getDirtyNodes() {
-        return dirtyNodes;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getPrefix() {
-        return prefix;
-    }
-
-    public Date getRevision() {
-        return revision;
-    }
-
-    public Set<AugmentationSchemaBuilder> getAddedAugments() {
-        return addedAugments;
-    }
-
-    public void addDirtyNode(List<String> path) {
-        List<String> dirtyNodePath = new ArrayList<String>(path);
-        TypeAwareBuilder nodeBuilder = (TypeAwareBuilder) moduleNodes
-                .get(dirtyNodePath);
-        dirtyNodes.put(dirtyNodePath, nodeBuilder);
-    }
-
-    public void setNamespace(URI namespace) {
-        instance.setNamespace(namespace);
-    }
-
-    public void setRevision(Date revision) {
-        this.revision = revision;
-        instance.setRevision(revision);
-    }
-
-    public void setPrefix(String prefix) {
-        this.prefix = prefix;
-        instance.setPrefix(prefix);
-    }
-
-    public void setYangVersion(String yangVersion) {
-        instance.setYangVersion(yangVersion);
-    }
-
-    public void setDescription(String description) {
-        instance.setDescription(description);
-    }
-
-    public void setReference(String reference) {
-        instance.setReference(reference);
-    }
-
-    public void setOrganization(String organization) {
-        instance.setOrganization(organization);
-    }
-
-    public void setContact(String contact) {
-        instance.setContact(contact);
-    }
-
-    public void setAugmentations(Set<AugmentationSchema> augmentations) {
-        this.augmentations = augmentations;
-    }
-
-    public boolean addModuleImport(final String moduleName,
-            final Date revision, final String prefix) {
-        ModuleImport moduleImport = createModuleImport(moduleName, revision,
-                prefix);
-        return imports.add(moduleImport);
-    }
-
-    public Set<ModuleImport> getModuleImports() {
-        return imports;
-    }
-
-    public ExtensionBuilder addExtension(QName qname) {
-        ExtensionBuilder builder = new ExtensionBuilder(qname);
-        return builder;
-    }
-
-    public ContainerSchemaNodeBuilder addContainerNode(QName containerName,
-            List<String> parentPath) {
-        List<String> pathToNode = new ArrayList<String>(parentPath);
-
-        ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
-                containerName);
-
-        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
-                .get(pathToNode);
-        if (parent != null) {
-            if(parent instanceof AugmentationSchemaBuilder) {
-                containerBuilder.setAugmenting(true);
-            }
-            parent.addChildNode(containerBuilder);
-        }
-
-        pathToNode.add(containerName.getLocalName());
-        moduleNodes.put(pathToNode, containerBuilder);
-        addedChilds.put(pathToNode, containerBuilder);
-
-        return containerBuilder;
-    }
-
-    public ListSchemaNodeBuilder addListNode(QName listName,
-            List<String> parentPath) {
-        List<String> pathToNode = new ArrayList<String>(parentPath);
-
-        ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(listName);
-
-        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
-                .get(pathToNode);
-        if (parent != null) {
-            if(parent instanceof AugmentationSchemaBuilder) {
-                listBuilder.setAugmenting(true);
-            }
-            parent.addChildNode(listBuilder);
-        }
-
-        pathToNode.add(listName.getLocalName());
-        moduleNodes.put(pathToNode, listBuilder);
-        addedChilds.put(pathToNode, listBuilder);
-
-        return listBuilder;
-    }
-
-    public LeafSchemaNodeBuilder addLeafNode(QName leafName,
-            List<String> parentPath) {
-        List<String> pathToNode = new ArrayList<String>(parentPath);
-
-        LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(leafName);
-
-        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);
-        if (parent != null) {
-            if(parent instanceof AugmentationSchemaBuilder) {
-                leafBuilder.setAugmenting(true);
-            }
-            parent.addChildNode(leafBuilder);
-        }
-
-        pathToNode.add(leafName.getLocalName());
-        addedChilds.put(pathToNode, leafBuilder);
-        moduleNodes.put(pathToNode, leafBuilder);
-
-        return leafBuilder;
-    }
-
-    public LeafListSchemaNodeBuilder addLeafListNode(QName leafListName,
-            List<String> parentPath) {
-        List<String> pathToNode = new ArrayList<String>(parentPath);
-
-        LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
-                leafListName);
-        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);
-        if (parent != null) {
-            if(parent instanceof AugmentationSchemaBuilder) {
-                leafListBuilder.setAugmenting(true);
-            }
-            parent.addChildNode(leafListBuilder);
-        }
-
-        pathToNode.add(leafListName.getLocalName());
-        addedChilds.put(pathToNode, leafListBuilder);
-        moduleNodes.put(pathToNode, leafListBuilder);
-
-        return leafListBuilder;
-    }
-
-    public GroupingBuilder addGrouping(QName qname, List<String> parentPath) {
-        List<String> pathToGroup = new ArrayList<String>(parentPath);
-
-        GroupingBuilder builder = new GroupingBuilderImpl(qname);
-        ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes.get(pathToGroup);
-        if (parentNodeBuilder != null) {
-            parentNodeBuilder.addGrouping(builder);
-        }
-
-        pathToGroup.add(qname.getLocalName());
-        moduleNodes.put(pathToGroup, builder);
-        addedGroupings.put(pathToGroup, builder);
-
-        return builder;
-    }
-
-    public AugmentationSchemaBuilder addAugment(String name,
-            List<String> parentPath) {
-        List<String> pathToAugment = new ArrayList<String>(parentPath);
-
-        AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name);
-
-        // augment can only be in 'module' or 'uses' statement
-        UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);
-        if (parent != null) {
-            parent.addAugment(builder);
-        }
-
-        pathToAugment.add(name);
-        moduleNodes.put(pathToAugment, builder);
-        addedAugments.add(builder);
-
-        return builder;
-    }
-
-    public UsesNodeBuilder addUsesNode(String groupingPathStr,
-            List<String> parentPath) {
-        List<String> pathToUses = new ArrayList<String>(parentPath);
-
-        UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(groupingPathStr);
-
-        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToUses);
-        if (parent != null) {
-            if(parent instanceof AugmentationSchemaBuilder) {
-                usesBuilder.setAugmenting(true);
-            }
-            parent.addUsesNode(usesBuilder);
-        }
-
-        pathToUses.add(groupingPathStr);
-        addedUsesNodes.put(pathToUses, usesBuilder);
-
-        return usesBuilder;
-    }
-
-    public RpcDefinitionBuilder addRpc(QName qname, List<String> parentPath) {
-        List<String> pathToRpc = new ArrayList<String>(parentPath);
-
-        RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);
-
-        pathToRpc.add(qname.getLocalName());
-        addedRpcs.put(pathToRpc, rpcBuilder);
-
-        QName inputQName = new QName(qname.getNamespace(), qname.getRevision(),
-                qname.getPrefix(), "input");
-        ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(inputQName);
-        List<String> pathToInput = new ArrayList<String>(pathToRpc);
-        pathToInput.add("input");
-        moduleNodes.put(pathToInput, inputBuilder);
-        rpcBuilder.setInput(inputBuilder);
-
-        QName outputQName = new QName(qname.getNamespace(),
-                qname.getRevision(), qname.getPrefix(), "output");
-        ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(outputQName);
-        List<String> pathToOutput = new ArrayList<String>(pathToRpc);
-        pathToOutput.add("output");
-        moduleNodes.put(pathToOutput, outputBuilder);
-        rpcBuilder.setOutput(outputBuilder);
-
-        return rpcBuilder;
-    }
-
-    public NotificationBuilder addNotification(QName notificationName,
-            List<String> parentPath) {
-        List<String> pathToNotification = new ArrayList<String>(parentPath);
-
-        NotificationBuilder notificationBuilder = new NotificationBuilder(
-                notificationName);
-
-        pathToNotification.add(notificationName.getLocalName());
-        moduleNodes.put(pathToNotification, notificationBuilder);
-        addedNotifications.add(notificationBuilder);
-
-        return notificationBuilder;
-    }
-
-    public FeatureBuilder addFeature(QName featureName, List<String> parentPath) {
-        List<String> pathToFeature = new ArrayList<String>(parentPath);
-        pathToFeature.add(featureName.getLocalName());
-
-        FeatureBuilder builder = new FeatureBuilder(featureName);
-        addedFeatures.put(pathToFeature, builder);
-        return builder;
-    }
-
-    public TypedefBuilder addTypedef(QName typeDefName, List<String> parentPath) {
-        List<String> pathToType = new ArrayList<String>(parentPath);
-        TypedefBuilder builder = new TypedefBuilder(typeDefName);
-        TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder) moduleNodes.get(pathToType);
-        if (parent != null) {
-            parent.addTypedef(builder);
-        }
-        pathToType.add(typeDefName.getLocalName());
-        addedTypedefs.put(pathToType, builder);
-        moduleNodes.put(pathToType, builder);
-        return builder;
-    }
-
-    public Set<TypeDefinitionBuilder> getModuleTypedefs() {
-        Set<TypeDefinitionBuilder> typedefs = new HashSet<TypeDefinitionBuilder>();
-        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs.entrySet()) {
-            if (entry.getKey().size() == 2) {
-                typedefs.add(entry.getValue());
-            }
-        }
-        return typedefs;
-    }
-
-    public void setType(TypeDefinition<?> type, List<String> parentPath) {
-        TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes.get(parentPath);
-        parent.setType(type);
-    }
-
-    public DeviationBuilder addDeviation(String targetPath) {
-        DeviationBuilder builder = new DeviationBuilder(targetPath);
-        addedDeviations.put(targetPath, builder);
-        return builder;
-    }
-
-    public void addConfiguration(boolean configuration, List<String> parentPath) {
-        Builder builder = moduleNodes.get(parentPath);
-        if (builder instanceof DeviationBuilder) {
-            // skip
-            // TODO
-        } else {
-            DataSchemaNodeBuilder configBuilder = (DataSchemaNodeBuilder) moduleNodes.get(parentPath);
-            configBuilder.setConfiguration(configuration);
-        }
-    }
-
-    public UnknownSchemaNodeBuilder addUnknownSchemaNode(QName qname, List<String> parentPath) {
-        UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(qname);
-        return builder;
-    }
-
-
-    private class ModuleImpl implements Module {
-        private URI namespace;
-        private final String name;
-        private Date revision;
-        private String prefix;
-        private String yangVersion;
-        private String description;
-        private String reference;
-        private String organization;
-        private String contact;
-        private Set<ModuleImport> imports = Collections.emptySet();
-        private Set<FeatureDefinition> features = Collections.emptySet();
-        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
-        private Set<NotificationDefinition> notifications = Collections.emptySet();
-        private Set<AugmentationSchema> augmentations = Collections.emptySet();
-        private Set<RpcDefinition> rpcs = Collections.emptySet();
-        private Set<Deviation> deviations = Collections.emptySet();
-        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
-        private Set<GroupingDefinition> groupings = Collections.emptySet();
-        private Set<UsesNode> uses = Collections.emptySet();
-        private List<ExtensionDefinition> extensionSchemaNodes = Collections.emptyList();
-
-        private ModuleImpl(String name) {
-            this.name = name;
-        }
-
-        @Override
-        public URI getNamespace() {
-            return namespace;
-        }
-
-        private void setNamespace(URI namespace) {
-            this.namespace = namespace;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
-
-        @Override
-        public Date getRevision() {
-            return revision;
-        }
-
-        private void setRevision(Date revision) {
-            this.revision = revision;
-        }
-
-        @Override
-        public String getPrefix() {
-            return prefix;
-        }
-
-        private void setPrefix(String prefix) {
-            this.prefix = prefix;
-        }
-
-        @Override
-        public String getYangVersion() {
-            return yangVersion;
-        }
-
-        private void setYangVersion(String yangVersion) {
-            this.yangVersion = yangVersion;
-        }
-
-        @Override
-        public String getDescription() {
-            return description;
-        }
-
-        private void setDescription(String description) {
-            this.description = description;
-        }
-
-        @Override
-        public String getReference() {
-            return reference;
-        }
-
-        private void setReference(String reference) {
-            this.reference = reference;
-        }
-
-        @Override
-        public String getOrganization() {
-            return organization;
-        }
-
-        private void setOrganization(String organization) {
-            this.organization = organization;
-        }
-
-        @Override
-        public String getContact() {
-            return contact;
-        }
-
-        private void setContact(String contact) {
-            this.contact = contact;
-        }
-
-        @Override
-        public Set<ModuleImport> getImports() {
-            return imports;
-        }
-
-        private void setImports(Set<ModuleImport> imports) {
-            this.imports = imports;
-        }
-
-        @Override
-        public Set<FeatureDefinition> getFeatures() {
-            return features;
-        }
-
-        private void setFeatures(Set<FeatureDefinition> features) {
-            this.features = features;
-        }
-
-        @Override
-        public Set<TypeDefinition<?>> getTypeDefinitions() {
-            return typeDefinitions;
-        }
-
-        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
-            this.typeDefinitions = typeDefinitions;
-        }
-
-        @Override
-        public Set<NotificationDefinition> getNotifications() {
-            return notifications;
-        }
-
-        private void setNotifications(Set<NotificationDefinition> notifications) {
-            this.notifications = notifications;
-        }
-
-        @Override
-        public Set<AugmentationSchema> getAugmentations() {
-            return augmentations;
-        }
-
-        private void setAugmentations(Set<AugmentationSchema> augmentations) {
-            this.augmentations = augmentations;
-        }
-
-        @Override
-        public Set<RpcDefinition> getRpcs() {
-            return rpcs;
-        }
-
-        private void setRpcs(Set<RpcDefinition> rpcs) {
-            this.rpcs = rpcs;
-        }
-
-        @Override
-        public Set<Deviation> getDeviations() {
-            return deviations;
-        }
-
-        private void setDeviations(Set<Deviation> deviations) {
-            this.deviations = deviations;
-        }
-
-        @Override
-        public Set<DataSchemaNode> getChildNodes() {
-            return new HashSet<DataSchemaNode>(childNodes.values());
-        }
-
-        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
-            this.childNodes = childNodes;
-        }
-
-        @Override
-        public Set<GroupingDefinition> getGroupings() {
-            return groupings;
-        }
-
-        private void setGroupings(Set<GroupingDefinition> groupings) {
-            this.groupings = groupings;
-        }
-
-        @Override
-        public Set<UsesNode> getUses() {
-            return uses;
-        }
-
-        private void setUses(Set<UsesNode> uses) {
-            this.uses = uses;
-        }
-
-        @Override
-        public List<ExtensionDefinition> getExtensionSchemaNodes() {
-            return extensionSchemaNodes;
-        }
-
-        private void setExtensionSchemaNodes(List<ExtensionDefinition> extensionSchemaNodes) {
-            if(extensionSchemaNodes != null) {
-                this.extensionSchemaNodes = extensionSchemaNodes;
-            }
-        }
-
-        @Override
-        public DataSchemaNode getDataChildByName(QName name) {
-            return childNodes.get(name);
-        }
-
-        @Override
-        public DataSchemaNode getDataChildByName(String name) {
-            DataSchemaNode result = null;
-            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
-                if (entry.getKey().getLocalName().equals(name)) {
-                    result = entry.getValue();
-                    break;
-                }
-            }
-            return result;
-        }
-
-        @Override
-        public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
-            result = prime * result + ((name == null) ? 0 : name.hashCode());
-            result = prime * result + ((revision == null) ? 0 : revision.hashCode());
-            result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
-            result = prime * result + ((yangVersion == null) ? 0 : yangVersion.hashCode());
-            result = prime * result + ((description == null) ? 0 : description.hashCode());
-            result = prime * result + ((reference == null) ? 0 : reference.hashCode());
-
-            result = prime * result + ((organization == null) ? 0 : organization.hashCode());
-            result = prime * result + ((contact == null) ? 0 : contact.hashCode());
-            result = prime * result + ((imports == null) ? 0 : imports.hashCode());
-            result = prime * result + ((features == null) ? 0 : features.hashCode());
-            result = prime * result + ((typeDefinitions == null) ? 0 : typeDefinitions.hashCode());
-            result = prime * result + ((notifications == null) ? 0 : notifications.hashCode());
-            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
-            result = prime * result + ((rpcs == null) ? 0 : rpcs.hashCode());
-            result = prime * result + ((deviations == null) ? 0 : deviations.hashCode());
-            result = prime * result + ((childNodes == null) ? 0 : childNodes.hashCode());
-            result = prime * result + ((groupings == null) ? 0 : groupings.hashCode());
-            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
-            return result;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null) {
-                return false;
-            }
-            if (getClass() != obj.getClass()) {
-                return false;
-            }
-            ModuleImpl other = (ModuleImpl) obj;
-            if (namespace == null) {
-                if (other.namespace != null) {
-                    return false;
-                }
-            } else if (!namespace.equals(other.namespace)) {
-                return false;
-            }
-            if (name == null) {
-                if (other.name != null) {
-                    return false;
-                }
-            } else if (!name.equals(other.name)) {
-                return false;
-            }
-            if (revision == null) {
-                if (other.revision != null) {
-                    return false;
-                }
-            } else if (!revision.equals(other.revision)) {
-                return false;
-            }
-            if (prefix == null) {
-                if (other.prefix != null) {
-                    return false;
-                }
-            } else if (!prefix.equals(other.prefix)) {
-                return false;
-            }
-            if (yangVersion == null) {
-                if (other.yangVersion != null) {
-                    return false;
-                }
-            } else if (!yangVersion.equals(other.yangVersion)) {
-                return false;
-            }
-            if (description == null) {
-                if (other.description != null) {
-                    return false;
-                }
-            } else if (!description.equals(other.description)) {
-                return false;
-            }
-            if (reference == null) {
-                if (other.reference != null) {
-                    return false;
-                }
-            } else if (!reference.equals(other.reference)) {
-                return false;
-            }
-            if (organization == null) {
-                if (other.organization != null) {
-                    return false;
-                }
-            } else if (!organization.equals(other.organization)) {
-                return false;
-            }
-            if (contact == null) {
-                if (other.contact != null) {
-                    return false;
-                }
-            } else if (!contact.equals(other.contact)) {
-                return false;
-            }
-            if (imports == null) {
-                if (other.imports != null) {
-                    return false;
-                }
-            } else if (!imports.equals(other.imports)) {
-                return false;
-            }
-            if (features == null) {
-                if (other.features != null) {
-                    return false;
-                }
-            } else if (!features.equals(other.features)) {
-                return false;
-            }
-            if (typeDefinitions == null) {
-                if (other.typeDefinitions != null) {
-                    return false;
-                }
-            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
-                return false;
-            }
-            if (notifications == null) {
-                if (other.notifications != null) {
-                    return false;
-                }
-            } else if (!notifications.equals(other.notifications)) {
-                return false;
-            }
-            if (augmentations == null) {
-                if (other.augmentations != null) {
-                    return false;
-                }
-            } else if (!augmentations.equals(other.augmentations)) {
-                return false;
-            }
-            if (rpcs == null) {
-                if (other.rpcs != null) {
-                    return false;
-                }
-            } else if (!rpcs.equals(other.rpcs)) {
-                return false;
-            }
-            if (deviations == null) {
-                if (other.deviations != null) {
-                    return false;
-                }
-            } else if (!deviations.equals(other.deviations)) {
-                return false;
-            }
-            if (childNodes == null) {
-                if (other.childNodes != null) {
-                    return false;
-                }
-            } else if (!childNodes.equals(other.childNodes)) {
-                return false;
-            }
-            if (groupings == null) {
-                if (other.groupings != null) {
-                    return false;
-                }
-            } else if (!groupings.equals(other.groupings)) {
-                return false;
-            }
-            if (uses == null) {
-                if (other.uses != null) {
-                    return false;
-                }
-            } else if (!uses.equals(other.uses)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder(
-                    ModuleImpl.class.getSimpleName());
-            sb.append("[\n");
-            sb.append("name=" + name + ",\n");
-            sb.append("namespace=" + namespace + ",\n");
-            sb.append("revision=" + revision + ",\n");
-            sb.append("prefix=" + prefix + ",\n");
-            sb.append("yangVersion=" + yangVersion + ",\n");
-            sb.append("description=" + description + ",\n");
-            sb.append("reference=" + reference + ",\n");
-            sb.append("organization=" + organization + ",\n");
-            sb.append("contact=" + contact + ",\n");
-            sb.append("childNodes=" + childNodes.values() + ",\n");
-            sb.append("groupings=" + groupings + ",\n");
-            sb.append("imports=" + imports + ",\n");
-            sb.append("features=" + features + ",\n");
-            sb.append("typeDefinitions=" + typeDefinitions + ",\n");
-            sb.append("notifications=" + notifications + ",\n");
-            sb.append("augmentations=" + augmentations + ",\n");
-            sb.append("rpcs=" + rpcs + ",\n");
-            sb.append("deviations=" + deviations + "\n");
-            sb.append("uses=" + uses + "\n");
-            sb.append("]");
-            return sb.toString();
-        }
-    }
-
-    private ModuleImport createModuleImport(final String moduleName,
-            final Date revision, final String prefix) {
-        ModuleImport moduleImport = new ModuleImport() {
-            @Override
-            public String getModuleName() {
-                return moduleName;
-            }
-
-            @Override
-            public Date getRevision() {
-                return revision;
-            }
-
-            @Override
-            public String getPrefix() {
-                return prefix;
-            }
-
-            @Override
-            public int hashCode() {
-                final int prime = 31;
-                int result = 1;
-                result = prime * result
-                        + ((moduleName == null) ? 0 : moduleName.hashCode());
-                result = prime * result
-                        + ((revision == null) ? 0 : revision.hashCode());
-                result = prime * result
-                        + ((prefix == null) ? 0 : prefix.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;
-                }
-                ModuleImport other = (ModuleImport) obj;
-                if (getModuleName() == null) {
-                    if (other.getModuleName() != null) {
-                        return false;
-                    }
-                } else if (!getModuleName().equals(other.getModuleName())) {
-                    return false;
-                }
-                if (getRevision() == null) {
-                    if (other.getRevision() != null) {
-                        return false;
-                    }
-                } else if (!getRevision().equals(other.getRevision())) {
-                    return false;
-                }
-                if (getPrefix() == null) {
-                    if (other.getPrefix() != null) {
-                        return false;
-                    }
-                } else if (!getPrefix().equals(other.getPrefix())) {
-                    return false;
-                }
-                return true;
-            }
-
-            @Override
-            public String toString() {
-                return "ModuleImport[moduleName=" + moduleName + ", revision="
-                        + revision + ", prefix=" + prefix + "]";
-            }
-        };
-        return moduleImport;
-    }
-
-    /**
-     * Traverse through given addedChilds and add only direct module childs.
-     * Direct module child path size is 2 (1. module name, 2. child name).
-     *
-     * @param addedChilds
-     * @return map of children, where key is child QName and value is child
-     *         itself
-     */
-    private Map<QName, DataSchemaNode> buildModuleChildNodes(
-            Map<List<String>, DataSchemaNodeBuilder> addedChilds) {
-        final Map<QName, DataSchemaNode> childNodes = new HashMap<QName, DataSchemaNode>();
-        for (Map.Entry<List<String>, DataSchemaNodeBuilder> entry : addedChilds
-                .entrySet()) {
-            if (entry.getKey().size() == 2) {
-                DataSchemaNode node = entry.getValue().build();
-                QName qname = entry.getValue().getQName();
-                childNodes.put(qname, node);
-            }
-        }
-        return childNodes;
-    }
-
-    /**
-     * Traverse through given addedGroupings and add only direct module
-     * groupings. Direct module grouping path size is 2 (1. module name, 2.
-     * grouping name).
-     *
-     * @param addedGroupings
-     * @return set of built GroupingDefinition objects
-     */
-    private Set<GroupingDefinition> buildModuleGroupings(
-            Map<List<String>, GroupingBuilder> addedGroupings) {
-        final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
-        for (Map.Entry<List<String>, GroupingBuilder> entry : addedGroupings
-                .entrySet()) {
-            if (entry.getKey().size() == 2) {
-                groupings.add(entry.getValue().build());
-            }
-        }
-        return groupings;
-    }
-
-    /**
-     * Traverse through given addedRpcs and build RpcDefinition objects.
-     *
-     * @param addedRpcs
-     * @return set of built RpcDefinition objects
-     */
-    private Set<RpcDefinition> buildModuleRpcs(
-            Map<List<String>, RpcDefinitionBuilder> addedRpcs) {
-        final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();
-        RpcDefinitionBuilder builder;
-        for (Map.Entry<List<String>, RpcDefinitionBuilder> entry : addedRpcs
-                .entrySet()) {
-            builder = entry.getValue();
-            RpcDefinition rpc = builder.build();
-            rpcs.add(rpc);
-        }
-        return rpcs;
-    }
-
-    /**
-     * Traverse through given addedTypedefs and add only direct module typedef
-     * statements. Direct module typedef path size is 2 (1. module name, 2.
-     * typedef name).
-     *
-     * @param addedTypedefs
-     * @return set of built module typedef statements
-     */
-    private Set<TypeDefinition<?>> buildModuleTypedefs(
-            Map<List<String>, TypeDefinitionBuilder> addedTypedefs) {
-        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
-        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs
-                .entrySet()) {
-            if (entry.getKey().size() == 2) {
-                TypeDefinition<? extends TypeDefinition<?>> node = entry
-                        .getValue().build();
-                typedefs.add(node);
-            }
-        }
-        return typedefs;
-    }
-
-    /**
-     * Traverse through given addedUsesNodes and add only direct module uses
-     * nodes. Direct module uses node path size is 2 (1. module name, 2. uses
-     * name).
-     *
-     * @param addedUsesNodes
-     * @return set of built module uses nodes
-     */
-    private Set<UsesNode> buildUsesNodes(
-            Map<List<String>, UsesNodeBuilder> addedUsesNodes) {
-        final Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();
-        for (Map.Entry<List<String>, UsesNodeBuilder> entry : addedUsesNodes
-                .entrySet()) {
-            if (entry.getKey().size() == 2) {
-                usesNodeDefinitions.add(entry.getValue().build());
-            }
-        }
-        return usesNodeDefinitions;
-    }
-
-    /**
-     * Traverse through given addedFeatures and add only direct module features.
-     * Direct module feature path size is 2 (1. module name, 2. feature name).
-     *
-     * @param addedFeatures
-     * @return set of built module features
-     */
-    private Set<FeatureDefinition> buildModuleFeatures(
-            Map<List<String>, FeatureBuilder> addedFeatures) {
-        Set<FeatureDefinition> features = new HashSet<FeatureDefinition>();
-        for (Map.Entry<List<String>, FeatureBuilder> entry : addedFeatures
-                .entrySet()) {
-            if (entry.getKey().size() == 2) {
-                features.add(entry.getValue().build());
-            }
-        }
-        return features;
-    }
-
-}
+/*\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.parser.builder.impl;\r
+\r
+import java.net.URI;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
+import org.opendaylight.controller.yang.model.api.Deviation;\r
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.FeatureDefinition;\r
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
+import org.opendaylight.controller.yang.model.api.Module;\r
+import org.opendaylight.controller.yang.model.api.ModuleImport;\r
+import org.opendaylight.controller.yang.model.api.NotificationDefinition;\r
+import org.opendaylight.controller.yang.model.api.RpcDefinition;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+import org.opendaylight.controller.yang.model.api.UsesNode;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.ChildNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;\r
+\r
+/**\r
+ * This builder builds Module object. If this module is dependent on external\r
+ * module/modules, these dependencies must be resolved before module is built,\r
+ * otherwise result may not be valid.\r
+ */\r
+public class ModuleBuilder implements Builder {\r
+\r
+    private final ModuleImpl instance;\r
+    private final String name;\r
+    private String prefix;\r
+    private Date revision;\r
+\r
+    private final Set<ModuleImport> imports = new HashSet<ModuleImport>();\r
+    private Set<AugmentationSchema> augmentations;\r
+\r
+    /**\r
+     * All nodes, that can contain other nodes\r
+     */\r
+    private final Map<List<String>, Builder> moduleNodes = new HashMap<List<String>, Builder>();\r
+\r
+    /**\r
+     * Holds all child (DataSchemaNode) nodes: anyxml, choice, case, container,\r
+     * list, leaf, leaf-list.\r
+     */\r
+    private final Map<List<String>, DataSchemaNodeBuilder> addedChilds = new HashMap<List<String>, DataSchemaNodeBuilder>();\r
+\r
+    private final Map<List<String>, GroupingBuilder> addedGroupings = new HashMap<List<String>, GroupingBuilder>();\r
+    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
+    private final Map<List<String>, UsesNodeBuilder> addedUsesNodes = new HashMap<List<String>, UsesNodeBuilder>();\r
+    private final Map<List<String>, RpcDefinitionBuilder> addedRpcs = new HashMap<List<String>, RpcDefinitionBuilder>();\r
+    private final Set<NotificationBuilder> addedNotifications = new HashSet<NotificationBuilder>();\r
+    private final Map<List<String>, FeatureBuilder> addedFeatures = new HashMap<List<String>, FeatureBuilder>();\r
+    private final Map<String, DeviationBuilder> addedDeviations = new HashMap<String, DeviationBuilder>();\r
+    private final Map<List<String>, TypeDefinitionBuilder> addedTypedefs = new HashMap<List<String>, TypeDefinitionBuilder>();\r
+    private final List<ExtensionBuilder> addedExtensions = new ArrayList<ExtensionBuilder>();\r
+\r
+    private final Map<List<String>, TypeAwareBuilder> dirtyNodes = new HashMap<List<String>, TypeAwareBuilder>();\r
+    private final Map<List<String>, UnionTypeBuilder> unionTypes = new HashMap<List<String>, UnionTypeBuilder>();\r
+\r
+    public ModuleBuilder(String name) {\r
+        this.name = name;\r
+        instance = new ModuleImpl(name);\r
+    }\r
+\r
+\r
+\r
+    /**\r
+     * Build new Module object based on this builder.\r
+     */\r
+    @Override\r
+    public Module build() {\r
+        instance.setImports(imports);\r
+\r
+        // TYPEDEFS\r
+        final Set<TypeDefinition<?>> typedefs = buildModuleTypedefs(addedTypedefs);\r
+        instance.setTypeDefinitions(typedefs);\r
+\r
+        // CHILD NODES\r
+        final Map<QName, DataSchemaNode> childNodes = buildModuleChildNodes(addedChilds);\r
+        instance.setChildNodes(childNodes);\r
+\r
+        // GROUPINGS\r
+        final Set<GroupingDefinition> groupings = buildModuleGroupings(addedGroupings);\r
+        instance.setGroupings(groupings);\r
+\r
+        // USES\r
+        final Set<UsesNode> usesNodeDefinitions = buildUsesNodes(addedUsesNodes);\r
+        instance.setUses(usesNodeDefinitions);\r
+\r
+        // FEATURES\r
+        final Set<FeatureDefinition> features = buildModuleFeatures(addedFeatures);\r
+        instance.setFeatures(features);\r
+\r
+        // NOTIFICATIONS\r
+        final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();\r
+        for (NotificationBuilder entry : addedNotifications) {\r
+            notifications.add((NotificationDefinition) entry.build());\r
+        }\r
+        instance.setNotifications(notifications);\r
+\r
+        // AUGMENTATIONS\r
+        instance.setAugmentations(augmentations);\r
+\r
+        // RPCs\r
+        final Set<RpcDefinition> rpcs = buildModuleRpcs(addedRpcs);\r
+        instance.setRpcs(rpcs);\r
+\r
+        // DEVIATIONS\r
+        final Set<Deviation> deviations = new HashSet<Deviation>();\r
+        for (Map.Entry<String, DeviationBuilder> entry : addedDeviations\r
+                .entrySet()) {\r
+            deviations.add(entry.getValue().build());\r
+        }\r
+        instance.setDeviations(deviations);\r
+\r
+        // EXTENSIONS\r
+        final List<ExtensionDefinition> extensions = new ArrayList<ExtensionDefinition>();\r
+        for(ExtensionBuilder b : addedExtensions) {\r
+            extensions.add(b.build());\r
+        }\r
+        instance.setExtensionSchemaNodes(extensions);\r
+\r
+        return instance;\r
+    }\r
+\r
+    public Builder getNode(List<String> path) {\r
+        return moduleNodes.get(path);\r
+    }\r
+\r
+    public Map<List<String>, TypeAwareBuilder> getDirtyNodes() {\r
+        return dirtyNodes;\r
+    }\r
+\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+    public String getPrefix() {\r
+        return prefix;\r
+    }\r
+\r
+    public Date getRevision() {\r
+        return revision;\r
+    }\r
+\r
+    public Set<AugmentationSchemaBuilder> getAddedAugments() {\r
+        return addedAugments;\r
+    }\r
+\r
+    public void addDirtyNode(List<String> path) {\r
+        List<String> dirtyNodePath = new ArrayList<String>(path);\r
+        TypeAwareBuilder nodeBuilder = (TypeAwareBuilder) moduleNodes\r
+                .get(dirtyNodePath);\r
+        dirtyNodes.put(dirtyNodePath, nodeBuilder);\r
+    }\r
+\r
+    public void setNamespace(URI namespace) {\r
+        instance.setNamespace(namespace);\r
+    }\r
+\r
+    public void setRevision(Date revision) {\r
+        this.revision = revision;\r
+        instance.setRevision(revision);\r
+    }\r
+\r
+    public void setPrefix(String prefix) {\r
+        this.prefix = prefix;\r
+        instance.setPrefix(prefix);\r
+    }\r
+\r
+    public void setYangVersion(String yangVersion) {\r
+        instance.setYangVersion(yangVersion);\r
+    }\r
+\r
+    public void setDescription(String description) {\r
+        instance.setDescription(description);\r
+    }\r
+\r
+    public void setReference(String reference) {\r
+        instance.setReference(reference);\r
+    }\r
+\r
+    public void setOrganization(String organization) {\r
+        instance.setOrganization(organization);\r
+    }\r
+\r
+    public void setContact(String contact) {\r
+        instance.setContact(contact);\r
+    }\r
+\r
+    public void setAugmentations(Set<AugmentationSchema> augmentations) {\r
+        this.augmentations = augmentations;\r
+    }\r
+\r
+    public boolean addModuleImport(final String moduleName,\r
+            final Date revision, final String prefix) {\r
+        ModuleImport moduleImport = createModuleImport(moduleName, revision,\r
+                prefix);\r
+        return imports.add(moduleImport);\r
+    }\r
+\r
+    public Set<ModuleImport> getModuleImports() {\r
+        return imports;\r
+    }\r
+\r
+    public ExtensionBuilder addExtension(QName qname) {\r
+        ExtensionBuilder builder = new ExtensionBuilder(qname);\r
+        return builder;\r
+    }\r
+\r
+    public ContainerSchemaNodeBuilder addContainerNode(QName containerName,\r
+            List<String> parentPath) {\r
+        List<String> pathToNode = new ArrayList<String>(parentPath);\r
+\r
+        ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(\r
+                containerName);\r
+\r
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes\r
+                .get(pathToNode);\r
+        if (parent != null) {\r
+            if(parent instanceof AugmentationSchemaBuilder) {\r
+                containerBuilder.setAugmenting(true);\r
+            }\r
+            parent.addChildNode(containerBuilder);\r
+        }\r
+\r
+        pathToNode.add(containerName.getLocalName());\r
+        moduleNodes.put(pathToNode, containerBuilder);\r
+        addedChilds.put(pathToNode, containerBuilder);\r
+\r
+        return containerBuilder;\r
+    }\r
+\r
+    public ListSchemaNodeBuilder addListNode(QName listName,\r
+            List<String> parentPath) {\r
+        List<String> pathToNode = new ArrayList<String>(parentPath);\r
+\r
+        ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(listName);\r
+\r
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes\r
+                .get(pathToNode);\r
+        if (parent != null) {\r
+            if(parent instanceof AugmentationSchemaBuilder) {\r
+                listBuilder.setAugmenting(true);\r
+            }\r
+            parent.addChildNode(listBuilder);\r
+        }\r
+\r
+        pathToNode.add(listName.getLocalName());\r
+        moduleNodes.put(pathToNode, listBuilder);\r
+        addedChilds.put(pathToNode, listBuilder);\r
+\r
+        return listBuilder;\r
+    }\r
+\r
+    public LeafSchemaNodeBuilder addLeafNode(QName leafName,\r
+            List<String> parentPath) {\r
+        List<String> pathToNode = new ArrayList<String>(parentPath);\r
+\r
+        LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(leafName);\r
+\r
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);\r
+        if (parent != null) {\r
+            if(parent instanceof AugmentationSchemaBuilder) {\r
+                leafBuilder.setAugmenting(true);\r
+            }\r
+            parent.addChildNode(leafBuilder);\r
+        }\r
+\r
+        pathToNode.add(leafName.getLocalName());\r
+        addedChilds.put(pathToNode, leafBuilder);\r
+        moduleNodes.put(pathToNode, leafBuilder);\r
+\r
+        return leafBuilder;\r
+    }\r
+\r
+    public LeafListSchemaNodeBuilder addLeafListNode(QName leafListName,\r
+            List<String> parentPath) {\r
+        List<String> pathToNode = new ArrayList<String>(parentPath);\r
+\r
+        LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(\r
+                leafListName);\r
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);\r
+        if (parent != null) {\r
+            if(parent instanceof AugmentationSchemaBuilder) {\r
+                leafListBuilder.setAugmenting(true);\r
+            }\r
+            parent.addChildNode(leafListBuilder);\r
+        }\r
+\r
+        pathToNode.add(leafListName.getLocalName());\r
+        addedChilds.put(pathToNode, leafListBuilder);\r
+        moduleNodes.put(pathToNode, leafListBuilder);\r
+\r
+        return leafListBuilder;\r
+    }\r
+\r
+    public GroupingBuilder addGrouping(QName qname, List<String> parentPath) {\r
+        List<String> pathToGroup = new ArrayList<String>(parentPath);\r
+\r
+        GroupingBuilder builder = new GroupingBuilderImpl(qname);\r
+        ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes.get(pathToGroup);\r
+        if (parentNodeBuilder != null) {\r
+            parentNodeBuilder.addGrouping(builder);\r
+        }\r
+\r
+        pathToGroup.add(qname.getLocalName());\r
+        moduleNodes.put(pathToGroup, builder);\r
+        addedGroupings.put(pathToGroup, builder);\r
+\r
+        return builder;\r
+    }\r
+\r
+    public AugmentationSchemaBuilder addAugment(String name,\r
+            List<String> parentPath) {\r
+        List<String> pathToAugment = new ArrayList<String>(parentPath);\r
+\r
+        AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name);\r
+\r
+        // augment can only be in 'module' or 'uses' statement\r
+        UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);\r
+        if (parent != null) {\r
+            parent.addAugment(builder);\r
+        }\r
+\r
+        pathToAugment.add(name);\r
+        moduleNodes.put(pathToAugment, builder);\r
+        addedAugments.add(builder);\r
+\r
+        return builder;\r
+    }\r
+\r
+    public UsesNodeBuilder addUsesNode(String groupingPathStr,\r
+            List<String> parentPath) {\r
+        List<String> pathToUses = new ArrayList<String>(parentPath);\r
+\r
+        UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(groupingPathStr);\r
+\r
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToUses);\r
+        if (parent != null) {\r
+            if(parent instanceof AugmentationSchemaBuilder) {\r
+                usesBuilder.setAugmenting(true);\r
+            }\r
+            parent.addUsesNode(usesBuilder);\r
+        }\r
+\r
+        pathToUses.add(groupingPathStr);\r
+        addedUsesNodes.put(pathToUses, usesBuilder);\r
+\r
+        return usesBuilder;\r
+    }\r
+\r
+    public RpcDefinitionBuilder addRpc(QName qname, List<String> parentPath) {\r
+        List<String> pathToRpc = new ArrayList<String>(parentPath);\r
+\r
+        RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);\r
+\r
+        pathToRpc.add(qname.getLocalName());\r
+        addedRpcs.put(pathToRpc, rpcBuilder);\r
+\r
+        QName inputQName = new QName(qname.getNamespace(), qname.getRevision(),\r
+                qname.getPrefix(), "input");\r
+        ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(inputQName);\r
+        List<String> pathToInput = new ArrayList<String>(pathToRpc);\r
+        pathToInput.add("input");\r
+        moduleNodes.put(pathToInput, inputBuilder);\r
+        rpcBuilder.setInput(inputBuilder);\r
+\r
+        QName outputQName = new QName(qname.getNamespace(),\r
+                qname.getRevision(), qname.getPrefix(), "output");\r
+        ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(outputQName);\r
+        List<String> pathToOutput = new ArrayList<String>(pathToRpc);\r
+        pathToOutput.add("output");\r
+        moduleNodes.put(pathToOutput, outputBuilder);\r
+        rpcBuilder.setOutput(outputBuilder);\r
+\r
+        return rpcBuilder;\r
+    }\r
+\r
+    public NotificationBuilder addNotification(QName notificationName,\r
+            List<String> parentPath) {\r
+        List<String> pathToNotification = new ArrayList<String>(parentPath);\r
+\r
+        NotificationBuilder notificationBuilder = new NotificationBuilder(\r
+                notificationName);\r
+\r
+        pathToNotification.add(notificationName.getLocalName());\r
+        moduleNodes.put(pathToNotification, notificationBuilder);\r
+        addedNotifications.add(notificationBuilder);\r
+\r
+        return notificationBuilder;\r
+    }\r
+\r
+    public FeatureBuilder addFeature(QName featureName, List<String> parentPath) {\r
+        List<String> pathToFeature = new ArrayList<String>(parentPath);\r
+        pathToFeature.add(featureName.getLocalName());\r
+\r
+        FeatureBuilder builder = new FeatureBuilder(featureName);\r
+        addedFeatures.put(pathToFeature, builder);\r
+        return builder;\r
+    }\r
+\r
+    public TypedefBuilder addTypedef(QName typeDefName, List<String> parentPath) {\r
+        List<String> pathToType = new ArrayList<String>(parentPath);\r
+        TypedefBuilder builder = new TypedefBuilder(typeDefName);\r
+        TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder) moduleNodes.get(pathToType);\r
+        if (parent != null) {\r
+            parent.addTypedef(builder);\r
+        }\r
+        pathToType.add(typeDefName.getLocalName());\r
+        addedTypedefs.put(pathToType, builder);\r
+        moduleNodes.put(pathToType, builder);\r
+        return builder;\r
+    }\r
+\r
+    public Set<TypeDefinitionBuilder> getModuleTypedefs() {\r
+        Set<TypeDefinitionBuilder> typedefs = new HashSet<TypeDefinitionBuilder>();\r
+        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs.entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                typedefs.add(entry.getValue());\r
+            }\r
+        }\r
+        return typedefs;\r
+    }\r
+\r
+    public void setType(TypeDefinition<?> type, List<String> parentPath) {\r
+        TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes.get(parentPath);\r
+        parent.setType(type);\r
+    }\r
+\r
+    public void addUnionType(List<String> parentPath) {\r
+        TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes.get(parentPath);\r
+        UnionTypeBuilder union = new UnionTypeBuilder();\r
+        parent.setType(union.build());\r
+\r
+        List<String> path = new ArrayList<String>(parentPath);\r
+        path.add("union");\r
+\r
+        unionTypes.put(path, union);\r
+        moduleNodes.put(path, union);\r
+    }\r
+\r
+    public DeviationBuilder addDeviation(String targetPath) {\r
+        DeviationBuilder builder = new DeviationBuilder(targetPath);\r
+        addedDeviations.put(targetPath, builder);\r
+        return builder;\r
+    }\r
+\r
+    public void addConfiguration(boolean configuration, List<String> parentPath) {\r
+        Builder builder = moduleNodes.get(parentPath);\r
+        if (builder instanceof DeviationBuilder) {\r
+            // skip\r
+            // TODO\r
+        } else {\r
+            DataSchemaNodeBuilder configBuilder = (DataSchemaNodeBuilder) moduleNodes.get(parentPath);\r
+            configBuilder.setConfiguration(configuration);\r
+        }\r
+    }\r
+\r
+    public UnknownSchemaNodeBuilder addUnknownSchemaNode(QName qname, List<String> parentPath) {\r
+        UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(qname);\r
+        return builder;\r
+    }\r
+\r
+\r
+    private class ModuleImpl implements Module {\r
+        private URI namespace;\r
+        private final String name;\r
+        private Date revision;\r
+        private String prefix;\r
+        private String yangVersion;\r
+        private String description;\r
+        private String reference;\r
+        private String organization;\r
+        private String contact;\r
+        private Set<ModuleImport> imports = Collections.emptySet();\r
+        private Set<FeatureDefinition> features = Collections.emptySet();\r
+        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();\r
+        private Set<NotificationDefinition> notifications = Collections.emptySet();\r
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();\r
+        private Set<RpcDefinition> rpcs = Collections.emptySet();\r
+        private Set<Deviation> deviations = Collections.emptySet();\r
+        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();\r
+        private Set<GroupingDefinition> groupings = Collections.emptySet();\r
+        private Set<UsesNode> uses = Collections.emptySet();\r
+        private List<ExtensionDefinition> extensionSchemaNodes = Collections.emptyList();\r
+\r
+        private ModuleImpl(String name) {\r
+            this.name = name;\r
+        }\r
+\r
+        @Override\r
+        public URI getNamespace() {\r
+            return namespace;\r
+        }\r
+\r
+        private void setNamespace(URI namespace) {\r
+            this.namespace = namespace;\r
+        }\r
+\r
+        @Override\r
+        public String getName() {\r
+            return name;\r
+        }\r
+\r
+        @Override\r
+        public Date getRevision() {\r
+            return revision;\r
+        }\r
+\r
+        private void setRevision(Date revision) {\r
+            this.revision = revision;\r
+        }\r
+\r
+        @Override\r
+        public String getPrefix() {\r
+            return prefix;\r
+        }\r
+\r
+        private void setPrefix(String prefix) {\r
+            this.prefix = prefix;\r
+        }\r
+\r
+        @Override\r
+        public String getYangVersion() {\r
+            return yangVersion;\r
+        }\r
+\r
+        private void setYangVersion(String yangVersion) {\r
+            this.yangVersion = yangVersion;\r
+        }\r
+\r
+        @Override\r
+        public String getDescription() {\r
+            return description;\r
+        }\r
+\r
+        private void setDescription(String description) {\r
+            this.description = description;\r
+        }\r
+\r
+        @Override\r
+        public String getReference() {\r
+            return reference;\r
+        }\r
+\r
+        private void setReference(String reference) {\r
+            this.reference = reference;\r
+        }\r
+\r
+        @Override\r
+        public String getOrganization() {\r
+            return organization;\r
+        }\r
+\r
+        private void setOrganization(String organization) {\r
+            this.organization = organization;\r
+        }\r
+\r
+        @Override\r
+        public String getContact() {\r
+            return contact;\r
+        }\r
+\r
+        private void setContact(String contact) {\r
+            this.contact = contact;\r
+        }\r
+\r
+        @Override\r
+        public Set<ModuleImport> getImports() {\r
+            return imports;\r
+        }\r
+\r
+        private void setImports(Set<ModuleImport> imports) {\r
+            if(imports != null) {\r
+                this.imports = imports;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<FeatureDefinition> getFeatures() {\r
+            return features;\r
+        }\r
+\r
+        private void setFeatures(Set<FeatureDefinition> features) {\r
+            if(features != null) {\r
+                this.features = features;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<TypeDefinition<?>> getTypeDefinitions() {\r
+            return typeDefinitions;\r
+        }\r
+\r
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
+            if(typeDefinitions != null) {\r
+                this.typeDefinitions = typeDefinitions;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<NotificationDefinition> getNotifications() {\r
+            return notifications;\r
+        }\r
+\r
+        private void setNotifications(Set<NotificationDefinition> notifications) {\r
+            if(notifications != null) {\r
+                this.notifications = notifications;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<AugmentationSchema> getAugmentations() {\r
+            return augmentations;\r
+        }\r
+\r
+        private void setAugmentations(Set<AugmentationSchema> augmentations) {\r
+            if(augmentations != null) {\r
+                this.augmentations = augmentations;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<RpcDefinition> getRpcs() {\r
+            return rpcs;\r
+        }\r
+\r
+        private void setRpcs(Set<RpcDefinition> rpcs) {\r
+            if(rpcs != null) {\r
+                this.rpcs = rpcs;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<Deviation> getDeviations() {\r
+            return deviations;\r
+        }\r
+\r
+        private void setDeviations(Set<Deviation> deviations) {\r
+            if(deviations != null) {\r
+                this.deviations = deviations;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<DataSchemaNode> getChildNodes() {\r
+            return new HashSet<DataSchemaNode>(childNodes.values());\r
+        }\r
+\r
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
+            if(childNodes != null) {\r
+                this.childNodes = childNodes;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<GroupingDefinition> getGroupings() {\r
+            return groupings;\r
+        }\r
+\r
+        private void setGroupings(Set<GroupingDefinition> groupings) {\r
+            if(groupings != null) {\r
+                this.groupings = groupings;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public Set<UsesNode> getUses() {\r
+            return uses;\r
+        }\r
+\r
+        private void setUses(Set<UsesNode> uses) {\r
+            if(uses != null) {\r
+                this.uses = uses;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+            return extensionSchemaNodes;\r
+        }\r
+\r
+        private void setExtensionSchemaNodes(List<ExtensionDefinition> extensionSchemaNodes) {\r
+            if(extensionSchemaNodes != null) {\r
+                this.extensionSchemaNodes = extensionSchemaNodes;\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public DataSchemaNode getDataChildByName(QName name) {\r
+            return childNodes.get(name);\r
+        }\r
+\r
+        @Override\r
+        public DataSchemaNode getDataChildByName(String name) {\r
+            DataSchemaNode result = null;\r
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
+                if (entry.getKey().getLocalName().equals(name)) {\r
+                    result = entry.getValue();\r
+                    break;\r
+                }\r
+            }\r
+            return result;\r
+        }\r
+\r
+        @Override\r
+        public int hashCode() {\r
+            final int prime = 31;\r
+            int result = 1;\r
+            result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());\r
+            result = prime * result + ((name == null) ? 0 : name.hashCode());\r
+            result = prime * result + ((revision == null) ? 0 : revision.hashCode());\r
+            result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());\r
+            result = prime * result + ((yangVersion == null) ? 0 : yangVersion.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
+            ModuleImpl other = (ModuleImpl) obj;\r
+            if (namespace == null) {\r
+                if (other.namespace != null) {\r
+                    return false;\r
+                }\r
+            } else if (!namespace.equals(other.namespace)) {\r
+                return false;\r
+            }\r
+            if (name == null) {\r
+                if (other.name != null) {\r
+                    return false;\r
+                }\r
+            } else if (!name.equals(other.name)) {\r
+                return false;\r
+            }\r
+            if (revision == null) {\r
+                if (other.revision != null) {\r
+                    return false;\r
+                }\r
+            } else if (!revision.equals(other.revision)) {\r
+                return false;\r
+            }\r
+            if (prefix == null) {\r
+                if (other.prefix != null) {\r
+                    return false;\r
+                }\r
+            } else if (!prefix.equals(other.prefix)) {\r
+                return false;\r
+            }\r
+            if (yangVersion == null) {\r
+                if (other.yangVersion != null) {\r
+                    return false;\r
+                }\r
+            } else if (!yangVersion.equals(other.yangVersion)) {\r
+                return false;\r
+            }\r
+            return true;\r
+        }\r
+\r
+        @Override\r
+        public String toString() {\r
+            StringBuilder sb = new StringBuilder(\r
+                    ModuleImpl.class.getSimpleName());\r
+            sb.append("[\n");\r
+            sb.append("name=" + name + ",\n");\r
+            sb.append("namespace=" + namespace + ",\n");\r
+            sb.append("revision=" + revision + ",\n");\r
+            sb.append("prefix=" + prefix + ",\n");\r
+            sb.append("yangVersion=" + yangVersion + ",\n");\r
+            sb.append("description=" + description + ",\n");\r
+            sb.append("reference=" + reference + ",\n");\r
+            sb.append("organization=" + organization + ",\n");\r
+            sb.append("contact=" + contact + ",\n");\r
+            sb.append("childNodes=" + childNodes.values() + ",\n");\r
+            sb.append("groupings=" + groupings + ",\n");\r
+            sb.append("imports=" + imports + ",\n");\r
+            sb.append("features=" + features + ",\n");\r
+            sb.append("typeDefinitions=" + typeDefinitions + ",\n");\r
+            sb.append("notifications=" + notifications + ",\n");\r
+            sb.append("augmentations=" + augmentations + ",\n");\r
+            sb.append("rpcs=" + rpcs + ",\n");\r
+            sb.append("deviations=" + deviations + "\n");\r
+            sb.append("uses=" + uses + "\n");\r
+            sb.append("]");\r
+            return sb.toString();\r
+        }\r
+    }\r
+\r
+    private ModuleImport createModuleImport(final String moduleName,\r
+            final Date revision, final String prefix) {\r
+        ModuleImport moduleImport = new ModuleImport() {\r
+            @Override\r
+            public String getModuleName() {\r
+                return moduleName;\r
+            }\r
+\r
+            @Override\r
+            public Date getRevision() {\r
+                return revision;\r
+            }\r
+\r
+            @Override\r
+            public String getPrefix() {\r
+                return prefix;\r
+            }\r
+\r
+            @Override\r
+            public int hashCode() {\r
+                final int prime = 31;\r
+                int result = 1;\r
+                result = prime * result\r
+                        + ((moduleName == null) ? 0 : moduleName.hashCode());\r
+                result = prime * result\r
+                        + ((revision == null) ? 0 : revision.hashCode());\r
+                result = prime * result\r
+                        + ((prefix == null) ? 0 : prefix.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
+                ModuleImport other = (ModuleImport) obj;\r
+                if (getModuleName() == null) {\r
+                    if (other.getModuleName() != null) {\r
+                        return false;\r
+                    }\r
+                } else if (!getModuleName().equals(other.getModuleName())) {\r
+                    return false;\r
+                }\r
+                if (getRevision() == null) {\r
+                    if (other.getRevision() != null) {\r
+                        return false;\r
+                    }\r
+                } else if (!getRevision().equals(other.getRevision())) {\r
+                    return false;\r
+                }\r
+                if (getPrefix() == null) {\r
+                    if (other.getPrefix() != null) {\r
+                        return false;\r
+                    }\r
+                } else if (!getPrefix().equals(other.getPrefix())) {\r
+                    return false;\r
+                }\r
+                return true;\r
+            }\r
+\r
+            @Override\r
+            public String toString() {\r
+                return "ModuleImport[moduleName=" + moduleName + ", revision="\r
+                        + revision + ", prefix=" + prefix + "]";\r
+            }\r
+        };\r
+        return moduleImport;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedChilds and add only direct module childs.\r
+     * Direct module child path size is 2 (1. module name, 2. child name).\r
+     *\r
+     * @param addedChilds\r
+     * @return map of children, where key is child QName and value is child\r
+     *         itself\r
+     */\r
+    private Map<QName, DataSchemaNode> buildModuleChildNodes(\r
+            Map<List<String>, DataSchemaNodeBuilder> addedChilds) {\r
+        final Map<QName, DataSchemaNode> childNodes = new HashMap<QName, DataSchemaNode>();\r
+        for (Map.Entry<List<String>, DataSchemaNodeBuilder> entry : addedChilds\r
+                .entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                DataSchemaNode node = entry.getValue().build();\r
+                QName qname = entry.getValue().getQName();\r
+                childNodes.put(qname, node);\r
+            }\r
+        }\r
+        return childNodes;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedGroupings and add only direct module\r
+     * groupings. Direct module grouping path size is 2 (1. module name, 2.\r
+     * grouping name).\r
+     *\r
+     * @param addedGroupings\r
+     * @return set of built GroupingDefinition objects\r
+     */\r
+    private Set<GroupingDefinition> buildModuleGroupings(\r
+            Map<List<String>, GroupingBuilder> addedGroupings) {\r
+        final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();\r
+        for (Map.Entry<List<String>, GroupingBuilder> entry : addedGroupings\r
+                .entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                groupings.add(entry.getValue().build());\r
+            }\r
+        }\r
+        return groupings;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedRpcs and build RpcDefinition objects.\r
+     *\r
+     * @param addedRpcs\r
+     * @return set of built RpcDefinition objects\r
+     */\r
+    private Set<RpcDefinition> buildModuleRpcs(\r
+            Map<List<String>, RpcDefinitionBuilder> addedRpcs) {\r
+        final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();\r
+        RpcDefinitionBuilder builder;\r
+        for (Map.Entry<List<String>, RpcDefinitionBuilder> entry : addedRpcs\r
+                .entrySet()) {\r
+            builder = entry.getValue();\r
+            RpcDefinition rpc = builder.build();\r
+            rpcs.add(rpc);\r
+        }\r
+        return rpcs;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedTypedefs and add only direct module typedef\r
+     * statements. Direct module typedef path size is 2 (1. module name, 2.\r
+     * typedef name).\r
+     *\r
+     * @param addedTypedefs\r
+     * @return set of built module typedef statements\r
+     */\r
+    private Set<TypeDefinition<?>> buildModuleTypedefs(\r
+            Map<List<String>, TypeDefinitionBuilder> addedTypedefs) {\r
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
+        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs\r
+                .entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                TypeDefinition<? extends TypeDefinition<?>> node = entry\r
+                        .getValue().build();\r
+                typedefs.add(node);\r
+            }\r
+        }\r
+        return typedefs;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedUsesNodes and add only direct module uses\r
+     * nodes. Direct module uses node path size is 2 (1. module name, 2. uses\r
+     * name).\r
+     *\r
+     * @param addedUsesNodes\r
+     * @return set of built module uses nodes\r
+     */\r
+    private Set<UsesNode> buildUsesNodes(\r
+            Map<List<String>, UsesNodeBuilder> addedUsesNodes) {\r
+        final Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();\r
+        for (Map.Entry<List<String>, UsesNodeBuilder> entry : addedUsesNodes\r
+                .entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                usesNodeDefinitions.add(entry.getValue().build());\r
+            }\r
+        }\r
+        return usesNodeDefinitions;\r
+    }\r
+\r
+    /**\r
+     * Traverse through given addedFeatures and add only direct module features.\r
+     * Direct module feature path size is 2 (1. module name, 2. feature name).\r
+     *\r
+     * @param addedFeatures\r
+     * @return set of built module features\r
+     */\r
+    private Set<FeatureDefinition> buildModuleFeatures(\r
+            Map<List<String>, FeatureBuilder> addedFeatures) {\r
+        Set<FeatureDefinition> features = new HashSet<FeatureDefinition>();\r
+        for (Map.Entry<List<String>, FeatureBuilder> entry : addedFeatures\r
+                .entrySet()) {\r
+            if (entry.getKey().size() == 2) {\r
+                features.add(entry.getValue().build());\r
+            }\r
+        }\r
+        return features;\r
+    }\r
+\r
+}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnionTypeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnionTypeBuilder.java
new file mode 100644 (file)
index 0000000..265c94d
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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.parser.builder.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.model.util.UnionType;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+
+public class UnionTypeBuilder implements TypeAwareBuilder, TypeDefinitionBuilder, Builder {
+
+    private final List<TypeDefinition<?>> types;
+    private final List<TypeDefinitionBuilder> typedefs;
+    private final UnionType instance;
+
+    public UnionTypeBuilder() {
+        types = new ArrayList<TypeDefinition<?>>();
+        typedefs = new ArrayList<TypeDefinitionBuilder>();
+        instance = new UnionType(types);
+    }
+
+    public List<TypeDefinition<?>> getTypes() {
+        return types;
+    }
+
+    @Override
+    public TypeDefinition<?> getType() {
+        return instance;
+    }
+
+    @Override
+    public void setType(TypeDefinition<?> type) {
+        types.add(type);
+    }
+
+    public void addType(TypeDefinitionBuilder tdb) {
+        typedefs.add(tdb);
+    }
+
+    @Override
+    public UnionType build() {
+        for(TypeDefinitionBuilder tdb : typedefs) {
+            types.add(tdb.build());
+        }
+        return instance;
+    }
+
+    @Override
+    public QName getQName() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public TypeDefinition<?> getBaseType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setUnits(String units) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setDefaultValue(Object defaultValue) {
+        // TODO Auto-generated method stub
+
+    }
+
+}
index d7c6711affb740de272f754e76e331561782f8ba..fe02e141eda433a19523066d748fda9dfa5b9280 100644 (file)
@@ -9,7 +9,9 @@ package org.opendaylight.controller.yang.model.parser.impl;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -61,6 +63,7 @@ import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeB
 import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.UnionTypeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -71,14 +74,22 @@ public class YangModelParserImpl implements YangModelParser {
 
     @Override
     public Module parseYangModel(String yangFile) {
-        final Map<String, TreeMap<Date, ModuleBuilder>> modules = loadFiles(yangFile);
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuildersFromStreams(yangFile);
         Set<Module> result = build(modules);
         return result.iterator().next();
     }
 
     @Override
     public Set<Module> parseYangModels(String... yangFiles) {
-        final Map<String, TreeMap<Date, ModuleBuilder>> modules = loadFiles(yangFiles);
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuildersFromStreams(yangFiles);
+        Set<Module> result = build(modules);
+        return result;
+    }
+
+    @Override
+    public Set<Module> parseYangModelsFromStreams(
+            InputStream... yangModelStreams) {
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuildersFromStreams(yangModelStreams);
         Set<Module> result = build(modules);
         return result;
     }
@@ -88,14 +99,31 @@ public class YangModelParserImpl implements YangModelParser {
         return new SchemaContextImpl(modules);
     }
 
-    private Map<String, TreeMap<Date, ModuleBuilder>> loadFiles(
+    private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuildersFromStreams(
             String... yangFiles) {
+        InputStream[] streams = new InputStream[yangFiles.length];
+        for(int i = 0; i < yangFiles.length; i++) {
+            final String yangFileName = yangFiles[i];
+            final File yangFile = new File(yangFileName);
+            FileInputStream inStream = null;
+            try {
+                inStream = new FileInputStream(yangFile);
+            } catch(FileNotFoundException e) {
+                logger.warn("Exception while reading yang stream: " + inStream, e);
+            }
+            streams[i] = inStream;
+        }
+        return resolveModuleBuildersFromStreams(streams);
+    }
+
+    private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuildersFromStreams(
+            InputStream... yangFiles) {
         final Map<String, TreeMap<Date, ModuleBuilder>> modules = new HashMap<String, TreeMap<Date, ModuleBuilder>>();
 
         final YangModelParserListenerImpl yangModelParser = new YangModelParserListenerImpl();
         final ParseTreeWalker walker = new ParseTreeWalker();
 
-        List<ParseTree> trees = parseFiles(yangFiles);
+        List<ParseTree> trees = parseStreams(yangFiles);
 
         ModuleBuilder[] builders = new ModuleBuilder[trees.size()];
 
@@ -123,26 +151,24 @@ public class YangModelParserImpl implements YangModelParser {
         return modules;
     }
 
-    private List<ParseTree> parseFiles(String... yangFileNames) {
+    private List<ParseTree> parseStreams(InputStream... yangStreams) {
         List<ParseTree> trees = new ArrayList<ParseTree>();
-        for (String fileName : yangFileNames) {
-            trees.add(parseFile(fileName));
+        for (InputStream yangStream : yangStreams) {
+            trees.add(parseStream(yangStream));
         }
         return trees;
     }
 
-    private ParseTree parseFile(String yangFileName) {
+    private ParseTree parseStream(InputStream yangStream) {
         ParseTree result = null;
         try {
-            final File yangFile = new File(yangFileName);
-            final FileInputStream inStream = new FileInputStream(yangFile);
-            final ANTLRInputStream input = new ANTLRInputStream(inStream);
+            final ANTLRInputStream input = new ANTLRInputStream(yangStream);
             final YangLexer lexer = new YangLexer(input);
             final CommonTokenStream tokens = new CommonTokenStream(lexer);
             final YangParser parser = new YangParser(tokens);
             result = parser.yang();
         } catch (IOException e) {
-            logger.warn("Exception while reading yang file: " + yangFileName, e);
+            logger.warn("Exception while reading yang file: " + yangStream, e);
         }
         return result;
     }
@@ -187,13 +213,13 @@ public class YangModelParserImpl implements YangModelParser {
      *
      * @param modules
      *            all available modules
-     * @param builder
+     * @param module
      *            current module
      */
     private void resolveTypedefs(
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            ModuleBuilder builder) {
-        Map<List<String>, TypeAwareBuilder> dirtyNodes = builder
+            ModuleBuilder module) {
+        Map<List<String>, TypeAwareBuilder> dirtyNodes = module
                 .getDirtyNodes();
         if (dirtyNodes.size() == 0) {
             return;
@@ -201,131 +227,165 @@ public class YangModelParserImpl implements YangModelParser {
             for (Map.Entry<List<String>, TypeAwareBuilder> entry : dirtyNodes
                     .entrySet()) {
                 TypeAwareBuilder typeToResolve = entry.getValue();
-                Map<TypeDefinitionBuilder, TypeConstraints> foundedTypeDefinitionBuilder = findTypeDefinitionBuilderWithConstraints(
-                        modules, entry.getValue(), builder);
-                TypeDefinitionBuilder targetType = foundedTypeDefinitionBuilder
-                        .entrySet().iterator().next().getKey();
-                TypeConstraints constraints = foundedTypeDefinitionBuilder
-                        .entrySet().iterator().next().getValue();
-
-                UnknownType ut = (UnknownType) typeToResolve.getType();
-
-                // RANGE
-                List<RangeConstraint> ranges = ut.getRangeStatements();
-                resolveRanges(ranges, typeToResolve, targetType, modules,
-                        builder);
 
-                // LENGTH
-                List<LengthConstraint> lengths = ut.getLengthStatements();
-                resolveLengths(lengths, typeToResolve, targetType, modules,
-                        builder);
-
-                // PATTERN
-                List<PatternConstraint> patterns = ut.getPatterns();
-
-                // Fraction Digits
-                Integer fractionDigits = ut.getFractionDigits();
-
-                TypeDefinition<?> type = targetType.getBaseType();
-                String typeName = type.getQName().getLocalName();
-
-                // MERGE CONSTRAINTS (enumeration and leafref omitted because
-                // they have no restrictions)
-                if (type instanceof DecimalTypeDefinition) {
-                    List<RangeConstraint> fullRanges = new ArrayList<RangeConstraint>();
-                    fullRanges.addAll(constraints.getRanges());
-                    fullRanges.addAll(ranges);
-                    Integer fd = fractionDigits == null ? constraints
-                            .getFractionDigits() : fractionDigits;
-                    type = YangTypesConverter.javaTypeForBaseYangDecimal64Type(
-                            fullRanges, fd);
-                } else if (type instanceof IntegerTypeDefinition) {
-                    List<RangeConstraint> fullRanges = new ArrayList<RangeConstraint>();
-                    fullRanges.addAll(constraints.getRanges());
-                    fullRanges.addAll(ranges);
-                    if (typeName.startsWith("int")) {
-                        type = YangTypesConverter
-                                .javaTypeForBaseYangSignedIntegerType(typeName,
-                                        fullRanges);
-                    } else {
-                        type = YangTypesConverter
-                                .javaTypeForBaseYangUnsignedIntegerType(
-                                        typeName, fullRanges);
-                    }
-                } else if (type instanceof StringTypeDefinition) {
-                    List<LengthConstraint> fullLengths = new ArrayList<LengthConstraint>();
-                    fullLengths.addAll(constraints.getLengths());
-                    fullLengths.addAll(lengths);
-                    List<PatternConstraint> fullPatterns = new ArrayList<PatternConstraint>();
-                    fullPatterns.addAll(constraints.getPatterns());
-                    fullPatterns.addAll(patterns);
-                    type = new StringType(fullLengths, fullPatterns);
-                } else if (type instanceof BitsTypeDefinition) {
-                    // TODO: add 'length' restriction to BitsType
-                    BitsTypeDefinition bitsType = (BitsTypeDefinition) type;
-                    List<Bit> bits = bitsType.getBits();
-                    type = new BitsType(bits);
-                } else if (type instanceof BinaryTypeDefinition) {
-                    type = new BinaryType(null, lengths, null);
-                } else if (typeName.equals("instance-identifier")) {
-                    // TODO: instance-identifier
-                    /*
-                     * boolean requireInstance = isRequireInstance(typeBody);
-                     * type = new InstanceIdentifier(null, requireInstance);
-                     */
+                if (typeToResolve instanceof UnionTypeBuilder) {
+                    resolveUnionTypeBuilder(modules, module,
+                            (UnionTypeBuilder) typeToResolve);
+                } else {
+                    UnknownType ut = (UnknownType) typeToResolve.getType();
+                    TypeDefinition<?> resolvedType = findTargetType(ut,
+                            modules, module);
+                    typeToResolve.setType(resolvedType);
                 }
-                typeToResolve.setType(type);
             }
         }
     }
 
+    private UnionTypeBuilder resolveUnionTypeBuilder(
+            Map<String, TreeMap<Date, ModuleBuilder>> modules,
+            ModuleBuilder builder, UnionTypeBuilder unionTypeBuilderToResolve) {
+
+        List<TypeDefinition<?>> resolvedTypes = new ArrayList<TypeDefinition<?>>();
+        List<TypeDefinition<?>> typesToRemove = new ArrayList<TypeDefinition<?>>();
+
+        for (TypeDefinition<?> td : unionTypeBuilderToResolve.getTypes()) {
+            if (td instanceof UnknownType) {
+                TypeDefinition<?> resolvedType = findTargetType(
+                        (UnknownType) td, modules, builder);
+                resolvedTypes.add(resolvedType);
+                typesToRemove.add(td);
+            }
+        }
+
+        List<TypeDefinition<?>> unionTypeBuilderTypes = unionTypeBuilderToResolve
+                .getTypes();
+        unionTypeBuilderTypes.addAll(resolvedTypes);
+        unionTypeBuilderTypes.removeAll(typesToRemove);
+
+        return unionTypeBuilderToResolve;
+    }
+
+    private TypeDefinition<?> findTargetType(UnknownType ut,
+            Map<String, TreeMap<Date, ModuleBuilder>> modules,
+            ModuleBuilder builder) {
+
+        Map<TypeDefinitionBuilder, TypeConstraints> foundedTypeDefinitionBuilder = findTypeDefinitionBuilderWithConstraints(
+                modules, ut, builder);
+        TypeDefinitionBuilder targetType = foundedTypeDefinitionBuilder
+                .entrySet().iterator().next().getKey();
+        TypeConstraints constraints = foundedTypeDefinitionBuilder.entrySet()
+                .iterator().next().getValue();
+
+        TypeDefinition<?> targetTypeBaseType = targetType.getBaseType();
+        String targetTypeBaseTypeName = targetTypeBaseType.getQName()
+                .getLocalName();
+
+        // RANGE
+        List<RangeConstraint> ranges = ut.getRangeStatements();
+        resolveRanges(ranges, targetType, modules, builder);
+
+        // LENGTH
+        List<LengthConstraint> lengths = ut.getLengthStatements();
+        resolveLengths(lengths, targetType, modules, builder);
+
+        // PATTERN
+        List<PatternConstraint> patterns = ut.getPatterns();
+
+        // Fraction Digits
+        Integer fractionDigits = ut.getFractionDigits();
+
+        // MERGE CONSTRAINTS (enumeration and leafref omitted
+        // because
+        // they have no restrictions)
+        if (targetTypeBaseType instanceof DecimalTypeDefinition) {
+            List<RangeConstraint> fullRanges = new ArrayList<RangeConstraint>();
+            fullRanges.addAll(constraints.getRanges());
+            fullRanges.addAll(ranges);
+            Integer fd = fractionDigits == null ? constraints
+                    .getFractionDigits() : fractionDigits;
+            targetTypeBaseType = YangTypesConverter
+                    .javaTypeForBaseYangDecimal64Type(fullRanges, fd);
+        } else if (targetTypeBaseType instanceof IntegerTypeDefinition) {
+            List<RangeConstraint> fullRanges = new ArrayList<RangeConstraint>();
+            fullRanges.addAll(constraints.getRanges());
+            fullRanges.addAll(ranges);
+            if (targetTypeBaseTypeName.startsWith("int")) {
+                targetTypeBaseType = YangTypesConverter
+                        .javaTypeForBaseYangSignedIntegerType(
+                                targetTypeBaseTypeName, fullRanges);
+            } else {
+                targetTypeBaseType = YangTypesConverter
+                        .javaTypeForBaseYangUnsignedIntegerType(
+                                targetTypeBaseTypeName, fullRanges);
+            }
+        } else if (targetTypeBaseType instanceof StringTypeDefinition) {
+            List<LengthConstraint> fullLengths = new ArrayList<LengthConstraint>();
+            fullLengths.addAll(constraints.getLengths());
+            fullLengths.addAll(lengths);
+            List<PatternConstraint> fullPatterns = new ArrayList<PatternConstraint>();
+            fullPatterns.addAll(constraints.getPatterns());
+            fullPatterns.addAll(patterns);
+            targetTypeBaseType = new StringType(fullLengths, fullPatterns);
+        } else if (targetTypeBaseType instanceof BitsTypeDefinition) {
+            BitsTypeDefinition bitsType = (BitsTypeDefinition) targetTypeBaseType;
+            List<Bit> bits = bitsType.getBits();
+            targetTypeBaseType = new BitsType(bits);
+        } else if (targetTypeBaseType instanceof BinaryTypeDefinition) {
+            targetTypeBaseType = new BinaryType(null, lengths, null);
+        } else if (targetTypeBaseTypeName.equals("instance-identifier")) {
+            // TODO: instance-identifier
+            /*
+             * boolean requireInstance = isRequireInstance(typeBody); type = new
+             * InstanceIdentifier(null, requireInstance);
+             */
+        }
+
+        return targetTypeBaseType;
+    }
+
     private TypeDefinitionBuilder findTypeDefinitionBuilder(
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            TypeAwareBuilder typeBuilder, ModuleBuilder builder) {
+            UnknownType unknownType, ModuleBuilder builder) {
         Map<TypeDefinitionBuilder, TypeConstraints> result = findTypeDefinitionBuilderWithConstraints(
-                modules, typeBuilder, builder);
+                modules, unknownType, builder);
         return result.entrySet().iterator().next().getKey();
     }
 
     private Map<TypeDefinitionBuilder, TypeConstraints> findTypeDefinitionBuilderWithConstraints(
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            TypeAwareBuilder typeBuilder, ModuleBuilder builder) {
+            UnknownType unknownType, ModuleBuilder builder) {
         return findTypeDefinitionBuilderWithConstraints(new TypeConstraints(),
-                modules, typeBuilder, builder);
+                modules, unknownType, builder);
     }
 
     /**
      * Traverse through all referenced types chain until base YANG type is
      * founded.
      *
-     * @param constraints
-     *            current type constraints
-     * @param modules
-     *            all available modules
-     * @param typeBuilder
-     *            type builder which contains type
-     * @param builder
-     *            current module
+     * @param constraints current type constraints
+     * @param modules all available modules
+     * @param unknownType unknown type
+     * @param builder current module
      * @return map, where key is type referenced and value is its constraints
      */
     private Map<TypeDefinitionBuilder, TypeConstraints> findTypeDefinitionBuilderWithConstraints(
             TypeConstraints constraints,
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            TypeAwareBuilder typeBuilder, ModuleBuilder builder) {
+            UnknownType unknownType, ModuleBuilder builder) {
         Map<TypeDefinitionBuilder, TypeConstraints> result = new HashMap<TypeDefinitionBuilder, TypeConstraints>();
 
-        UnknownType type = (UnknownType) typeBuilder.getType();
-        QName typeQName = type.getQName();
-        String typeName = type.getQName().getLocalName();
-        String prefix = typeQName.getPrefix();
+        // TypeDefinition<?> unknownType = typeBuilder.getType();
+        QName unknownTypeQName = unknownType.getQName();
+        String unknownTypeName = unknownTypeQName.getLocalName();
+        String unknownTypePrefix = unknownTypeQName.getPrefix();
 
         // search for module which contains referenced typedef
         ModuleBuilder dependentModuleBuilder;
-        if (prefix.equals(builder.getPrefix())) {
+        if (unknownTypePrefix.equals(builder.getPrefix())) {
             dependentModuleBuilder = builder;
         } else {
             ModuleImport dependentModuleImport = getModuleImport(builder,
-                    prefix);
+                    unknownTypePrefix);
             String dependentModuleName = dependentModuleImport.getModuleName();
             Date dependentModuleRevision = dependentModuleImport.getRevision();
             TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules
@@ -346,7 +406,7 @@ public class YangModelParserImpl implements YangModelParser {
         TypeDefinitionBuilder lookedUpBuilder = null;
         for (TypeDefinitionBuilder tdb : typedefs) {
             QName qname = tdb.getQName();
-            if (qname.getLocalName().equals(typeName)) {
+            if (qname.getLocalName().equals(unknownTypeName)) {
                 lookedUpBuilder = tdb;
                 break;
             }
@@ -366,8 +426,7 @@ public class YangModelParserImpl implements YangModelParser {
             final List<PatternConstraint> patterns = unknown.getPatterns();
             constraints.addPatterns(patterns);
             return findTypeDefinitionBuilderWithConstraints(constraints,
-                    modules, (TypeAwareBuilder) lookedUpBuilder,
-                    dependentModuleBuilder);
+                    modules, unknown, dependentModuleBuilder);
         } else {
             // pull restriction from this base type and add them to
             // 'constraints'
@@ -383,16 +442,14 @@ public class YangModelParserImpl implements YangModelParser {
             } else if (referencedType instanceof StringTypeDefinition) {
                 constraints.addPatterns(((StringTypeDefinition) referencedType)
                         .getPatterns());
-            } else if (referencedType instanceof BitsTypeDefinition) {
-                // TODO: add 'length' restriction to BitsType
             } else if (referencedType instanceof BinaryTypeDefinition) {
-                // TODO
+                constraints.addLengths(((BinaryTypeDefinition) referencedType)
+                        .getLengthConstraints());
             } else if (referencedType instanceof InstanceIdentifierTypeDefinition) {
                 // TODO: instance-identifier
             }
 
             result.put(lookedUpBuilder, constraints);
-            // return lookedUpBuilder;
             return result;
         }
     }
@@ -403,13 +460,13 @@ public class YangModelParserImpl implements YangModelParser {
      *
      * @param modules
      *            all available modules
-     * @param builder
+     * @param module
      *            current module
      */
     private void resolveAugments(
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
-            ModuleBuilder builder) {
-        Set<AugmentationSchemaBuilder> augmentBuilders = builder
+            ModuleBuilder module) {
+        Set<AugmentationSchemaBuilder> augmentBuilders = module
                 .getAddedAugments();
 
         Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();
@@ -421,7 +478,7 @@ public class YangModelParserImpl implements YangModelParser {
                 prefix = pathPart.getPrefix();
                 augmentTargetPath.add(pathPart.getLocalName());
             }
-            ModuleImport dependentModuleImport = getModuleImport(builder,
+            ModuleImport dependentModuleImport = getModuleImport(module,
                     prefix);
             String dependentModuleName = dependentModuleImport.getModuleName();
             augmentTargetPath.add(0, dependentModuleName);
@@ -446,7 +503,7 @@ public class YangModelParserImpl implements YangModelParser {
             fillAugmentTarget(augmentBuilder, (ChildNodeBuilder) augmentTarget);
             augments.add(result);
         }
-        builder.setAugmentations(augments);
+        module.setAugmentations(augments);
     }
 
     /**
@@ -487,19 +544,13 @@ public class YangModelParserImpl implements YangModelParser {
      * Helper method for resolving special 'min' or 'max' values in range
      * constraint
      *
-     * @param ranges
-     *            ranges to resolve
-     * @param typeToResolve
-     *            type to resolve
-     * @param targetType
-     *            target type
-     * @param modules
-     *            all available modules
-     * @param builder
-     *            current module
+     * @param ranges ranges to resolve
+     * @param targetType target type
+     * @param modules all available modules
+     * @param builder current module
      */
     private void resolveRanges(List<RangeConstraint> ranges,
-            TypeAwareBuilder typeToResolve, TypeDefinitionBuilder targetType,
+            TypeDefinitionBuilder targetType,
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
             ModuleBuilder builder) {
         if (ranges != null && ranges.size() > 0) {
@@ -507,8 +558,8 @@ public class YangModelParserImpl implements YangModelParser {
             Long max = (Long) ranges.get(ranges.size() - 1).getMax();
             // if range contains one of the special values 'min' or 'max'
             if (min.equals(Long.MIN_VALUE) || max.equals(Long.MAX_VALUE)) {
-                Long[] values = parseRangeConstraint(typeToResolve, targetType,
-                        modules, builder);
+                Long[] values = parseRangeConstraint(targetType, modules,
+                        builder);
                 if (min.equals(Long.MIN_VALUE)) {
                     min = values[0];
                     RangeConstraint oldFirst = ranges.get(0);
@@ -533,19 +584,13 @@ public class YangModelParserImpl implements YangModelParser {
      * Helper method for resolving special 'min' or 'max' values in length
      * constraint
      *
-     * @param ranges
-     *            ranges to resolve
-     * @param typeToResolve
-     *            type to resolve
-     * @param targetType
-     *            target type
-     * @param modules
-     *            all available modules
-     * @param builder
-     *            current module
+     * @param lengths lengths to resolve
+     * @param targetType target type
+     * @param modules all available modules
+     * @param builder current module
      */
     private void resolveLengths(List<LengthConstraint> lengths,
-            TypeAwareBuilder typeToResolve, TypeDefinitionBuilder targetType,
+            TypeDefinitionBuilder targetType,
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
             ModuleBuilder builder) {
         if (lengths != null && lengths.size() > 0) {
@@ -553,8 +598,8 @@ public class YangModelParserImpl implements YangModelParser {
             Long max = lengths.get(lengths.size() - 1).getMax();
             // if length contains one of the special values 'min' or 'max'
             if (min.equals(Long.MIN_VALUE) || max.equals(Long.MAX_VALUE)) {
-                Long[] values = parseRangeConstraint(typeToResolve, targetType,
-                        modules, builder);
+                Long[] values = parseRangeConstraint(targetType, modules,
+                        builder);
                 if (min.equals(Long.MIN_VALUE)) {
                     min = values[0];
                     LengthConstraint oldFirst = lengths.get(0);
@@ -577,8 +622,7 @@ public class YangModelParserImpl implements YangModelParser {
         }
     }
 
-    private Long[] parseRangeConstraint(TypeAwareBuilder typeToResolve,
-            TypeDefinitionBuilder targetType,
+    private Long[] parseRangeConstraint(TypeDefinitionBuilder targetType,
             Map<String, TreeMap<Date, ModuleBuilder>> modules,
             ModuleBuilder builder) {
         TypeDefinition<?> targetBaseType = targetType.getBaseType();
@@ -596,9 +640,10 @@ public class YangModelParserImpl implements YangModelParser {
             Long max = (Long) ranges.get(ranges.size() - 1).getMax();
             return new Long[] { min, max };
         } else {
-            return parseRangeConstraint(typeToResolve,
-                    findTypeDefinitionBuilder(modules, typeToResolve, builder),
-                    modules, builder);
+            return parseRangeConstraint(
+                    findTypeDefinitionBuilder(modules,
+                            (UnknownType) targetBaseType, builder), modules,
+                    builder);
         }
     }
 
index 510bec8cb20eb9942429f2a6b84fe93ffb92a67f..a9fce16bfaee5569962526de28427f887fcfdd6d 100644 (file)
-/*
- * 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.parser.impl;
-
-import static org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil.*;
-
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Stack;
-
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Contact_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Container_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_add_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_delete_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_not_supported_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_replace_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Import_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Key_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_list_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.List_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Module_header_stmtsContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Namespace_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Organization_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Prefix_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Presence_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_date_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtsContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;
-import org.opendaylight.controller.antlrv4.code.gen.YangParserBaseListener;
-import org.opendaylight.controller.model.util.YangTypesConverter;
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.Status;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
-import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.ContainerSchemaNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.DeviationBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.ExtensionBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.FeatureBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.LeafListSchemaNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.LeafSchemaNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.ListSchemaNodeBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.NotificationBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.RpcDefinitionBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.TypedefBuilder;
-import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class YangModelParserListenerImpl extends YangParserBaseListener {
-
-    private static final Logger logger = LoggerFactory
-            .getLogger(YangModelParserListenerImpl.class);
-
-    private ModuleBuilder moduleBuilder;
-
-    private String moduleName;
-    private URI namespace;
-    private String yangModelPrefix;
-    private Date revision;
-
-    private final DateFormat simpleDateFormat = new SimpleDateFormat(
-            "yyyy-mm-dd");
-    private final Stack<String> actualPath = new Stack<String>();
-
-
-    @Override
-    public void enterModule_stmt(YangParser.Module_stmtContext ctx) {
-        moduleName = stringFromNode(ctx);
-        actualPath.push(moduleName);
-        moduleBuilder = new ModuleBuilder(moduleName);
-
-        String description = null;
-        String reference = null;
-
-        for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
-            if (child instanceof Description_stmtContext) {
-                description = stringFromNode(child);
-            } else if (child instanceof Reference_stmtContext) {
-                reference = stringFromNode(child);
-            } else {
-                if (description != null && reference != null) {
-                    break;
-                }
-            }
-        }
-        moduleBuilder.setDescription(description);
-        moduleBuilder.setReference(reference);
-    }
-
-    @Override
-    public void exitModule_stmt(YangParser.Module_stmtContext ctx) {
-        final String moduleName = actualPath.pop();
-        logger.debug("Exiting module " + moduleName);
-    }
-
-    @Override
-    public void enterModule_header_stmts(final Module_header_stmtsContext ctx) {
-        super.enterModule_header_stmts(ctx);
-
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            final ParseTree treeNode = ctx.getChild(i);
-            if (treeNode instanceof Namespace_stmtContext) {
-                final String namespaceStr = stringFromNode(treeNode);
-                namespace = URI.create(namespaceStr);
-                moduleBuilder.setNamespace(namespace);
-            } else if (treeNode instanceof Prefix_stmtContext) {
-                yangModelPrefix = stringFromNode(treeNode);
-                moduleBuilder.setPrefix(yangModelPrefix);
-            } else if (treeNode instanceof Yang_version_stmtContext) {
-                final String yangVersion = stringFromNode(treeNode);
-                moduleBuilder.setYangVersion(yangVersion);
-            }
-        }
-    }
-
-    @Override
-    public void enterMeta_stmts(YangParser.Meta_stmtsContext ctx) {
-        for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
-            if (child instanceof Organization_stmtContext) {
-                final String organization = stringFromNode(child);
-                moduleBuilder.setOrganization(organization);
-            } else if (child instanceof Contact_stmtContext) {
-                final String contact = stringFromNode(child);
-                moduleBuilder.setContact(contact);
-            } else if (child instanceof Description_stmtContext) {
-                final String description = stringFromNode(child);
-                moduleBuilder.setDescription(description);
-            } else if (child instanceof Reference_stmtContext) {
-                final String reference = stringFromNode(child);
-                moduleBuilder.setReference(reference);
-            }
-        }
-    }
-
-    @Override
-    public void exitSubmodule_header_stmts(
-            YangParser.Submodule_header_stmtsContext ctx) {
-        final String submodule = actualPath.pop();
-        logger.debug("exiting submodule " + submodule);
-    }
-
-    @Override
-    public void enterRevision_stmts(Revision_stmtsContext ctx) {
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            final ParseTree treeNode = ctx.getChild(i);
-            if (treeNode instanceof Revision_stmtContext) {
-                final String revisionDateStr = stringFromNode(treeNode);
-                try {
-                    revision = simpleDateFormat.parse(revisionDateStr);
-                    moduleBuilder.setRevision(revision);
-                } catch (ParseException e) {
-                    final String message = "Failed to parse revision string: "+ revisionDateStr;
-                    logger.warn(message);
-                }
-            }
-        }
-    }
-
-    @Override
-    public void enterImport_stmt(Import_stmtContext ctx) {
-        super.enterImport_stmt(ctx);
-
-        final String importName = stringFromNode(ctx);
-        String importPrefix = null;
-        Date importRevision = null;
-
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            final ParseTree treeNode = ctx.getChild(i);
-            if (treeNode instanceof Prefix_stmtContext) {
-                importPrefix = stringFromNode(treeNode);
-            }
-            if (treeNode instanceof Revision_date_stmtContext) {
-                String importRevisionStr = stringFromNode(treeNode);
-                try {
-                    importRevision = simpleDateFormat.parse(importRevisionStr);
-                } catch(ParseException e) {
-                    logger.warn("Failed to parse import revision-date: "+ importRevisionStr);
-                }
-            }
-        }
-        moduleBuilder.addModuleImport(importName, importRevision, importPrefix);
-    }
-
-    @Override
-    public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {
-        final String augmentPath = stringFromNode(ctx);
-        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(
-                augmentPath, getActualPath());
-        updatePath(augmentPath);
-
-        for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
-            if (child instanceof Description_stmtContext) {
-                String desc = stringFromNode(child);
-                builder.setDescription(desc);
-            } else if (child instanceof Reference_stmtContext) {
-                String ref = stringFromNode(child);
-                builder.setReference(ref);
-            } else if (child instanceof Status_stmtContext) {
-                Status status = parseStatus((Status_stmtContext) child);
-                builder.setStatus(status);
-            }
-        }
-    }
-
-    @Override
-    public void exitAugment_stmt(YangParser.Augment_stmtContext ctx) {
-        final String augment = actualPath.pop();
-        logger.debug("exiting augment " + augment);
-    }
-
-    @Override
-    public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {
-        String argument = stringFromNode(ctx);
-        QName qname = new QName(namespace, revision, yangModelPrefix, argument);
-        ExtensionBuilder builder = moduleBuilder.addExtension(qname);
-        parseSchemaNodeArgs(ctx, builder);
-    }
-
-    @Override
-    public void enterTypedef_stmt(YangParser.Typedef_stmtContext ctx) {
-        String typedefName = stringFromNode(ctx);
-        QName typedefQName = new QName(namespace, revision, yangModelPrefix,
-                typedefName);
-        TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,
-                getActualPath());
-        updatePath(typedefName);
-
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
-        parseSchemaNodeArgs(ctx, builder);
-        builder.setUnits(parseUnits(ctx));
-    }
-
-    @Override
-    public void exitTypedef_stmt(YangParser.Typedef_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterType_stmt(YangParser.Type_stmtContext ctx) {
-        String typeName = stringFromNode(ctx);
-        QName typeQName;
-        if (typeName.contains(":")) {
-            String[] splittedName = typeName.split(":");
-            String prefix = splittedName[0];
-            String name = splittedName[1];
-            if (prefix.equals(yangModelPrefix)) {
-                typeQName = new QName(namespace, revision, prefix, name);
-            } else {
-                typeQName = new QName(null, null, prefix, name);
-            }
-        } else {
-            typeQName = new QName(namespace, revision, yangModelPrefix,
-                    typeName);
-        }
-
-        TypeDefinition<?> type = null;
-        Type_body_stmtsContext typeBody = null;
-        for (int i = 0; i < ctx.getChildCount(); i++) {
-            if (ctx.getChild(i) instanceof Type_body_stmtsContext) {
-                typeBody = (Type_body_stmtsContext) ctx.getChild(i);
-                break;
-            }
-        }
-
-        // if this is base yang type...
-        if(YangTypesConverter.isBaseYangType(typeName)) {
-            if (typeBody == null) {
-                // if there are no constraints, just grab default base yang type
-                type = YangTypesConverter.javaTypeForBaseYangType(typeName);
-            } else {
-                type = parseTypeBody(typeName, typeBody, actualPath, namespace, revision, yangModelPrefix);
-            }
-        } else {
-            type = parseUnknownTypeBody(typeQName, typeBody);
-            // mark parent node of this type statement as dirty
-            moduleBuilder.addDirtyNode(actualPath);
-        }
-
-        moduleBuilder.setType(type, actualPath);
-        updatePath(typeName);
-    }
-
-    @Override
-    public void exitType_stmt(YangParser.Type_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
-        final String groupName = stringFromNode(ctx);
-        QName groupQName = new QName(namespace, revision, yangModelPrefix,
-                groupName);
-        GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,
-                actualPath);
-        updatePath("grouping");
-        updatePath(groupName);
-        parseSchemaNodeArgs(ctx, groupBuilder);
-    }
-
-    @Override
-    public void exitGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
-        String actContainer = actualPath.pop();
-        actContainer += "-" + actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterContainer_stmt(Container_stmtContext ctx) {
-        super.enterContainer_stmt(ctx);
-        String containerName = stringFromNode(ctx);
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,
-                containerName);
-        ContainerSchemaNodeBuilder containerBuilder = moduleBuilder
-                .addContainerNode(containerQName, actualPath);
-        updatePath(containerName);
-
-        containerBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, containerBuilder);
-        parseConstraints(ctx, containerBuilder.getConstraintsBuilder());
-
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            final ParseTree childNode = ctx.getChild(i);
-            if (childNode instanceof Presence_stmtContext) {
-                containerBuilder.setPresenceContainer(true);
-                break;
-            }
-        }
-    }
-
-    @Override
-    public void exitContainer_stmt(Container_stmtContext ctx) {
-        super.exitContainer_stmt(ctx);
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterLeaf_stmt(Leaf_stmtContext ctx) {
-        super.enterLeaf_stmt(ctx);
-
-        final String leafName = stringFromNode(ctx);
-        QName leafQName = new QName(namespace, revision, yangModelPrefix,
-                leafName);
-        LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(
-                leafQName, actualPath);
-        updatePath(leafName);
-
-        leafBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, leafBuilder);
-        parseConstraints(ctx, leafBuilder.getConstraintsBuilder());
-    }
-
-    @Override
-    public void exitLeaf_stmt(YangParser.Leaf_stmtContext ctx) {
-        final String actLeaf = actualPath.pop();
-        logger.debug("exiting " + actLeaf);
-    }
-
-    @Override
-    public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {
-        final String groupingPathStr = stringFromNode(ctx);
-        moduleBuilder.addUsesNode(groupingPathStr, actualPath);
-        updatePath(groupingPathStr);
-    }
-
-    @Override
-    public void exitUses_stmt(YangParser.Uses_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterLeaf_list_stmt(Leaf_list_stmtContext ctx) {
-        super.enterLeaf_list_stmt(ctx);
-
-        final String leafListName = stringFromNode(ctx);
-        QName leafListQName = new QName(namespace, revision, yangModelPrefix,
-                leafListName);
-        LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder
-                .addLeafListNode(leafListQName, actualPath);
-        updatePath(leafListName);
-
-        parseSchemaNodeArgs(ctx, leafListBuilder);
-        parseConstraints(ctx, leafListBuilder.getConstraintsBuilder());
-
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            final ParseTree childNode = ctx.getChild(i);
-            if (childNode instanceof Ordered_by_stmtContext) {
-                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;
-                final boolean userOrdered = parseUserOrdered(orderedBy);
-                leafListBuilder.setUserOrdered(userOrdered);
-                break;
-            }
-        }
-    }
-
-    @Override
-    public void exitLeaf_list_stmt(YangParser.Leaf_list_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterList_stmt(List_stmtContext ctx) {
-        super.enterList_stmt(ctx);
-
-        final String containerName = stringFromNode(ctx);
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,
-                containerName);
-        ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(
-                containerQName, actualPath);
-        updatePath(containerName);
-
-        listBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, listBuilder);
-        parseConstraints(ctx, listBuilder.getConstraintsBuilder());
-
-        String keyDefinition = "";
-        for (int i = 0; i < ctx.getChildCount(); ++i) {
-            ParseTree childNode = ctx.getChild(i);
-            if (childNode instanceof Ordered_by_stmtContext) {
-                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;
-                final boolean userOrdered = parseUserOrdered(orderedBy);
-                listBuilder.setUserOrdered(userOrdered);
-            } else if (childNode instanceof Key_stmtContext) {
-                keyDefinition = stringFromNode(childNode);
-                List<QName> key = createListKey(keyDefinition, namespace,
-                        revision, yangModelPrefix);
-                listBuilder.setKeyDefinition(key);
-            }
-        }
-    }
-
-    @Override
-    public void exitList_stmt(List_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterNotification_stmt(YangParser.Notification_stmtContext ctx) {
-        final String notificationName = stringFromNode(ctx);
-        QName notificationQName = new QName(namespace, revision,
-                yangModelPrefix, notificationName);
-        NotificationBuilder notificationBuilder = moduleBuilder
-                .addNotification(notificationQName, actualPath);
-        updatePath(notificationName);
-
-        notificationBuilder.setPath(createActualSchemaPath(actualPath, namespace,
-                revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, notificationBuilder);
-    }
-
-    @Override
-    public void exitNotification_stmt(YangParser.Notification_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    // Unknown types
-    @Override
-    public void enterIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {
-        String name = stringFromNode(ctx);
-
-        QName qname;
-        if(name != null) {
-            String[] splittedName = name.split(":");
-            if(splittedName.length == 2) {
-                qname = new QName(null, null, splittedName[0], splittedName[1]);
-            } else {
-                qname = new QName(namespace, revision, yangModelPrefix, splittedName[0]);
-            }
-        } else {
-            qname = new QName(namespace, revision, yangModelPrefix, name);
-        }
-
-        UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(qname, getActualPath());
-        updatePath(name);
-
-        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, builder);
-    }
-
-    @Override
-    public void exitIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterRpc_stmt(YangParser.Rpc_stmtContext ctx) {
-        final String rpcName = stringFromNode(ctx);
-        QName rpcQName = new QName(namespace, revision, yangModelPrefix,
-                rpcName);
-        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,
-                actualPath);
-        updatePath(rpcName);
-
-        rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision,
-                yangModelPrefix));
-        parseSchemaNodeArgs(ctx, rpcBuilder);
-    }
-
-    @Override
-    public void exitRpc_stmt(YangParser.Rpc_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterInput_stmt(YangParser.Input_stmtContext ctx) {
-        updatePath("input");
-    }
-
-    @Override
-    public void exitInput_stmt(YangParser.Input_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterOutput_stmt(YangParser.Output_stmtContext ctx) {
-        updatePath("output");
-    }
-
-    @Override
-    public void exitOutput_stmt(YangParser.Output_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterFeature_stmt(YangParser.Feature_stmtContext ctx) {
-        final String featureName = stringFromNode(ctx);
-        QName featureQName = new QName(namespace, revision, yangModelPrefix,
-                featureName);
-        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,
-                actualPath);
-        updatePath(featureName);
-
-        featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,
-                revision, yangModelPrefix));
-        parseSchemaNodeArgs(ctx, featureBuilder);
-    }
-
-    @Override
-    public void exitFeature_stmt(YangParser.Feature_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterDeviation_stmt(YangParser.Deviation_stmtContext ctx) {
-        final String targetPath = stringFromNode(ctx);
-        String reference = null;
-        String deviate = null;
-        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath);
-        updatePath(targetPath);
-
-        for (int i = 0; i < ctx.getChildCount(); i++) {
-            ParseTree child = ctx.getChild(i);
-            if (child instanceof Reference_stmtContext) {
-                reference = stringFromNode(child);
-            } else if (child instanceof Deviate_not_supported_stmtContext) {
-                deviate = stringFromNode(child);
-            } else if (child instanceof Deviate_add_stmtContext) {
-                deviate = stringFromNode(child);
-            } else if (child instanceof Deviate_replace_stmtContext) {
-                deviate = stringFromNode(child);
-            } else if (child instanceof Deviate_delete_stmtContext) {
-                deviate = stringFromNode(child);
-            }
-        }
-        builder.setReference(reference);
-        builder.setDeviate(deviate);
-    }
-
-    @Override
-    public void exitDeviation_stmt(YangParser.Deviation_stmtContext ctx) {
-        final String actContainer = actualPath.pop();
-        logger.debug("exiting " + actContainer);
-    }
-
-    @Override
-    public void enterConfig_stmt(YangParser.Config_stmtContext ctx) {
-        boolean configuration = parseConfig(ctx);
-        moduleBuilder.addConfiguration(configuration, actualPath);
-    }
-
-    public ModuleBuilder getModuleBuilder() {
-        return moduleBuilder;
-    }
-
-    private void updatePath(String containerName) {
-        actualPath.push(containerName);
-    }
-
-    private List<String> getActualPath() {
-        return Collections.unmodifiableList(actualPath);
-    }
-
+/*\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.parser.impl;\r
+\r
+import static org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil.*;\r
+\r
+import java.net.URI;\r
+import java.text.DateFormat;\r
+import java.text.ParseException;\r
+import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.Stack;\r
+import java.util.TreeMap;\r
+\r
+import org.antlr.v4.runtime.tree.ParseTree;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Contact_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Container_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_add_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_delete_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_not_supported_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_replace_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Import_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Key_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_list_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.List_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Module_header_stmtsContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Namespace_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Organization_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Prefix_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Presence_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_date_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtsContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Union_specificationContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;\r
+import org.opendaylight.controller.antlrv4.code.gen.YangParserBaseListener;\r
+import org.opendaylight.controller.model.util.YangTypesConverter;\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.ContainerSchemaNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.DeviationBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.ExtensionBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.FeatureBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.LeafListSchemaNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.LeafSchemaNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.ListSchemaNodeBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.NotificationBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.RpcDefinitionBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.TypedefBuilder;\r
+import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+final class YangModelParserListenerImpl extends YangParserBaseListener {\r
+\r
+    private static final Logger logger = LoggerFactory\r
+            .getLogger(YangModelParserListenerImpl.class);\r
+\r
+    private ModuleBuilder moduleBuilder;\r
+\r
+    private String moduleName;\r
+    private URI namespace;\r
+    private String yangModelPrefix;\r
+    private Date revision;\r
+\r
+    private final DateFormat simpleDateFormat = new SimpleDateFormat(\r
+            "yyyy-mm-dd");\r
+    private final Stack<String> actualPath = new Stack<String>();\r
+\r
+\r
+    @Override\r
+    public void enterModule_stmt(YangParser.Module_stmtContext ctx) {\r
+        moduleName = stringFromNode(ctx);\r
+        actualPath.push(moduleName);\r
+        moduleBuilder = new ModuleBuilder(moduleName);\r
+\r
+        String description = null;\r
+        String reference = null;\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); i++) {\r
+            ParseTree child = ctx.getChild(i);\r
+            if (child instanceof Description_stmtContext) {\r
+                description = stringFromNode(child);\r
+            } else if (child instanceof Reference_stmtContext) {\r
+                reference = stringFromNode(child);\r
+            } else {\r
+                if (description != null && reference != null) {\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+        moduleBuilder.setDescription(description);\r
+        moduleBuilder.setReference(reference);\r
+    }\r
+\r
+    @Override\r
+    public void exitModule_stmt(YangParser.Module_stmtContext ctx) {\r
+        final String moduleName = actualPath.pop();\r
+        logger.debug("Exiting module " + moduleName);\r
+    }\r
+\r
+    @Override\r
+    public void enterModule_header_stmts(final Module_header_stmtsContext ctx) {\r
+        super.enterModule_header_stmts(ctx);\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            final ParseTree treeNode = ctx.getChild(i);\r
+            if (treeNode instanceof Namespace_stmtContext) {\r
+                final String namespaceStr = stringFromNode(treeNode);\r
+                namespace = URI.create(namespaceStr);\r
+                moduleBuilder.setNamespace(namespace);\r
+            } else if (treeNode instanceof Prefix_stmtContext) {\r
+                yangModelPrefix = stringFromNode(treeNode);\r
+                moduleBuilder.setPrefix(yangModelPrefix);\r
+            } else if (treeNode instanceof Yang_version_stmtContext) {\r
+                final String yangVersion = stringFromNode(treeNode);\r
+                moduleBuilder.setYangVersion(yangVersion);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void enterMeta_stmts(YangParser.Meta_stmtsContext ctx) {\r
+        for (int i = 0; i < ctx.getChildCount(); i++) {\r
+            ParseTree child = ctx.getChild(i);\r
+            if (child instanceof Organization_stmtContext) {\r
+                final String organization = stringFromNode(child);\r
+                moduleBuilder.setOrganization(organization);\r
+            } else if (child instanceof Contact_stmtContext) {\r
+                final String contact = stringFromNode(child);\r
+                moduleBuilder.setContact(contact);\r
+            } else if (child instanceof Description_stmtContext) {\r
+                final String description = stringFromNode(child);\r
+                moduleBuilder.setDescription(description);\r
+            } else if (child instanceof Reference_stmtContext) {\r
+                final String reference = stringFromNode(child);\r
+                moduleBuilder.setReference(reference);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void exitSubmodule_header_stmts(\r
+            YangParser.Submodule_header_stmtsContext ctx) {\r
+        final String submodule = actualPath.pop();\r
+        logger.debug("exiting submodule " + submodule);\r
+    }\r
+\r
+    @Override\r
+    public void enterRevision_stmts(Revision_stmtsContext ctx) {\r
+        TreeMap<Date, Revision_stmtContext> revisions = new TreeMap<Date, Revision_stmtContext>();\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            final ParseTree treeNode = ctx.getChild(i);\r
+            if (treeNode instanceof Revision_stmtContext) {\r
+                final String revisionDateStr = stringFromNode(treeNode);\r
+                try {\r
+                    Date revision = simpleDateFormat.parse(revisionDateStr);\r
+                    revisions.put(revision, (Revision_stmtContext)treeNode);\r
+\r
+                } catch (ParseException e) {\r
+                    final String message = "Failed to parse revision string: "+ revisionDateStr;\r
+                    logger.warn(message);\r
+                }\r
+            }\r
+        }\r
+        if(revisions.size() > 0) {\r
+            Revision_stmtContext revisionCtx = revisions.firstEntry().getValue();\r
+            moduleBuilder.setRevision(revisions.firstKey());\r
+\r
+            for(int i = 0; i < revisionCtx.getChildCount(); i++) {\r
+                ParseTree child = revisionCtx.getChild(i);\r
+                if(child instanceof Reference_stmtContext) {\r
+                    moduleBuilder.setReference(stringFromNode(child));\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void enterImport_stmt(Import_stmtContext ctx) {\r
+        super.enterImport_stmt(ctx);\r
+\r
+        final String importName = stringFromNode(ctx);\r
+        String importPrefix = null;\r
+        Date importRevision = null;\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            final ParseTree treeNode = ctx.getChild(i);\r
+            if (treeNode instanceof Prefix_stmtContext) {\r
+                importPrefix = stringFromNode(treeNode);\r
+            }\r
+            if (treeNode instanceof Revision_date_stmtContext) {\r
+                String importRevisionStr = stringFromNode(treeNode);\r
+                try {\r
+                    importRevision = simpleDateFormat.parse(importRevisionStr);\r
+                } catch(ParseException e) {\r
+                    logger.warn("Failed to parse import revision-date: "+ importRevisionStr);\r
+                }\r
+            }\r
+        }\r
+        moduleBuilder.addModuleImport(importName, importRevision, importPrefix);\r
+    }\r
+\r
+    @Override\r
+    public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {\r
+        final String augmentPath = stringFromNode(ctx);\r
+        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(\r
+                augmentPath, getActualPath());\r
+        updatePath(augmentPath);\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); i++) {\r
+            ParseTree child = ctx.getChild(i);\r
+            if (child instanceof Description_stmtContext) {\r
+                String desc = stringFromNode(child);\r
+                builder.setDescription(desc);\r
+            } else if (child instanceof Reference_stmtContext) {\r
+                String ref = stringFromNode(child);\r
+                builder.setReference(ref);\r
+            } else if (child instanceof Status_stmtContext) {\r
+                Status status = parseStatus((Status_stmtContext) child);\r
+                builder.setStatus(status);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void exitAugment_stmt(YangParser.Augment_stmtContext ctx) {\r
+        final String augment = actualPath.pop();\r
+        logger.debug("exiting augment " + augment);\r
+    }\r
+\r
+    @Override\r
+    public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {\r
+        String argument = stringFromNode(ctx);\r
+        QName qname = new QName(namespace, revision, yangModelPrefix, argument);\r
+        ExtensionBuilder builder = moduleBuilder.addExtension(qname);\r
+        parseSchemaNodeArgs(ctx, builder);\r
+    }\r
+\r
+    @Override\r
+    public void enterTypedef_stmt(YangParser.Typedef_stmtContext ctx) {\r
+        String typedefName = stringFromNode(ctx);\r
+        QName typedefQName = new QName(namespace, revision, yangModelPrefix,\r
+                typedefName);\r
+        TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,\r
+                getActualPath());\r
+        updatePath(typedefName);\r
+\r
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,\r
+                yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, builder);\r
+        builder.setUnits(parseUnits(ctx));\r
+    }\r
+\r
+    @Override\r
+    public void exitTypedef_stmt(YangParser.Typedef_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterType_stmt(YangParser.Type_stmtContext ctx) {\r
+        String typeName = stringFromNode(ctx);\r
+        QName typeQName;\r
+        if (typeName.contains(":")) {\r
+            String[] splittedName = typeName.split(":");\r
+            String prefix = splittedName[0];\r
+            String name = splittedName[1];\r
+            if (prefix.equals(yangModelPrefix)) {\r
+                typeQName = new QName(namespace, revision, prefix, name);\r
+            } else {\r
+                typeQName = new QName(null, null, prefix, name);\r
+            }\r
+        } else {\r
+            typeQName = new QName(namespace, revision, yangModelPrefix,\r
+                    typeName);\r
+        }\r
+\r
+        TypeDefinition<?> type = null;\r
+        Type_body_stmtsContext typeBody = null;\r
+        for (int i = 0; i < ctx.getChildCount(); i++) {\r
+            if (ctx.getChild(i) instanceof Type_body_stmtsContext) {\r
+                typeBody = (Type_body_stmtsContext) ctx.getChild(i);\r
+                break;\r
+            }\r
+        }\r
+\r
+\r
+\r
+        // if this is base yang type...\r
+        if(YangTypesConverter.isBaseYangType(typeName)) {\r
+            if (typeBody == null) {\r
+                // if there are no constraints, just grab default base yang type\r
+                type = YangTypesConverter.javaTypeForBaseYangType(typeName);\r
+                moduleBuilder.setType(type, actualPath);\r
+            } else {\r
+                if(typeName.equals("union")) {\r
+                    List<String> types = new ArrayList<String>();\r
+                    for(int i = 0; i < typeBody.getChildCount(); i++) {\r
+                        ParseTree unionSpec = typeBody.getChild(i);\r
+                        if(unionSpec instanceof Union_specificationContext) {\r
+                            for(int j = 0; j < unionSpec.getChildCount(); j++) {\r
+                                ParseTree typeSpec = unionSpec.getChild(j);\r
+                                types.add(stringFromNode(typeSpec));\r
+                            }\r
+                        }\r
+                    }\r
+                    moduleBuilder.addUnionType(actualPath);\r
+                } else {\r
+                    type = parseTypeBody(typeName, typeBody, actualPath, namespace, revision, yangModelPrefix);\r
+                    moduleBuilder.setType(type, actualPath);\r
+                }\r
+            }\r
+        } else {\r
+            type = parseUnknownTypeBody(typeQName, typeBody);\r
+            // mark parent node of this type statement as dirty\r
+            moduleBuilder.addDirtyNode(actualPath);\r
+            moduleBuilder.setType(type, actualPath);\r
+        }\r
+\r
+        updatePath(typeName);\r
+\r
+    }\r
+\r
+    @Override\r
+    public void exitType_stmt(YangParser.Type_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterGrouping_stmt(YangParser.Grouping_stmtContext ctx) {\r
+        final String groupName = stringFromNode(ctx);\r
+        QName groupQName = new QName(namespace, revision, yangModelPrefix,\r
+                groupName);\r
+        GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,\r
+                actualPath);\r
+        updatePath("grouping");\r
+        updatePath(groupName);\r
+        parseSchemaNodeArgs(ctx, groupBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void exitGrouping_stmt(YangParser.Grouping_stmtContext ctx) {\r
+        String actContainer = actualPath.pop();\r
+        actContainer += "-" + actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterContainer_stmt(Container_stmtContext ctx) {\r
+        super.enterContainer_stmt(ctx);\r
+        String containerName = stringFromNode(ctx);\r
+        QName containerQName = new QName(namespace, revision, yangModelPrefix,\r
+                containerName);\r
+        ContainerSchemaNodeBuilder containerBuilder = moduleBuilder\r
+                .addContainerNode(containerQName, actualPath);\r
+        updatePath(containerName);\r
+\r
+        containerBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, containerBuilder);\r
+        parseConstraints(ctx, containerBuilder.getConstraintsBuilder());\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            final ParseTree childNode = ctx.getChild(i);\r
+            if (childNode instanceof Presence_stmtContext) {\r
+                containerBuilder.setPresenceContainer(true);\r
+                break;\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void exitContainer_stmt(Container_stmtContext ctx) {\r
+        super.exitContainer_stmt(ctx);\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterLeaf_stmt(Leaf_stmtContext ctx) {\r
+        super.enterLeaf_stmt(ctx);\r
+\r
+        final String leafName = stringFromNode(ctx);\r
+        QName leafQName = new QName(namespace, revision, yangModelPrefix,\r
+                leafName);\r
+        LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(\r
+                leafQName, actualPath);\r
+        updatePath(leafName);\r
+\r
+        leafBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, leafBuilder);\r
+        parseConstraints(ctx, leafBuilder.getConstraintsBuilder());\r
+    }\r
+\r
+    @Override\r
+    public void exitLeaf_stmt(YangParser.Leaf_stmtContext ctx) {\r
+        final String actLeaf = actualPath.pop();\r
+        logger.debug("exiting " + actLeaf);\r
+    }\r
+\r
+    @Override\r
+    public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {\r
+        final String groupingPathStr = stringFromNode(ctx);\r
+        moduleBuilder.addUsesNode(groupingPathStr, actualPath);\r
+        updatePath(groupingPathStr);\r
+    }\r
+\r
+    @Override\r
+    public void exitUses_stmt(YangParser.Uses_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterLeaf_list_stmt(Leaf_list_stmtContext ctx) {\r
+        super.enterLeaf_list_stmt(ctx);\r
+\r
+        final String leafListName = stringFromNode(ctx);\r
+        QName leafListQName = new QName(namespace, revision, yangModelPrefix,\r
+                leafListName);\r
+        LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder\r
+                .addLeafListNode(leafListQName, actualPath);\r
+        updatePath(leafListName);\r
+\r
+        parseSchemaNodeArgs(ctx, leafListBuilder);\r
+        parseConstraints(ctx, leafListBuilder.getConstraintsBuilder());\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            final ParseTree childNode = ctx.getChild(i);\r
+            if (childNode instanceof Ordered_by_stmtContext) {\r
+                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;\r
+                final boolean userOrdered = parseUserOrdered(orderedBy);\r
+                leafListBuilder.setUserOrdered(userOrdered);\r
+                break;\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void exitLeaf_list_stmt(YangParser.Leaf_list_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterList_stmt(List_stmtContext ctx) {\r
+        super.enterList_stmt(ctx);\r
+\r
+        final String containerName = stringFromNode(ctx);\r
+        QName containerQName = new QName(namespace, revision, yangModelPrefix,\r
+                containerName);\r
+        ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(\r
+                containerQName, actualPath);\r
+        updatePath(containerName);\r
+\r
+        listBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, listBuilder);\r
+        parseConstraints(ctx, listBuilder.getConstraintsBuilder());\r
+\r
+        String keyDefinition = "";\r
+        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
+            ParseTree childNode = ctx.getChild(i);\r
+            if (childNode instanceof Ordered_by_stmtContext) {\r
+                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;\r
+                final boolean userOrdered = parseUserOrdered(orderedBy);\r
+                listBuilder.setUserOrdered(userOrdered);\r
+            } else if (childNode instanceof Key_stmtContext) {\r
+                keyDefinition = stringFromNode(childNode);\r
+                List<QName> key = createListKey(keyDefinition, namespace,\r
+                        revision, yangModelPrefix);\r
+                listBuilder.setKeyDefinition(key);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void exitList_stmt(List_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterNotification_stmt(YangParser.Notification_stmtContext ctx) {\r
+        final String notificationName = stringFromNode(ctx);\r
+        QName notificationQName = new QName(namespace, revision,\r
+                yangModelPrefix, notificationName);\r
+        NotificationBuilder notificationBuilder = moduleBuilder\r
+                .addNotification(notificationQName, actualPath);\r
+        updatePath(notificationName);\r
+\r
+        notificationBuilder.setPath(createActualSchemaPath(actualPath, namespace,\r
+                revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, notificationBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void exitNotification_stmt(YangParser.Notification_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    // Unknown types\r
+    @Override\r
+    public void enterIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {\r
+        String name = stringFromNode(ctx);\r
+\r
+        QName qname;\r
+        if(name != null) {\r
+            String[] splittedName = name.split(":");\r
+            if(splittedName.length == 2) {\r
+                qname = new QName(null, null, splittedName[0], splittedName[1]);\r
+            } else {\r
+                qname = new QName(namespace, revision, yangModelPrefix, splittedName[0]);\r
+            }\r
+        } else {\r
+            qname = new QName(namespace, revision, yangModelPrefix, name);\r
+        }\r
+\r
+        UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(qname, getActualPath());\r
+        updatePath(name);\r
+\r
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, builder);\r
+    }\r
+\r
+    @Override\r
+    public void exitIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterRpc_stmt(YangParser.Rpc_stmtContext ctx) {\r
+        final String rpcName = stringFromNode(ctx);\r
+        QName rpcQName = new QName(namespace, revision, yangModelPrefix,\r
+                rpcName);\r
+        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,\r
+                actualPath);\r
+        updatePath(rpcName);\r
+\r
+        rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision,\r
+                yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, rpcBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void exitRpc_stmt(YangParser.Rpc_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterInput_stmt(YangParser.Input_stmtContext ctx) {\r
+        updatePath("input");\r
+    }\r
+\r
+    @Override\r
+    public void exitInput_stmt(YangParser.Input_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterOutput_stmt(YangParser.Output_stmtContext ctx) {\r
+        updatePath("output");\r
+    }\r
+\r
+    @Override\r
+    public void exitOutput_stmt(YangParser.Output_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterFeature_stmt(YangParser.Feature_stmtContext ctx) {\r
+        final String featureName = stringFromNode(ctx);\r
+        QName featureQName = new QName(namespace, revision, yangModelPrefix,\r
+                featureName);\r
+        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,\r
+                actualPath);\r
+        updatePath(featureName);\r
+\r
+        featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,\r
+                revision, yangModelPrefix));\r
+        parseSchemaNodeArgs(ctx, featureBuilder);\r
+    }\r
+\r
+    @Override\r
+    public void exitFeature_stmt(YangParser.Feature_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterDeviation_stmt(YangParser.Deviation_stmtContext ctx) {\r
+        final String targetPath = stringFromNode(ctx);\r
+        String reference = null;\r
+        String deviate = null;\r
+        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath);\r
+        updatePath(targetPath);\r
+\r
+        for (int i = 0; i < ctx.getChildCount(); i++) {\r
+            ParseTree child = ctx.getChild(i);\r
+            if (child instanceof Reference_stmtContext) {\r
+                reference = stringFromNode(child);\r
+            } else if (child instanceof Deviate_not_supported_stmtContext) {\r
+                deviate = stringFromNode(child);\r
+            } else if (child instanceof Deviate_add_stmtContext) {\r
+                deviate = stringFromNode(child);\r
+            } else if (child instanceof Deviate_replace_stmtContext) {\r
+                deviate = stringFromNode(child);\r
+            } else if (child instanceof Deviate_delete_stmtContext) {\r
+                deviate = stringFromNode(child);\r
+            }\r
+        }\r
+        builder.setReference(reference);\r
+        builder.setDeviate(deviate);\r
+    }\r
+\r
+    @Override\r
+    public void exitDeviation_stmt(YangParser.Deviation_stmtContext ctx) {\r
+        final String actContainer = actualPath.pop();\r
+        logger.debug("exiting " + actContainer);\r
+    }\r
+\r
+    @Override\r
+    public void enterConfig_stmt(YangParser.Config_stmtContext ctx) {\r
+        boolean configuration = parseConfig(ctx);\r
+        moduleBuilder.addConfiguration(configuration, actualPath);\r
+    }\r
+\r
+    public ModuleBuilder getModuleBuilder() {\r
+        return moduleBuilder;\r
+    }\r
+\r
+    private void updatePath(String containerName) {\r
+        actualPath.push(containerName);\r
+    }\r
+\r
+    private List<String> getActualPath() {\r
+        return Collections.unmodifiableList(actualPath);\r
+    }\r
+\r
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/TypesResolutionTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/TypesResolutionTest.java
new file mode 100644 (file)
index 0000000..12924ef
--- /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.model.parser.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.controller.model.util.EnumerationType;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+
+public class TypesResolutionTest {
+
+    private YangModelParser parser;
+    private String[] testFiles;
+    private Set<Module> modules;
+
+    @Before
+    public void init() {
+        parser = new YangModelParserImpl();
+        testFiles = new String[5];
+
+        File testDir = new File("src/test/resources/types");
+        String[] fileList = testDir.list();
+        int i = 0;
+        for(String fileName : fileList) {
+            File file = new File(testDir, fileName);
+            testFiles[i] = file.getAbsolutePath();
+            i++;
+        }
+
+        modules = parser.parseYangModels(testFiles);
+        assertEquals(5, modules.size());
+    }
+
+    @Test
+    public void testIetfInetTypes() {
+        Module tested = findModule(modules, "ietf-inet-types");
+        Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
+        assertEquals(14, typedefs.size());
+
+        TypeDefinition<?> t1 = findTypedef(typedefs, "ip-version");
+        EnumerationType en = (EnumerationType)t1.getBaseType();
+        List<EnumPair> values = en.getValues();
+
+        EnumPair value0 = values.get(0);
+        assertEquals("unknown", value0.getName());
+        assertEquals(0, (int)value0.getValue());
+
+        EnumPair value1 = values.get(1);
+        assertEquals("ipv4", value1.getName());
+        assertEquals(1, (int)value1.getValue());
+
+        EnumPair value2 = values.get(2);
+        assertEquals("ipv6", value2.getName());
+        assertEquals(2, (int)value2.getValue());
+    }
+
+    private Module findModule(Set<Module> modules, String name) {
+        for(Module module : modules) {
+            if(module.getName().equals(name)) {
+                return module;
+            }
+        }
+        return null;
+    }
+
+    private TypeDefinition<?> findTypedef(Set<TypeDefinition<?>> typedefs, String name) {
+        for(TypeDefinition<?> td : typedefs) {
+            if(td.getQName().getLocalName().equals(name)) {
+                return td;
+            }
+        }
+        return null;
+    }
+
+}
index a9bcb918b7ca6ee1ff8396082567899291f453ea..c8c9f8b9c1f634afbaf502702c903c74725e506a 100644 (file)
@@ -12,6 +12,8 @@ import static org.junit.Assert.*;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -22,10 +24,10 @@ import org.antlr.v4.runtime.ANTLRInputStream;
 import org.antlr.v4.runtime.CommonTokenStream;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.ParseTreeWalker;
-import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.antlrv4.code.gen.YangLexer;
 import org.opendaylight.controller.antlrv4.code.gen.YangParser;
+import org.opendaylight.controller.model.util.Leafref;
 import org.opendaylight.controller.model.util.UnknownType;
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
@@ -43,33 +45,70 @@ import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
 
 public class YangModelParserListenerTest {
 
-    private final String testFile = "/test-model.yang";
-    ModuleBuilder builder;
-    Module module;
+    @Test
+    public void testParseImport() throws Exception {
+        Module module = getModule("/abstract-topology.yang");
+
+        Set<ModuleImport> imports = module.getImports();
+        assertEquals(1, imports.size());
+        ModuleImport moduleImport = imports.iterator().next();
 
+        assertEquals("inet", moduleImport.getPrefix());
 
-    @Before
-    public void init() throws IOException {
-        builder = getBuilder(testFile);
-        module = builder.build();
+        DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");
+        Date expectedDate = simpleDateFormat.parse("2010-09-24");
+        assertEquals(expectedDate, moduleImport.getRevision());
     }
 
     @Test
-    public void testParseModule() throws IOException {
-        Set<ModuleImport> imports = module.getImports();
-        assertEquals(3, imports.size());
+    public void testParseHeaders() throws Exception {
+        Module module = getModule("/abstract-topology.yang");
 
         URI namespace = module.getNamespace();
-        URI expectedNS = URI.create("urn:cisco:params:xml:ns:yang:controller:network");
+        URI expectedNS = URI.create("");
         assertEquals(expectedNS, namespace);
 
-        Date revision = module.getRevision();
-        assertNull(revision);
+        DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");
+        Date expectedDate = simpleDateFormat.parse("2013-02-08");
+        assertEquals(expectedDate, module.getRevision());
 
         String prefix = module.getPrefix();
-        String expectedPrefix = "topos";
+        String expectedPrefix = "tp";
         assertEquals(expectedPrefix, prefix);
 
+        String expectedDescription = "This module contains the definitions of elements that creates network";
+        assertTrue(module.getDescription().contains(expectedDescription));
+
+        String expectedReference = "~~~ WILL BE DEFINED LATER";
+        assertEquals(expectedReference, module.getReference());
+
+        assertEquals("1", module.getYangVersion());
+    }
+
+    @Test
+    public void testParseLeafref() throws Exception {
+        Module module = getModule("/abstract-topology.yang");
+
+        Set<TypeDefinition<?>> typedefs = module.getTypeDefinitions();
+        assertEquals(2, typedefs.size());
+        for(TypeDefinition<?> td : typedefs) {
+            Leafref baseType = (Leafref)td.getBaseType();
+            if(td.getQName().getLocalName().equals("network-node-id-ref")) {
+                assertEquals("/tp:topology/tp:network-nodes/tp:network-node/tp:node-id", baseType.getPathStatement().toString());
+            } else {
+                assertEquals("/tp:topology/tp:network-links/tp:network-link/tp:link-id", baseType.getPathStatement().toString());
+            }
+        }
+    }
+
+    @Test
+    public void testParseModule() throws IOException {
+        Module module = getModule("/test-model.yang");
+
+        URI namespace = module.getNamespace();
+        Date revision = module.getRevision();
+        String prefix = module.getPrefix();
+
         String expectedDescription = "module description";
         assertEquals(expectedDescription, module.getDescription());
 
@@ -93,7 +132,9 @@ public class YangModelParserListenerTest {
     }
 
     @Test
-    public void testParseContainer() {
+    public void testParseContainer() throws IOException {
+        Module module = getModule("/test-model.yang");
+
         URI namespace = module.getNamespace();
         Date revision = module.getRevision();
         String prefix = module.getPrefix();
@@ -120,7 +161,9 @@ public class YangModelParserListenerTest {
     }
 
     @Test
-    public void testParseList() {
+    public void testParseList() throws IOException {
+        Module module = getModule("/test-model.yang");
+
         URI namespace = module.getNamespace();
         Date revision = module.getRevision();
         String prefix = module.getPrefix();
@@ -156,7 +199,9 @@ public class YangModelParserListenerTest {
     }
 
     @Test
-    public void testParseLeaf() {
+    public void testParseLeaf() throws IOException {
+        Module module = getModule("/test-model.yang");
+
         URI namespace = module.getNamespace();
         Date revision = module.getRevision();
         String prefix = module.getPrefix();
@@ -194,6 +239,11 @@ public class YangModelParserListenerTest {
         assertEquals(expectedStatus, tested.getStatus());
     }
 
+    private Module getModule(String testFile) throws IOException {
+        ModuleBuilder builder = getBuilder(testFile);
+        return builder.build();
+    }
+
     private ModuleBuilder getBuilder(String fileName) throws IOException {
         final InputStream inStream = getClass().getResourceAsStream(fileName);
         ANTLRInputStream input = new ANTLRInputStream(inStream);
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/abstract-topology.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/abstract-topology.yang
new file mode 100644 (file)
index 0000000..dbece9a
--- /dev/null
@@ -0,0 +1,92 @@
+module abstract-topology {
+    yang-version 1;
+    namespace "";
+    prefix "tp";
+
+    import ietf-inet-types { 
+        prefix "inet"; 
+        revision-date 2010-09-24;
+    }
+
+    organization "Cisco";
+    contact "WILL-BE-DEFINED-LATER";
+
+    description
+        "This module contains the definitions of elements that creates network 
+    topology i.e. definition of network nodes and links. This module is not designed to be used solely for network representation. This module SHOULD be used as base module in defining the network topology.";
+
+    revision "2013-02-08" {
+        reference "~~~ WILL BE DEFINED LATER";
+    }
+    
+    typedef network-node-id-ref {
+        type leafref {
+            path "/tp:topology/tp:network-nodes/tp:network-node/tp:node-id";
+        }
+        description "This type is used for leafs that reference network node instance.";
+    }
+
+    typedef link-id-ref {
+        type leafref {
+            path "/tp:topology/tp:network-links/tp:network-link/tp:link-id";
+        }
+        description "This type is used for leafs that reference network link instance.";
+    }
+
+    container topology {
+        description "This is the model of abstract topology which contains only Network Nodes and Network Links. Each topology MUST be identified by unique topology-id for reason that the store could contain many topologies.";
+
+        leaf topology-id {
+            type inet:uri;
+            description "It is presumed that datastore will contain many topologies. To distinguish between topologies it is vital to have
+            UNIQUE topology identifier.";
+        }
+
+        container network-nodes {
+            list network-node {
+                key "node-id";
+
+                leaf node-id {
+                    type inet:uri;
+                    description "The Topology identifier of network-node.";
+                }
+
+                container attributes {
+                    description "Aditional attributes that can Network Node contains.";
+                }
+                description "The list of network nodes defined for topology.";
+            }
+        }
+        
+        container network-links {
+            list network-link {
+                key "link-id";
+
+                leaf link-id {
+                    type inet:uri;
+                    description "";
+                }
+
+                container source-node {
+                    leaf id {
+                        type node-id-ref;
+                        description "Source node identifier.";
+                    }
+                }
+
+                container destination-node {
+                    leaf id {
+                        type node-id-ref;
+                        description "Destination node identifier.";
+                    }
+                }
+
+                container attributes {
+                    description "Aditional attributes that can Network Link contains.";
+                }
+                description "The Network Link which is defined by Local (Source) and Remote (Destination) Network Nodes. Every link MUST be defined either by identifier and
+                his local and remote Network Nodes (In real applications it is common that many links are originated from one node and end up in same remote node). To ensure that we would always know to distinguish between links, every link SHOULD have identifier.";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-afn-safi@2012-06-04.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-afn-safi@2012-06-04.yang
new file mode 100644 (file)
index 0000000..5d5bdd0
--- /dev/null
@@ -0,0 +1,387 @@
+module iana-afn-safi {
+  namespace "urn:ietf:params:xml:ns:yang:iana-afn-safi";
+  prefix "ianaaf";
+
+  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 provides two typedefs containing YANG
+     definitions for the following IANA-registered enumerations:
+
+     - Address Family Numbers (AFN)
+
+     - Subsequent Address Family Identifiers (SAFI)
+
+     The latest revision of this YANG module can be obtained from the
+     IANA web site.
+
+     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-06-04 {
+    description
+      "Initial revision.";
+    reference
+      "RFC XXXX: TITLE";
+  }
+
+  typedef address-family {
+    type enumeration {
+      enum other {
+        value "0";
+        description
+          "none of the following";
+      }
+      enum ipv4 {
+        value "1";
+        description
+          "IP version 4";
+      }
+      enum ipv6 {
+        value "2";
+        description
+          "IP version 6";
+      }
+      enum nsap {
+        value "3";
+        description
+          "NSAP";
+      }
+      enum hdlc {
+        value "4";
+        description
+          "HDLC (8-bit multidrop)";
+      }
+      enum bbn1822 {
+        value "5";
+        description
+          "BBN 1822";
+      }
+      enum all802 {
+        value "6";
+        description
+          "802 (includes all 802 media plus Ethernet 'canonical
+           format')";
+      }
+      enum e163 {
+        value "7";
+        description
+          "E.163";
+      }
+      enum e164 {
+        value "8";
+        description
+          "E.164 (SMDS, FrameRelay, ATM)";
+      }
+      enum f69 {
+        value "9";
+        description
+          "F.69 (Telex)";
+      }
+      enum x121 {
+        value "10";
+        description
+          "X.121 (X.25, Frame Relay)";
+      }
+      enum ipx {
+        value "11";
+        description
+          "IPX (Internetwork Packet Exchange)";
+      }
+      enum appletalk {
+        value "12";
+        description
+          "Appletalk";
+      }
+      enum decnetIV {
+        value "13";
+        description
+          "DECnet IV";
+      }
+      enum banyanVines {
+        value "14";
+        description
+          "Banyan Vines";
+      }
+      enum e164withNsap {
+        value "15";
+        description
+          "E.164 with NSAP format subaddress";
+        reference
+          "ATM Forum UNI 3.1";
+      }
+      enum dns {
+        value "16";
+        description
+          "DNS (Domain Name System)";
+      }
+      enum distinguishedName {
+        value "17";
+        description
+          "Distinguished Name (per X.500)";
+      }
+      enum asNumber {
+        value "18";
+        description
+          "Autonomous System Number";
+      }
+      enum xtpOverIPv4 {
+        value "19";
+        description
+          "XTP over IP version 4";
+      }
+      enum xtpOverIpv6 {
+        value "20";
+        description
+          "XTP over IP version 6";
+      }
+      enum xtpNativeModeXTP {
+        value "21";
+        description
+          "XTP native mode XTP";
+      }
+      enum fibreChannelWWPN {
+        value "22";
+        description
+          "Fibre Channel World-Wide Port Name";
+      }
+      enum fibreChannelWWNN {
+        value "23";
+        description
+          "Fibre Channel World-Wide Node Name";
+      }
+      enum gwid {
+        value "24";
+        description
+          "Gateway Identifier";
+      }
+      enum l2vpn {
+        value "25";
+        description
+          "AFI for L2VPN information";
+        reference
+          "RFC 4761: Virtual Private LAN Service (VPLS): Using BGP
+           for Auto-Discovery and Signaling
+
+           RFC 6074: Provisioning, Auto-Discovery, and Signaling in
+           Layer 2 Virtual Private Networks (L2VPNs)
+          ";
+      }
+      enum eigrpCommon {
+        value "16384";
+        description
+          "EIGRP Common Service Family";
+      }
+      enum eigrpIPv4 {
+        value "16385";
+        description
+          "EIGRP IPv4 Service Family";
+      }
+      enum eigrpIPv6 {
+        value "16386";
+        description
+          "EIGRP IPv6 Service Family";
+      }
+      enum lcaf {
+        value "16387";
+        description
+          "LISP Canonical Address Format";
+      }
+    }
+    description
+      "This typedef is a YANG enumeration of IANA-registered address
+       family numbers (AFN).";
+    reference
+      "Address Family Numbers. IANA, 2011-01-20.
+       <http://www.iana.org/assignments/address-family-numbers/
+       address-family-numbers.xml>
+      ";
+  }
+
+  typedef subsequent-address-family {
+    type enumeration {
+      enum nlri-unicast {
+        value "1";
+        description
+          "Network Layer Reachability Information used for unicast
+           forwarding";
+        reference
+          "RFC 4760: Multiprotocol Extensions for BGP-4";
+      }
+      enum nlri-multicast {
+        value "2";
+        description
+          "Network Layer Reachability Information used for multicast
+           forwarding";
+        reference
+          "RFC 4760: Multiprotocol Extensions for BGP-4";
+      }
+      enum nlri-mpls {
+        value "4";
+        description
+          "Network Layer Reachability Information (NLRI) with MPLS
+           Labels";
+        reference
+          "RFC 3107: Carrying Label Information in BGP-4";
+      }
+      enum mcast-vpn {
+        value "5";
+        description
+          "MCAST-VPN";
+        reference
+          "RFC 6514: BGP Encodings and Procedures for Multicast in
+           MPLS/BGP IP VPNs";
+      }
+      enum nlri-dynamic-ms-pw {
+        value "6";
+        status "obsolete";
+        description
+          "Network Layer Reachability Information used for Dynamic
+           Placement of Multi-Segment Pseudowires (TEMPORARY -
+           Expires 2008-08-23)";
+        reference
+          "draft-ietf-pwe3-dynamic-ms-pw: Dynamic Placement of Multi
+           Segment Pseudowires";
+      }
+      enum encapsulation {
+        value "7";
+        description
+          "Encapsulation SAFI";
+        reference
+          "RFC 5512: The BGP Encapsulation Subsequent Address Family
+           Identifier (SAFI) and the BGP Tunnel Encapsulation
+           Attribute";
+      }
+      enum tunnel-safi {
+        value "64";
+        status "obsolete";
+        description
+          "Tunnel SAFI";
+        reference
+          "draft-nalawade-kapoor-tunnel-safi: BGP Tunnel SAFI";
+      }
+      enum vpls {
+        value "65";
+        description
+          "Virtual Private LAN Service (VPLS)";
+        reference
+          "RFC 4761: Virtual Private LAN Service (VPLS): Using BGP
+           for Auto-Discovery and Signaling
+
+           RFC 6074: Provisioning, Auto-Discovery, and Signaling in
+           Layer 2 Virtual Private Networks (L2VPNs)
+          ";
+      }
+      enum bgp-mdt {
+        value "66";
+        description
+          "BGP MDT SAFI";
+        reference
+          "RFC 6037: Cisco Systems' Solution for Multicast in
+           BGP/MPLS IP VPNs";
+      }
+      enum bgp-4over6 {
+        value "67";
+        description
+          "BGP 4over6 SAFI";
+        reference
+          "RFC 5747: 4over6 Transit Solution Using IP Encapsulation
+           and MP-BGP Extensions";
+      }
+      enum bgp-6over4 {
+        value "68";
+        description
+          "BGP 6over4 SAFI";
+      }
+      enum l1vpn-auto-discovery {
+        value "69";
+        description
+          "Layer-1 VPN auto-discovery information";
+        reference
+          "RFC 5195: BGP-Based Auto-Discovery for Layer-1 VPNs";
+      }
+      enum mpls-vpn {
+        value "128";
+        description
+          "MPLS-labeled VPN address";
+        reference
+          "RFC 4364: BGP/MPLS IP Virtual Private Networks (VPNs)";
+      }
+      enum multicast-bgp-mpls-vpn {
+        value "129";
+        description
+          "Multicast for BGP/MPLS IP Virtual Private Networks
+           (VPNs)";
+        reference
+          "RFC 6513: Multicast in MPLS/BGP IP VPNs
+
+           RFC 6514: BGP Encodings and Procedures for Multicast in
+           MPLS/BGP IP VPNs
+          ";
+      }
+      enum route-target-constraints {
+        value "132";
+        description
+          "Route Target constraints";
+        reference
+          "RFC 4684: Constrained Route Distribution for Border
+           Gateway Protocol/MultiProtocol Label Switching (BGP/MPLS)
+           Internet Protocol (IP) Virtual Private Networks (VPNs)";
+      }
+      enum ipv4-diss-flow {
+        value "133";
+        description
+          "IPv4 dissemination of flow specification rules";
+        reference
+          "RFC 5575: Dissemination of Flow Specification Rules";
+      }
+      enum vpnv4-diss-flow {
+        value "134";
+        description
+          "IPv4 dissemination of flow specification rules";
+        reference
+          "RFC 5575: Dissemination of Flow Specification Rules";
+      }
+      enum vpn-auto-discovery {
+        value "140";
+        status "obsolete";
+        description
+          "VPN auto-discovery";
+        reference
+          "draft-ietf-l3vpn-bgpvpn-auto: Using BGP as an
+           Auto-Discovery Mechanism for VR-based Layer-3 VPNs";
+      }
+    }
+    description
+      "This typedef is a YANG enumeration of IANA-registered
+       subsequent address family identifiers (SAFI).";
+    reference
+      "Subsequent Address Family Identifiers (SAFI) Parameters. IANA,
+       2012-02-22. <http://www.iana.org/assignments/safi-namespace/
+       safi-namespace.xml>
+      ";
+  }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-if-type@2012-06-05.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-if-type@2012-06-05.yang
new file mode 100644 (file)
index 0000000..c5ce80c
--- /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>";
+  }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-timezones@2012-07-09.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/iana-timezones@2012-07-09.yang
new file mode 100644 (file)
index 0000000..7fc1577
--- /dev/null
@@ -0,0 +1,1701 @@
+module iana-timezones {
+  namespace "urn:ietf:params:xml:ns:yang:iana-timezones";
+  prefix ianatz;
+
+  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-timezone typedef, which
+     contains YANG definitions for IANA-registered timezones.
+
+     This YANG module is maintained by IANA, and reflects the
+     IANA Time Zone Database.
+     (http://www.iana.org/time-zones)
+
+     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.";
+
+  revision 2012-07-09 {
+    description
+      "Initial revision. Using IANA Time Zone Data v. 2012c
+       (Released 2012-03-27)";
+    reference "RFC XXXX: TITLE";
+  }
+  typedef iana-timezone {
+    description
+      "A timezone location as defined by the IANA timezone
+       database (http://www.iana.org/time-zones)";
+    type enumeration {
+      enum "Europe/Andorra" {
+        value 0;
+      }
+      enum "Asia/Dubai" {
+        value 1;
+      }
+      enum "Asia/Kabul" {
+        value 2;
+      }
+      enum "America/Antigua" {
+        value 3;
+      }
+      enum "America/Anguilla" {
+        value 4;
+      }
+      enum "Europe/Tirane" {
+        value 5;
+      }
+      enum "Asia/Yerevan" {
+        value 6;
+      }
+      enum "Africa/Luanda" {
+        value 7;
+      }
+      enum "Antarctica/McMurdo" {
+        value 8;
+        description
+          "McMurdo Station, Ross Island";
+      }
+      enum "Antarctica/South_Pole" {
+        value 9;
+        description
+          "Amundsen-Scott Station, South Pole";
+      }
+      enum "Antarctica/Rothera" {
+        value 10;
+        description
+          "Rothera Station, Adelaide Island";
+      }
+      enum "Antarctica/Palmer" {
+        value 11;
+        description
+          "Palmer Station, Anvers Island";
+      }
+      enum "Antarctica/Mawson" {
+        value 12;
+        description
+          "Mawson Station, Holme Bay";
+      }
+      enum "Antarctica/Davis" {
+        value 13;
+        description
+          "Davis Station, Vestfold Hills";
+      }
+      enum "Antarctica/Casey" {
+        value 14;
+        description
+          "Casey Station, Bailey Peninsula";
+      }
+      enum "Antarctica/Vostok" {
+        value 15;
+        description
+          "Vostok Station, Lake Vostok";
+      }
+      enum "Antarctica/DumontDUrville" {
+        value 16;
+        description
+          "Dumont-d'Urville Station, Terre Adelie";
+      }
+      enum "Antarctica/Syowa" {
+        value 17;
+        description
+          "Syowa Station, E Ongul I";
+      }
+      enum "Antarctica/Macquarie" {
+        value 18;
+        description
+          "Macquarie Island Station, Macquarie Island";
+      }
+      enum "America/Argentina/Buenos_Aires" {
+        value 19;
+        description
+          "Buenos Aires (BA, CF)";
+      }
+      enum "America/Argentina/Cordoba" {
+        value 20;
+        description
+          "most locations (CB, CC, CN, ER, FM, MN, SE, SF)";
+      }
+      enum "America/Argentina/Salta" {
+        value 21;
+        description
+          "(SA, LP, NQ, RN)";
+      }
+      enum "America/Argentina/Jujuy" {
+        value 22;
+        description
+          "Jujuy (JY)";
+      }
+      enum "America/Argentina/Tucuman" {
+        value 23;
+        description
+          "Tucuman (TM)";
+      }
+      enum "America/Argentina/Catamarca" {
+        value 24;
+        description
+          "Catamarca (CT), Chubut (CH)";
+      }
+      enum "America/Argentina/La_Rioja" {
+        value 25;
+        description
+          "La Rioja (LR)";
+      }
+      enum "America/Argentina/San_Juan" {
+        value 26;
+        description
+          "San Juan (SJ)";
+      }
+      enum "America/Argentina/Mendoza" {
+        value 27;
+        description
+          "Mendoza (MZ)";
+      }
+      enum "America/Argentina/San_Luis" {
+        value 28;
+        description
+          "San Luis (SL)";
+      }
+      enum "America/Argentina/Rio_Gallegos" {
+        value 29;
+        description
+          "Santa Cruz (SC)";
+      }
+      enum "America/Argentina/Ushuaia" {
+        value 30;
+        description
+          "Tierra del Fuego (TF)";
+      }
+      enum "Pacific/Pago_Pago" {
+        value 31;
+      }
+      enum "Europe/Vienna" {
+        value 32;
+      }
+      enum "Australia/Lord_Howe" {
+        value 33;
+        description
+          "Lord Howe Island";
+      }
+      enum "Australia/Hobart" {
+        value 34;
+        description
+          "Tasmania - most locations";
+      }
+      enum "Australia/Currie" {
+        value 35;
+        description
+          "Tasmania - King Island";
+      }
+      enum "Australia/Melbourne" {
+        value 36;
+        description
+          "Victoria";
+      }
+      enum "Australia/Sydney" {
+        value 37;
+        description
+          "New South Wales - most locations";
+      }
+      enum "Australia/Broken_Hill" {
+        value 38;
+        description
+          "New South Wales - Yancowinna";
+      }
+      enum "Australia/Brisbane" {
+        value 39;
+        description
+          "Queensland - most locations";
+      }
+      enum "Australia/Lindeman" {
+        value 40;
+        description
+          "Queensland - Holiday Islands";
+      }
+      enum "Australia/Adelaide" {
+        value 41;
+        description
+          "South Australia";
+      }
+      enum "Australia/Darwin" {
+        value 42;
+        description
+          "Northern Territory";
+      }
+      enum "Australia/Perth" {
+        value 43;
+        description
+          "Western Australia - most locations";
+      }
+      enum "Australia/Eucla" {
+        value 44;
+        description
+          "Western Australia - Eucla area";
+      }
+      enum "America/Aruba" {
+        value 45;
+      }
+      enum "Europe/Mariehamn" {
+        value 46;
+      }
+      enum "Asia/Baku" {
+        value 47;
+      }
+      enum "Europe/Sarajevo" {
+        value 48;
+      }
+      enum "America/Barbados" {
+        value 49;
+      }
+      enum "Asia/Dhaka" {
+        value 50;
+      }
+      enum "Europe/Brussels" {
+        value 51;
+      }
+      enum "Africa/Ouagadougou" {
+        value 52;
+      }
+      enum "Europe/Sofia" {
+        value 53;
+      }
+      enum "Asia/Bahrain" {
+        value 54;
+      }
+      enum "Africa/Bujumbura" {
+        value 55;
+      }
+      enum "Africa/Porto-Novo" {
+        value 56;
+      }
+      enum "America/St_Barthelemy" {
+        value 57;
+      }
+      enum "Atlantic/Bermuda" {
+        value 58;
+      }
+      enum "Asia/Brunei" {
+        value 59;
+      }
+      enum "America/La_Paz" {
+        value 60;
+      }
+      enum "America/Kralendijk" {
+        value 61;
+      }
+      enum "America/Noronha" {
+        value 62;
+        description
+          "Atlantic islands";
+      }
+      enum "America/Belem" {
+        value 63;
+        description
+          "Amapa, E Para";
+      }
+      enum "America/Fortaleza" {
+        value 64;
+        description
+          "NE Brazil (MA, PI, CE, RN, PB)";
+      }
+      enum "America/Recife" {
+        value 65;
+        description
+          "Pernambuco";
+      }
+      enum "America/Araguaina" {
+        value 66;
+        description
+          "Tocantins";
+      }
+      enum "America/Maceio" {
+        value 67;
+        description
+          "Alagoas, Sergipe";
+      }
+      enum "America/Bahia" {
+        value 68;
+        description
+          "Bahia";
+      }
+      enum "America/Sao_Paulo" {
+        value 69;
+        description
+          "S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)";
+      }
+      enum "America/Campo_Grande" {
+        value 70;
+        description
+          "Mato Grosso do Sul";
+      }
+      enum "America/Cuiaba" {
+        value 71;
+        description
+          "Mato Grosso";
+      }
+      enum "America/Santarem" {
+        value 72;
+        description
+          "W Para";
+      }
+      enum "America/Porto_Velho" {
+        value 73;
+        description
+          "Rondonia";
+      }
+      enum "America/Boa_Vista" {
+        value 74;
+        description
+          "Roraima";
+      }
+      enum "America/Manaus" {
+        value 75;
+        description
+          "E Amazonas";
+      }
+      enum "America/Eirunepe" {
+        value 76;
+        description
+          "W Amazonas";
+      }
+      enum "America/Rio_Branco" {
+        value 77;
+        description
+          "Acre";
+      }
+      enum "America/Nassau" {
+        value 78;
+      }
+      enum "Asia/Thimphu" {
+        value 79;
+      }
+      enum "Africa/Gaborone" {
+        value 80;
+      }
+      enum "Europe/Minsk" {
+        value 81;
+      }
+      enum "America/Belize" {
+        value 82;
+      }
+      enum "America/St_Johns" {
+        value 83;
+        description
+          "Newfoundland Time, including SE Labrador";
+      }
+      enum "America/Halifax" {
+        value 84;
+        description
+          "Atlantic Time - Nova Scotia (most places), PEI";
+      }
+      enum "America/Glace_Bay" {
+        value 85;
+        description
+          "Atlantic Time - Nova Scotia - places that did not observe
+           DST 1966-1971";
+      }
+      enum "America/Moncton" {
+        value 86;
+        description
+          "Atlantic Time - New Brunswick";
+      }
+      enum "America/Goose_Bay" {
+        value 87;
+        description
+          "Atlantic Time - Labrador - most locations";
+      }
+      enum "America/Blanc-Sablon" {
+        value 88;
+        description
+          "Atlantic Standard Time - Quebec - Lower North Shore";
+      }
+      enum "America/Montreal" {
+        value 89;
+        description
+          "Eastern Time - Quebec - most locations";
+      }
+      enum "America/Toronto" {
+        value 90;
+        description
+          "Eastern Time - Ontario - most locations";
+      }
+      enum "America/Nipigon" {
+        value 91;
+        description
+          "Eastern Time - Ontario & Quebec - places that did not
+           observe DST 1967-1973";
+      }
+      enum "America/Thunder_Bay" {
+        value 92;
+        description
+          "Eastern Time - Thunder Bay, Ontario";
+      }
+      enum "America/Iqaluit" {
+        value 93;
+        description
+          "Eastern Time - east Nunavut - most locations";
+      }
+      enum "America/Pangnirtung" {
+        value 94;
+        description
+          "Eastern Time - Pangnirtung, Nunavut";
+      }
+      enum "America/Resolute" {
+        value 95;
+        description
+          "Central Standard Time - Resolute, Nunavut";
+      }
+      enum "America/Atikokan" {
+        value 96;
+        description
+          "Eastern Standard Time - Atikokan, Ontario and Southampton I,
+           Nunavut";
+      }
+      enum "America/Rankin_Inlet" {
+        value 97;
+        description
+          "Central Time - central Nunavut";
+      }
+      enum "America/Winnipeg" {
+        value 98;
+        description
+          "Central Time - Manitoba & west Ontario";
+      }
+      enum "America/Rainy_River" {
+        value 99;
+        description
+          "Central Time - Rainy River & Fort Frances, Ontario";
+      }
+      enum "America/Regina" {
+        value 100;
+        description
+          "Central Standard Time - Saskatchewan - most locations";
+      }
+      enum "America/Swift_Current" {
+        value 101;
+        description
+          "Central Standard Time - Saskatchewan - midwest";
+      }
+      enum "America/Edmonton" {
+        value 102;
+        description
+          "Mountain Time - Alberta, east British Columbia & west
+           Saskatchewan";
+      }
+      enum "America/Cambridge_Bay" {
+        value 103;
+        description
+          "Mountain Time - west Nunavut";
+      }
+      enum "America/Yellowknife" {
+        value 104;
+        description
+          "Mountain Time - central Northwest Territories";
+      }
+      enum "America/Inuvik" {
+        value 105;
+        description
+          "Mountain Time - west Northwest Territories";
+      }
+      enum "America/Creston" {
+        value 106;
+        description
+          "Mountain Standard Time - Creston, British Columbia";
+      }
+      enum "America/Dawson_Creek" {
+        value 107;
+        description
+          "Mountain Standard Time - Dawson Creek & Fort Saint John,
+           British Columbia";
+      }
+      enum "America/Vancouver" {
+        value 108;
+        description
+          "Pacific Time - west British Columbia";
+      }
+      enum "America/Whitehorse" {
+        value 109;
+        description
+          "Pacific Time - south Yukon";
+      }
+      enum "America/Dawson" {
+        value 110;
+        description
+          "Pacific Time - north Yukon";
+      }
+      enum "Indian/Cocos" {
+        value 111;
+      }
+      enum "Africa/Kinshasa" {
+        value 112;
+        description
+          "west Dem. Rep. of Congo";
+      }
+      enum "Africa/Lubumbashi" {
+        value 113;
+        description
+          "east Dem. Rep. of Congo";
+      }
+      enum "Africa/Bangui" {
+        value 114;
+      }
+      enum "Africa/Brazzaville" {
+        value 115;
+      }
+      enum "Europe/Zurich" {
+        value 116;
+      }
+      enum "Africa/Abidjan" {
+        value 117;
+      }
+      enum "Pacific/Rarotonga" {
+        value 118;
+      }
+      enum "America/Santiago" {
+        value 119;
+        description
+          "most locations";
+      }
+      enum "Pacific/Easter" {
+        value 120;
+        description
+          "Easter Island & Sala y Gomez";
+      }
+      enum "Africa/Douala" {
+        value 121;
+      }
+      enum "Asia/Shanghai" {
+        value 122;
+        description
+          "east China - Beijing, Guangdong, Shanghai, etc.";
+      }
+      enum "Asia/Harbin" {
+        value 123;
+        description
+          "Heilongjiang (except Mohe), Jilin";
+      }
+      enum "Asia/Chongqing" {
+        value 124;
+        description
+          "central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou,
+           etc.";
+      }
+      enum "Asia/Urumqi" {
+        value 125;
+        description
+          "most of Tibet & Xinjiang";
+      }
+      enum "Asia/Kashgar" {
+        value 126;
+        description
+          "west Tibet & Xinjiang";
+      }
+      enum "America/Bogota" {
+        value 127;
+      }
+      enum "America/Costa_Rica" {
+        value 128;
+      }
+      enum "America/Havana" {
+        value 129;
+      }
+      enum "Atlantic/Cape_Verde" {
+        value 130;
+      }
+      enum "America/Curacao" {
+        value 131;
+      }
+      enum "Indian/Christmas" {
+        value 132;
+      }
+      enum "Asia/Nicosia" {
+        value 133;
+      }
+      enum "Europe/Prague" {
+        value 134;
+      }
+      enum "Europe/Berlin" {
+        value 135;
+      }
+      enum "Africa/Djibouti" {
+        value 136;
+      }
+      enum "Europe/Copenhagen" {
+        value 137;
+      }
+      enum "America/Dominica" {
+        value 138;
+      }
+      enum "America/Santo_Domingo" {
+        value 139;
+      }
+      enum "Africa/Algiers" {
+        value 140;
+      }
+      enum "America/Guayaquil" {
+        value 141;
+        description
+          "mainland";
+      }
+      enum "Pacific/Galapagos" {
+        value 142;
+        description
+          "Galapagos Islands";
+      }
+      enum "Europe/Tallinn" {
+        value 143;
+      }
+      enum "Africa/Cairo" {
+        value 144;
+      }
+      enum "Africa/El_Aaiun" {
+        value 145;
+      }
+      enum "Africa/Asmara" {
+        value 146;
+      }
+      enum "Europe/Madrid" {
+        value 147;
+        description
+          "mainland";
+      }
+      enum "Africa/Ceuta" {
+        value 148;
+        description
+          "Ceuta & Melilla";
+      }
+      enum "Atlantic/Canary" {
+        value 149;
+        description
+          "Canary Islands";
+      }
+      enum "Africa/Addis_Ababa" {
+        value 150;
+      }
+      enum "Europe/Helsinki" {
+        value 151;
+      }
+      enum "Pacific/Fiji" {
+        value 152;
+      }
+      enum "Atlantic/Stanley" {
+        value 153;
+      }
+      enum "Pacific/Chuuk" {
+        value 154;
+        description
+          "Chuuk (Truk) and Yap";
+      }
+      enum "Pacific/Pohnpei" {
+        value 155;
+        description
+          "Pohnpei (Ponape)";
+      }
+      enum "Pacific/Kosrae" {
+        value 156;
+        description
+          "Kosrae";
+      }
+      enum "Atlantic/Faroe" {
+        value 157;
+      }
+      enum "Europe/Paris" {
+        value 158;
+      }
+      enum "Africa/Libreville" {
+        value 159;
+      }
+      enum "Europe/London" {
+        value 160;
+      }
+      enum "America/Grenada" {
+        value 161;
+      }
+      enum "Asia/Tbilisi" {
+        value 162;
+      }
+      enum "America/Cayenne" {
+        value 163;
+      }
+      enum "Europe/Guernsey" {
+        value 164;
+      }
+      enum "Africa/Accra" {
+        value 165;
+      }
+      enum "Europe/Gibraltar" {
+        value 166;
+      }
+      enum "America/Godthab" {
+        value 167;
+        description
+          "most locations";
+      }
+      enum "America/Danmarkshavn" {
+        value 168;
+        description
+          "east coast, north of Scoresbysund";
+      }
+      enum "America/Scoresbysund" {
+        value 169;
+        description
+          "Scoresbysund / Ittoqqortoormiit";
+      }
+      enum "America/Thule" {
+        value 170;
+        description
+          "Thule / Pituffik";
+      }
+      enum "Africa/Banjul" {
+        value 171;
+      }
+      enum "Africa/Conakry" {
+        value 172;
+      }
+      enum "America/Guadeloupe" {
+        value 173;
+      }
+      enum "Africa/Malabo" {
+        value 174;
+      }
+      enum "Europe/Athens" {
+        value 175;
+      }
+      enum "Atlantic/South_Georgia" {
+        value 176;
+      }
+      enum "America/Guatemala" {
+        value 177;
+      }
+      enum "Pacific/Guam" {
+        value 178;
+      }
+      enum "Africa/Bissau" {
+        value 179;
+      }
+      enum "America/Guyana" {
+        value 180;
+      }
+      enum "Asia/Hong_Kong" {
+        value 181;
+      }
+      enum "America/Tegucigalpa" {
+        value 182;
+      }
+      enum "Europe/Zagreb" {
+        value 183;
+      }
+      enum "America/Port-au-Prince" {
+        value 184;
+      }
+      enum "Europe/Budapest" {
+        value 185;
+      }
+      enum "Asia/Jakarta" {
+        value 186;
+        description
+          "Java & Sumatra";
+      }
+      enum "Asia/Pontianak" {
+        value 187;
+        description
+          "west & central Borneo";
+      }
+      enum "Asia/Makassar" {
+        value 188;
+        description
+          "east & south Borneo, Sulawesi (Celebes), Bali, Nusa
+           Tengarra, west Timor";
+      }
+      enum "Asia/Jayapura" {
+        value 189;
+        description
+          "west New Guinea (Irian Jaya) & Malukus (Moluccas)";
+      }
+      enum "Europe/Dublin" {
+        value 190;
+      }
+      enum "Asia/Jerusalem" {
+        value 191;
+      }
+      enum "Europe/Isle_of_Man" {
+        value 192;
+      }
+      enum "Asia/Kolkata" {
+        value 193;
+      }
+      enum "Indian/Chagos" {
+        value 194;
+      }
+      enum "Asia/Baghdad" {
+        value 195;
+      }
+      enum "Asia/Tehran" {
+        value 196;
+      }
+      enum "Atlantic/Reykjavik" {
+        value 197;
+      }
+      enum "Europe/Rome" {
+        value 198;
+      }
+      enum "Europe/Jersey" {
+        value 199;
+      }
+      enum "America/Jamaica" {
+        value 200;
+      }
+      enum "Asia/Amman" {
+        value 201;
+      }
+      enum "Asia/Tokyo" {
+        value 202;
+      }
+      enum "Africa/Nairobi" {
+        value 203;
+      }
+      enum "Asia/Bishkek" {
+        value 204;
+      }
+      enum "Asia/Phnom_Penh" {
+        value 205;
+      }
+      enum "Pacific/Tarawa" {
+        value 206;
+        description
+          "Gilbert Islands";
+      }
+      enum "Pacific/Enderbury" {
+        value 207;
+        description
+          "Phoenix Islands";
+      }
+      enum "Pacific/Kiritimati" {
+        value 208;
+        description
+          "Line Islands";
+      }
+      enum "Indian/Comoro" {
+        value 209;
+      }
+      enum "America/St_Kitts" {
+        value 210;
+      }
+      enum "Asia/Pyongyang" {
+        value 211;
+      }
+      enum "Asia/Seoul" {
+        value 212;
+      }
+      enum "Asia/Kuwait" {
+        value 213;
+      }
+      enum "America/Cayman" {
+        value 214;
+      }
+      enum "Asia/Almaty" {
+        value 215;
+        description
+          "most locations";
+      }
+      enum "Asia/Qyzylorda" {
+        value 216;
+        description
+          "Qyzylorda (Kyzylorda, Kzyl-Orda)";
+      }
+      enum "Asia/Aqtobe" {
+        value 217;
+        description
+          "Aqtobe (Aktobe)";
+      }
+      enum "Asia/Aqtau" {
+        value 218;
+        description
+          "Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau)";
+      }
+      enum "Asia/Oral" {
+        value 219;
+        description
+          "West Kazakhstan";
+      }
+      enum "Asia/Vientiane" {
+        value 220;
+      }
+      enum "Asia/Beirut" {
+        value 221;
+      }
+      enum "America/St_Lucia" {
+        value 222;
+      }
+      enum "Europe/Vaduz" {
+        value 223;
+      }
+      enum "Asia/Colombo" {
+        value 224;
+      }
+      enum "Africa/Monrovia" {
+        value 225;
+      }
+      enum "Africa/Maseru" {
+        value 226;
+      }
+      enum "Europe/Vilnius" {
+        value 227;
+      }
+      enum "Europe/Luxembourg" {
+        value 228;
+      }
+      enum "Europe/Riga" {
+        value 229;
+      }
+      enum "Africa/Tripoli" {
+        value 230;
+      }
+      enum "Africa/Casablanca" {
+        value 231;
+      }
+      enum "Europe/Monaco" {
+        value 232;
+      }
+      enum "Europe/Chisinau" {
+        value 233;
+      }
+      enum "Europe/Podgorica" {
+        value 234;
+      }
+      enum "America/Marigot" {
+        value 235;
+      }
+      enum "Indian/Antananarivo" {
+        value 236;
+      }
+      enum "Pacific/Majuro" {
+        value 237;
+        description
+          "most locations";
+      }
+      enum "Pacific/Kwajalein" {
+        value 238;
+        description
+          "Kwajalein";
+      }
+      enum "Europe/Skopje" {
+        value 239;
+      }
+      enum "Africa/Bamako" {
+        value 240;
+      }
+      enum "Asia/Rangoon" {
+        value 241;
+      }
+      enum "Asia/Ulaanbaatar" {
+        value 242;
+        description
+          "most locations";
+      }
+      enum "Asia/Hovd" {
+        value 243;
+        description
+          "Bayan-Olgiy, Govi-Altai, Hovd, Uvs, Zavkhan";
+      }
+      enum "Asia/Choibalsan" {
+        value 244;
+        description
+          "Dornod, Sukhbaatar";
+      }
+      enum "Asia/Macau" {
+        value 245;
+      }
+      enum "Pacific/Saipan" {
+        value 246;
+      }
+      enum "America/Martinique" {
+        value 247;
+      }
+      enum "Africa/Nouakchott" {
+        value 248;
+      }
+      enum "America/Montserrat" {
+        value 249;
+      }
+      enum "Europe/Malta" {
+        value 250;
+      }
+      enum "Indian/Mauritius" {
+        value 251;
+      }
+      enum "Indian/Maldives" {
+        value 252;
+      }
+      enum "Africa/Blantyre" {
+        value 253;
+      }
+      enum "America/Mexico_City" {
+        value 254;
+        description
+          "Central Time - most locations";
+      }
+      enum "America/Cancun" {
+        value 255;
+        description
+          "Central Time - Quintana Roo";
+      }
+      enum "America/Merida" {
+        value 256;
+        description
+          "Central Time - Campeche, Yucatan";
+      }
+      enum "America/Monterrey" {
+        value 257;
+        description
+          "Mexican Central Time - Coahuila, Durango, Nuevo Leon,
+           Tamaulipas away from US border";
+      }
+      enum "America/Matamoros" {
+        value 258;
+        description
+          "US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas
+           near US border";
+      }
+      enum "America/Mazatlan" {
+        value 259;
+        description
+          "Mountain Time - S Baja, Nayarit, Sinaloa";
+      }
+      enum "America/Chihuahua" {
+        value 260;
+        description
+          "Mexican Mountain Time - Chihuahua away from US border";
+      }
+      enum "America/Ojinaga" {
+        value 261;
+        description
+          "US Mountain Time - Chihuahua near US border";
+      }
+      enum "America/Hermosillo" {
+        value 262;
+        description
+          "Mountain Standard Time - Sonora";
+      }
+      enum "America/Tijuana" {
+        value 263;
+        description
+          "US Pacific Time - Baja California near US border";
+      }
+      enum "America/Santa_Isabel" {
+        value 264;
+        description
+          "Mexican Pacific Time - Baja California away from US border";
+      }
+      enum "America/Bahia_Banderas" {
+        value 265;
+        description
+          "Mexican Central Time - Bahia de Banderas";
+      }
+      enum "Asia/Kuala_Lumpur" {
+        value 266;
+        description
+          "peninsular Malaysia";
+      }
+      enum "Asia/Kuching" {
+        value 267;
+        description
+          "Sabah & Sarawak";
+      }
+      enum "Africa/Maputo" {
+        value 268;
+      }
+      enum "Africa/Windhoek" {
+        value 269;
+      }
+      enum "Pacific/Noumea" {
+        value 270;
+      }
+      enum "Africa/Niamey" {
+        value 271;
+      }
+      enum "Pacific/Norfolk" {
+        value 272;
+      }
+      enum "Africa/Lagos" {
+        value 273;
+      }
+      enum "America/Managua" {
+        value 274;
+      }
+      enum "Europe/Amsterdam" {
+        value 275;
+      }
+      enum "Europe/Oslo" {
+        value 276;
+      }
+      enum "Asia/Kathmandu" {
+        value 277;
+      }
+      enum "Pacific/Nauru" {
+        value 278;
+      }
+      enum "Pacific/Niue" {
+        value 279;
+      }
+      enum "Pacific/Auckland" {
+        value 280;
+        description
+          "most locations";
+      }
+      enum "Pacific/Chatham" {
+        value 281;
+        description
+          "Chatham Islands";
+      }
+      enum "Asia/Muscat" {
+        value 282;
+      }
+      enum "America/Panama" {
+        value 283;
+      }
+      enum "America/Lima" {
+        value 284;
+      }
+      enum "Pacific/Tahiti" {
+        value 285;
+        description
+          "Society Islands";
+      }
+      enum "Pacific/Marquesas" {
+        value 286;
+        description
+          "Marquesas Islands";
+      }
+      enum "Pacific/Gambier" {
+        value 287;
+        description
+          "Gambier Islands";
+      }
+      enum "Pacific/Port_Moresby" {
+        value 288;
+      }
+      enum "Asia/Manila" {
+        value 289;
+      }
+      enum "Asia/Karachi" {
+        value 290;
+      }
+      enum "Europe/Warsaw" {
+        value 291;
+      }
+      enum "America/Miquelon" {
+        value 292;
+      }
+      enum "Pacific/Pitcairn" {
+        value 293;
+      }
+      enum "America/Puerto_Rico" {
+        value 294;
+      }
+      enum "Asia/Gaza" {
+        value 295;
+        description
+          "Gaza Strip";
+      }
+      enum "Asia/Hebron" {
+        value 296;
+        description
+          "West Bank";
+      }
+      enum "Europe/Lisbon" {
+        value 297;
+        description
+          "mainland";
+      }
+      enum "Atlantic/Madeira" {
+        value 298;
+        description
+          "Madeira Islands";
+      }
+      enum "Atlantic/Azores" {
+        value 299;
+        description
+          "Azores";
+      }
+      enum "Pacific/Palau" {
+        value 300;
+      }
+      enum "America/Asuncion" {
+        value 301;
+      }
+      enum "Asia/Qatar" {
+        value 302;
+      }
+      enum "Indian/Reunion" {
+        value 303;
+      }
+      enum "Europe/Bucharest" {
+        value 304;
+      }
+      enum "Europe/Belgrade" {
+        value 305;
+      }
+      enum "Europe/Kaliningrad" {
+        value 306;
+        description
+          "Moscow-01 - Kaliningrad";
+      }
+      enum "Europe/Moscow" {
+        value 307;
+        description
+          "Moscow+00 - west Russia";
+      }
+      enum "Europe/Volgograd" {
+        value 308;
+        description
+          "Moscow+00 - Caspian Sea";
+      }
+      enum "Europe/Samara" {
+        value 309;
+        description
+          "Moscow+00 - Samara, Udmurtia";
+      }
+      enum "Asia/Yekaterinburg" {
+        value 310;
+        description
+          "Moscow+02 - Urals";
+      }
+      enum "Asia/Omsk" {
+        value 311;
+        description
+          "Moscow+03 - west Siberia";
+      }
+      enum "Asia/Novosibirsk" {
+        value 312;
+        description
+          "Moscow+03 - Novosibirsk";
+      }
+      enum "Asia/Novokuznetsk" {
+        value 313;
+        description
+          "Moscow+03 - Novokuznetsk";
+      }
+      enum "Asia/Krasnoyarsk" {
+        value 314;
+        description
+          "Moscow+04 - Yenisei River";
+      }
+      enum "Asia/Irkutsk" {
+        value 315;
+        description
+          "Moscow+05 - Lake Baikal";
+      }
+      enum "Asia/Yakutsk" {
+        value 316;
+        description
+          "Moscow+06 - Lena River";
+      }
+      enum "Asia/Vladivostok" {
+        value 317;
+        description
+          "Moscow+07 - Amur River";
+      }
+      enum "Asia/Sakhalin" {
+        value 318;
+        description
+          "Moscow+07 - Sakhalin Island";
+      }
+      enum "Asia/Magadan" {
+        value 319;
+        description
+          "Moscow+08 - Magadan";
+      }
+      enum "Asia/Kamchatka" {
+        value 320;
+        description
+          "Moscow+08 - Kamchatka";
+      }
+      enum "Asia/Anadyr" {
+        value 321;
+        description
+          "Moscow+08 - Bering Sea";
+      }
+      enum "Africa/Kigali" {
+        value 322;
+      }
+      enum "Asia/Riyadh" {
+        value 323;
+      }
+      enum "Pacific/Guadalcanal" {
+        value 324;
+      }
+      enum "Indian/Mahe" {
+        value 325;
+      }
+      enum "Africa/Khartoum" {
+        value 326;
+      }
+      enum "Europe/Stockholm" {
+        value 327;
+      }
+      enum "Asia/Singapore" {
+        value 328;
+      }
+      enum "Atlantic/St_Helena" {
+        value 329;
+      }
+      enum "Europe/Ljubljana" {
+        value 330;
+      }
+      enum "Arctic/Longyearbyen" {
+        value 331;
+      }
+      enum "Europe/Bratislava" {
+        value 332;
+      }
+      enum "Africa/Freetown" {
+        value 333;
+      }
+      enum "Europe/San_Marino" {
+        value 334;
+      }
+      enum "Africa/Dakar" {
+        value 335;
+      }
+      enum "Africa/Mogadishu" {
+        value 336;
+      }
+      enum "America/Paramaribo" {
+        value 337;
+      }
+      enum "Africa/Juba" {
+        value 338;
+      }
+      enum "Africa/Sao_Tome" {
+        value 339;
+      }
+      enum "America/El_Salvador" {
+        value 340;
+      }
+      enum "America/Lower_Princes" {
+        value 341;
+      }
+      enum "Asia/Damascus" {
+        value 342;
+      }
+      enum "Africa/Mbabane" {
+        value 343;
+      }
+      enum "America/Grand_Turk" {
+        value 344;
+      }
+      enum "Africa/Ndjamena" {
+        value 345;
+      }
+      enum "Indian/Kerguelen" {
+        value 346;
+      }
+      enum "Africa/Lome" {
+        value 347;
+      }
+      enum "Asia/Bangkok" {
+        value 348;
+      }
+      enum "Asia/Dushanbe" {
+        value 349;
+      }
+      enum "Pacific/Fakaofo" {
+        value 350;
+      }
+      enum "Asia/Dili" {
+        value 351;
+      }
+      enum "Asia/Ashgabat" {
+        value 352;
+      }
+      enum "Africa/Tunis" {
+        value 353;
+      }
+      enum "Pacific/Tongatapu" {
+        value 354;
+      }
+      enum "Europe/Istanbul" {
+        value 355;
+      }
+      enum "America/Port_of_Spain" {
+        value 356;
+      }
+      enum "Pacific/Funafuti" {
+        value 357;
+      }
+      enum "Asia/Taipei" {
+        value 358;
+      }
+      enum "Africa/Dar_es_Salaam" {
+        value 359;
+      }
+      enum "Europe/Kiev" {
+        value 360;
+        description
+          "most locations";
+      }
+      enum "Europe/Uzhgorod" {
+        value 361;
+        description
+          "Ruthenia";
+      }
+      enum "Europe/Zaporozhye" {
+        value 362;
+        description
+          "Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk";
+      }
+      enum "Europe/Simferopol" {
+        value 363;
+        description
+          "central Crimea";
+      }
+      enum "Africa/Kampala" {
+        value 364;
+      }
+      enum "Pacific/Johnston" {
+        value 365;
+        description
+          "Johnston Atoll";
+      }
+      enum "Pacific/Midway" {
+        value 366;
+        description
+          "Midway Islands";
+      }
+      enum "Pacific/Wake" {
+        value 367;
+        description
+          "Wake Island";
+      }
+      enum "America/New_York" {
+        value 368;
+        description
+          "Eastern Time";
+      }
+      enum "America/Detroit" {
+        value 369;
+        description
+          "Eastern Time - Michigan - most locations";
+      }
+      enum "America/Kentucky/Louisville" {
+        value 370;
+        description
+          "Eastern Time - Kentucky - Louisville area";
+      }
+      enum "America/Kentucky/Monticello" {
+        value 371;
+        description
+          "Eastern Time - Kentucky - Wayne County";
+      }
+      enum "America/Indiana/Indianapolis" {
+        value 372;
+        description
+          "Eastern Time - Indiana - most locations";
+      }
+      enum "America/Indiana/Vincennes" {
+        value 373;
+        description
+          "Eastern Time - Indiana - Daviess, Dubois, Knox & Martin
+           Counties";
+      }
+      enum "America/Indiana/Winamac" {
+        value 374;
+        description
+          "Eastern Time - Indiana - Pulaski County";
+      }
+      enum "America/Indiana/Marengo" {
+        value 375;
+        description
+          "Eastern Time - Indiana - Crawford County";
+      }
+      enum "America/Indiana/Petersburg" {
+        value 376;
+        description
+          "Eastern Time - Indiana - Pike County";
+      }
+      enum "America/Indiana/Vevay" {
+        value 377;
+        description
+          "Eastern Time - Indiana - Switzerland County";
+      }
+      enum "America/Chicago" {
+        value 378;
+        description
+          "Central Time";
+      }
+      enum "America/Indiana/Tell_City" {
+        value 379;
+        description
+          "Central Time - Indiana - Perry County";
+      }
+      enum "America/Indiana/Knox" {
+        value 380;
+        description
+          "Central Time - Indiana - Starke County";
+      }
+      enum "America/Menominee" {
+        value 381;
+        description
+          "Central Time - Michigan - Dickinson, Gogebic, Iron &
+           Menominee Counties";
+      }
+      enum "America/North_Dakota/Center" {
+        value 382;
+        description
+          "Central Time - North Dakota - Oliver County";
+      }
+      enum "America/North_Dakota/New_Salem" {
+        value 383;
+        description
+          "Central Time - North Dakota - Morton County (except Mandan
+           area)";
+      }
+      enum "America/North_Dakota/Beulah" {
+        value 384;
+        description
+          "Central Time - North Dakota - Mercer County";
+      }
+      enum "America/Denver" {
+        value 385;
+        description
+          "Mountain Time";
+      }
+      enum "America/Boise" {
+        value 386;
+        description
+          "Mountain Time - south Idaho & east Oregon";
+      }
+      enum "America/Shiprock" {
+        value 387;
+        description
+          "Mountain Time - Navajo";
+      }
+      enum "America/Phoenix" {
+        value 388;
+        description
+          "Mountain Standard Time - Arizona";
+      }
+      enum "America/Los_Angeles" {
+        value 389;
+        description
+          "Pacific Time";
+      }
+      enum "America/Anchorage" {
+        value 390;
+        description
+          "Alaska Time";
+      }
+      enum "America/Juneau" {
+        value 391;
+        description
+          "Alaska Time - Alaska panhandle";
+      }
+      enum "America/Sitka" {
+        value 392;
+        description
+          "Alaska Time - southeast Alaska panhandle";
+      }
+      enum "America/Yakutat" {
+        value 393;
+        description
+          "Alaska Time - Alaska panhandle neck";
+      }
+      enum "America/Nome" {
+        value 394;
+        description
+          "Alaska Time - west Alaska";
+      }
+      enum "America/Adak" {
+        value 395;
+        description
+          "Aleutian Islands";
+      }
+      enum "America/Metlakatla" {
+        value 396;
+        description
+          "Metlakatla Time - Annette Island";
+      }
+      enum "Pacific/Honolulu" {
+        value 397;
+        description
+          "Hawaii";
+      }
+      enum "America/Montevideo" {
+        value 398;
+      }
+      enum "Asia/Samarkand" {
+        value 399;
+        description
+          "west Uzbekistan";
+      }
+      enum "Asia/Tashkent" {
+        value 400;
+        description
+          "east Uzbekistan";
+      }
+      enum "Europe/Vatican" {
+        value 401;
+      }
+      enum "America/St_Vincent" {
+        value 402;
+      }
+      enum "America/Caracas" {
+        value 403;
+      }
+      enum "America/Tortola" {
+        value 404;
+      }
+      enum "America/St_Thomas" {
+        value 405;
+      }
+      enum "Asia/Ho_Chi_Minh" {
+        value 406;
+      }
+      enum "Pacific/Efate" {
+        value 407;
+      }
+      enum "Pacific/Wallis" {
+        value 408;
+      }
+      enum "Pacific/Apia" {
+        value 409;
+      }
+      enum "Asia/Aden" {
+        value 410;
+      }
+      enum "Indian/Mayotte" {
+        value 411;
+      }
+      enum "Africa/Johannesburg" {
+        value 412;
+      }
+      enum "Africa/Lusaka" {
+        value 413;
+      }
+      enum "Africa/Harare" {
+        value 414;
+      }
+    }
+  }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-inet-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-inet-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..de20feb
--- /dev/null
@@ -0,0 +1,418 @@
+ module ietf-inet-types {
+
+   namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+   prefix "inet";
+
+   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 for Internet addresses and related things.
+
+     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 protocol field related types ***/
+
+   typedef ip-version {
+     type enumeration {
+       enum unknown {
+         value "0";
+         description
+          "An unknown or unspecified version of the Internet protocol.";
+       }
+       enum ipv4 {
+         value "1";
+         description
+          "The IPv4 protocol as defined in RFC 791.";
+       }
+       enum ipv6 {
+         value "2";
+         description
+          "The IPv6 protocol as defined in RFC 2460.";
+       }
+     }
+     description
+      "This value represents the version of the IP protocol.
+
+       In the value set and its semantics, this type is equivalent
+       to the InetVersion textual convention of the SMIv2.";
+     reference
+      "RFC  791: Internet Protocol
+       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+       RFC 4001: Textual Conventions for Internet Network Addresses";
+   }
+
+   typedef dscp {
+     type uint8 {
+       range "0..63";
+     }
+     description
+      "The dscp type represents a Differentiated Services Code-Point
+       that may be used for marking packets in a traffic stream.
+
+       In the value set and its semantics, this type is equivalent
+       to the Dscp textual convention of the SMIv2.";
+     reference
+      "RFC 3289: Management Information Base for the Differentiated
+                 Services Architecture
+       RFC 2474: Definition of the Differentiated Services Field
+                 (DS Field) in the IPv4 and IPv6 Headers
+       RFC 2780: IANA Allocation Guidelines For Values In
+                 the Internet Protocol and Related Headers";
+   }
+
+   typedef ipv6-flow-label {
+     type uint32 {
+       range "0..1048575";
+     }
+     description
+      "The flow-label type represents flow identifier or Flow Label
+       in an IPv6 packet header that may be used to discriminate
+       traffic flows.
+
+       In the value set and its semantics, this type is equivalent
+       to the IPv6FlowLabel textual convention of the SMIv2.";
+     reference
+      "RFC 3595: Textual Conventions for IPv6 Flow Label
+       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+   }
+
+   typedef port-number {
+     type uint16 {
+       range "0..65535";
+     }
+     description
+      "The port-number type represents a 16-bit port number of an
+       Internet transport layer protocol such as UDP, TCP, DCCP, or
+       SCTP.  Port numbers are assigned by IANA.  A current list of
+       all assignments is available from <http://www.iana.org/>.
+
+       Note that the port number value zero is reserved by IANA.  In
+       situations where the value zero does not make sense, it can
+       be excluded by subtyping the port-number type.
+
+       In the value set and its semantics, this type is equivalent
+       to the InetPortNumber textual convention of the SMIv2.";
+     reference
+      "RFC  768: User Datagram Protocol
+       RFC  793: Transmission Control Protocol
+       RFC 4960: Stream Control Transmission Protocol
+       RFC 4340: Datagram Congestion Control Protocol (DCCP)
+       RFC 4001: Textual Conventions for Internet Network Addresses";
+   }
+
+   /*** collection of autonomous system related types ***/
+
+   typedef as-number {
+     type uint32;
+     description
+      "The as-number type represents autonomous system numbers
+       which identify an Autonomous System (AS).  An AS is a set
+       of routers under a single technical administration, using
+       an interior gateway protocol and common metrics to route
+       packets within the AS, and using an exterior gateway
+       protocol to route packets to other ASs'.  IANA maintains
+       the AS number space and has delegated large parts to the
+       regional registries.
+
+       Autonomous system numbers were originally limited to 16
+       bits.  BGP extensions have enlarged the autonomous system
+       number space to 32 bits.  This type therefore uses an uint32
+       base type without a range restriction in order to support
+       a larger autonomous system number space.
+
+       In the value set and its semantics, this type is equivalent
+       to the InetAutonomousSystemNumber textual convention of
+       the SMIv2.";
+     reference
+      "RFC 1930: Guidelines for creation, selection, and registration
+                 of an Autonomous System (AS)
+       RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+       RFC 4893: BGP Support for Four-octet AS Number Space
+       RFC 4001: Textual Conventions for Internet Network Addresses";
+   }
+
+   /*** collection of IP address and hostname related types ***/
+
+   typedef ip-address {
+     type union {
+       type inet:ipv4-address;
+       type inet:ipv6-address;
+     }
+     description
+      "The ip-address type represents an IP address and is IP
+       version neutral.  The format of the textual representations
+       implies the IP version.";
+   }
+
+   typedef ipv4-address {
+     type string {
+       pattern
+         '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+       +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
+       + '(%[\p{N}\p{L}]+)?';
+     }
+     description
+       "The ipv4-address type represents an IPv4 address in
+        dotted-quad notation.  The IPv4 address may include a zone
+        index, separated by a % sign.
+
+        The zone index is used to disambiguate identical address
+        values.  For link-local addresses, the zone index will
+        typically be the interface index number or the name of an
+        interface.  If the zone index is not present, the default
+        zone of the device will be used.
+
+        The canonical format for the zone index is the numerical
+        format";
+   }
+
+   typedef ipv6-address {
+     type string {
+       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
+             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
+             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
+             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
+             + '(%[\p{N}\p{L}]+)?';
+       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
+             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
+             + '(%.+)?';
+     }
+     description
+      "The ipv6-address type represents an IPv6 address in full,
+       mixed, shortened, and shortened-mixed notation.  The IPv6
+       address may include a zone index, separated by a % sign.
+
+       The zone index is used to disambiguate identical address
+       values.  For link-local addresses, the zone index will
+       typically be the interface index number or the name of an
+       interface.  If the zone index is not present, the default
+       zone of the device will be used.
+
+       The canonical format of IPv6 addresses uses the compressed
+       format described in RFC 4291, Section 2.2, item 2 with the
+       following additional rules: the :: substitution must be
+       applied to the longest sequence of all-zero 16-bit chunks
+       in an IPv6 address.  If there is a tie, the first sequence
+       of all-zero 16-bit chunks is replaced by ::.  Single
+       all-zero 16-bit chunks are not compressed.  The canonical
+       format uses lowercase characters and leading zeros are
+       not allowed.  The canonical format for the zone index is
+       the numerical format as described in RFC 4007, Section
+       11.2.";
+     reference
+      "RFC 4291: IP Version 6 Addressing Architecture
+       RFC 4007: IPv6 Scoped Address Architecture
+       RFC 5952: A Recommendation for IPv6 Address Text Representation";
+   }
+
+   typedef ip-prefix {
+     type union {
+       type inet:ipv4-prefix;
+       type inet:ipv6-prefix;
+     }
+     description
+      "The ip-prefix type represents an IP prefix and is IP
+       version neutral.  The format of the textual representations
+       implies the IP version.";
+   }
+
+   typedef ipv4-prefix {
+     type string {
+       pattern
+          '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
+        +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
+        + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
+     }
+     description
+      "The ipv4-prefix type represents an IPv4 address prefix.
+       The prefix length is given by the number following the
+       slash character and must be less than or equal to 32.
+
+       A prefix length value of n corresponds to an IP address
+       mask that has n contiguous 1-bits from the most
+       significant bit (MSB) and all other bits set to 0.
+
+       The canonical format of an IPv4 prefix has all bits of
+       the IPv4 address set to zero that are not part of the
+       IPv4 prefix.";
+   }
+
+   typedef ipv6-prefix {
+     type string {
+       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
+             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
+             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
+             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
+             + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
+             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
+             + '(/.+)';
+     }
+     description
+      "The ipv6-prefix type represents an IPv6 address prefix.
+       The prefix length is given by the number following the
+       slash character and must be less than or equal 128.
+
+       A prefix length value of n corresponds to an IP address
+       mask that has n contiguous 1-bits from the most
+       significant bit (MSB) and all other bits set to 0.
+
+       The IPv6 address should have all bits that do not belong
+       to the prefix set to zero.
+
+       The canonical format of an IPv6 prefix has all bits of
+       the IPv6 address set to zero that are not part of the
+       IPv6 prefix.  Furthermore, IPv6 address is represented
+       in the compressed format described in RFC 4291, Section
+       2.2, item 2 with the following additional rules: the ::
+       substitution must be applied to the longest sequence of
+       all-zero 16-bit chunks in an IPv6 address.  If there is
+       a tie, the first sequence of all-zero 16-bit chunks is
+       replaced by ::.  Single all-zero 16-bit chunks are not
+       compressed.  The canonical format uses lowercase
+       characters and leading zeros are not allowed.";
+     reference
+      "RFC 4291: IP Version 6 Addressing Architecture";
+   }
+
+   /*** collection of domain name and URI types ***/
+
+   typedef domain-name {
+     type string {
+       pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
+            +  '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
+            +  '|\.';
+       length "1..253";
+     }
+     description
+      "The domain-name type represents a DNS domain name.  The
+       name SHOULD be fully qualified whenever possible.
+
+       Internet domain names are only loosely specified.  Section
+       3.5 of RFC 1034 recommends a syntax (modified in Section
+       2.1 of RFC 1123).  The pattern above is intended to allow
+       for current practice in domain name use, and some possible
+       future expansion.  It is designed to hold various types of
+       domain names, including names used for A or AAAA records
+       (host names) and other records, such as SRV records.  Note
+       that Internet host names have a stricter syntax (described
+       in RFC 952) than the DNS recommendations in RFCs 1034 and
+       1123, and that systems that want to store host names in
+       schema nodes using the domain-name type are recommended to
+       adhere to this stricter standard to ensure interoperability.
+
+       The encoding of DNS names in the DNS protocol is limited
+       to 255 characters.  Since the encoding consists of labels
+       prefixed by a length bytes and there is a trailing NULL
+       byte, only 253 characters can appear in the textual dotted
+       notation.
+
+       The description clause of schema nodes using the domain-name
+       type MUST describe when and how these names are resolved to
+       IP addresses.  Note that the resolution of a domain-name value
+       may require to query multiple DNS records (e.g., A for IPv4
+       and AAAA for IPv6).  The order of the resolution process and
+       which DNS record takes precedence can either be defined
+       explicitely or it may depend on the configuration of the
+       resolver.
+
+       Domain-name values use the US-ASCII encoding.  Their canonical
+       format uses lowercase US-ASCII characters.  Internationalized
+       domain names MUST be encoded in punycode as described in RFC
+       3492";
+     reference
+      "RFC  952: DoD Internet Host Table Specification
+       RFC 1034: Domain Names - Concepts and Facilities
+       RFC 1123: Requirements for Internet Hosts -- Application
+                 and Support
+       RFC 2782: A DNS RR for specifying the location of services
+                 (DNS SRV)
+       RFC 3492: Punycode: A Bootstring encoding of Unicode for
+                 Internationalized Domain Names in Applications
+                 (IDNA)
+       RFC 5891: Internationalizing Domain Names in Applications
+                 (IDNA): Protocol";
+   }
+
+   typedef host {
+     type union {
+       type inet:ip-address;
+       type inet:domain-name;
+     }
+     description
+      "The host type represents either an IP address or a DNS
+       domain name.";
+   }
+
+   typedef uri {
+     type string;
+     description
+      "The uri type represents a Uniform Resource Identifier
+       (URI) as defined by STD 66.
+
+       Objects using the uri type MUST be in US-ASCII encoding,
+       and MUST be normalized as described by RFC 3986 Sections
+       6.2.1, 6.2.2.1, and 6.2.2.2.  All unnecessary
+       percent-encoding is removed, and all case-insensitive
+       characters are set to lowercase except for hexadecimal
+       digits, which are normalized to uppercase as described in
+       Section 6.2.2.1.
+
+       The purpose of this normalization is to help provide
+       unique URIs.  Note that this normalization is not
+       sufficient to provide uniqueness.  Two URIs that are
+       textually distinct after this normalization may still be
+       equivalent.
+
+       Objects using the uri type may restrict the schemes that
+       they permit.  For example, 'data:' and 'urn:' schemes
+       might not be appropriate.
+
+       A zero-length URI is not a valid URI.  This can be used to
+       express 'URI absent' where required.
+
+       In the value set and its semantics, this type is equivalent
+       to the Uri SMIv2 textual convention defined in RFC 5017.";
+     reference
+      "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+       RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+                 Group: Uniform Resource Identifiers (URIs), URLs,
+                 and Uniform Resource Names (URNs): Clarifications
+                 and Recommendations
+       RFC 5017: MIB Textual Conventions for Uniform Resource
+                 Identifiers (URIs)";
+   }
+
+ }
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-yang-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/types/ietf-yang-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..51d9f8b
--- /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";
+   }
+
+ }
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnionType.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnionType.java
new file mode 100644 (file)
index 0000000..9bac8bc
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+  * 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.model.util;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.model.api.type.UnionTypeDefinition;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+
+public class UnionType implements UnionTypeDefinition {
+
+    private final QName name = BaseTypes.constructQName("union");
+    private final SchemaPath path = BaseTypes.schemaPath(name);
+    private final String description = "The union built-in type represents a value that corresponds to one of its member types.";
+    private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.12";
+
+    private final List<TypeDefinition<?>> types;
+
+
+    public UnionType(List<TypeDefinition<?>> types) {
+        if(types == null) {
+            throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+        }
+        this.types = types;
+    }
+
+    @Override
+    public UnionTypeDefinition getBaseType() {
+        return this;
+    }
+
+    @Override
+    public String getUnits() {
+        return null;
+    }
+
+    @Override
+    public Object getDefaultValue() {
+        return null;
+    }
+
+    @Override
+    public QName getQName() {
+        return name;
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public String getReference() {
+        return reference;
+    }
+
+    @Override
+    public Status getStatus() {
+        return Status.CURRENT;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public List<TypeDefinition<?>> getTypes() {
+        return types;
+    }
+
+    @Override
+    public int hashCode() {
+        // TODO: implement hashcode
+        return 4;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        UnionType other = (UnionType) obj;
+        if (types == null) {
+            if (other.types != null) {
+                return false;
+            }
+        } else if (!types.equals(other.types)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("UnionType [name=");
+        builder.append(name);
+        builder.append(", types=[");
+        for(TypeDefinition<?> td : types) {
+            builder.append(", "+ td.getQName().getLocalName());
+        }
+        builder.append("]");
+        builder.append("]");
+        return builder.toString();
+    }
+
+}