Merge from development repository.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / code-generator-demo / src / main / java / org / opendaylight / controller / Demo.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller;\r
9 \r
10 import java.io.File;\r
11 import java.util.Set;\r
12 \r
13 import org.opendaylight.controller.yang.model.api.Module;\r
14 import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;\r
15 \r
16 public class Demo {\r
17 \r
18     public static void main(String[] args) throws Exception {\r
19 \r
20         String yangFilesDir;\r
21         if (args.length > 0) {\r
22             yangFilesDir = args[0];\r
23         } else {\r
24             yangFilesDir = "src/main/resources/demo";\r
25         }\r
26 \r
27         File resourceDir = new File(yangFilesDir);\r
28         if (!resourceDir.exists()) {\r
29             throw new IllegalArgumentException(\r
30                     "Specified resource directory does not exists: "\r
31                             + resourceDir.getAbsolutePath());\r
32         }\r
33 \r
34         String[] dirList = resourceDir.list();\r
35         String[] absFiles = new String[dirList.length];\r
36 \r
37         int i = 0;\r
38         for (String fileName : dirList) {\r
39             File abs = new File(resourceDir, fileName);\r
40             absFiles[i] = abs.getAbsolutePath();\r
41             i++;\r
42         }\r
43 \r
44         YangModelParserImpl parser = new YangModelParserImpl();\r
45         Set<Module> builtModules = parser.parseYangModels(absFiles);\r
46 \r
47         System.out.println("Modules built: " + builtModules.size());\r
48     }\r
49 \r
50 }\r