/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. \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
-\r
package org.opendaylight.controller;\r
\r
import java.io.File;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.controller.model.parser.builder.YangModelBuilder;\r
-\r
+import java.util.Set;\r
\r
+import org.opendaylight.controller.yang.model.api.Module;\r
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;\r
\r
public class Demo {\r
\r
- public static void main(String[] args) throws Exception {\r
-\r
- String yangFilesDir;\r
- if(args.length > 0) {\r
- yangFilesDir = args[0];\r
- } else {\r
- yangFilesDir = "src/main/resources";\r
- }\r
-\r
- File resourceDir = new File(yangFilesDir);\r
- if(!resourceDir.exists()) {\r
- throw new IllegalArgumentException("Specified resource directory does not exists: "+ resourceDir.getAbsolutePath());\r
- }\r
-\r
- String[] dirList = resourceDir.list();\r
- String[] absFiles = new String[dirList.length];\r
-\r
- int i = 0;\r
- for(String fileName : dirList) {\r
- File f = new File(fileName);\r
- absFiles[i] = f.getAbsolutePath();\r
- i++;\r
- }\r
-\r
- YangModelBuilder builder = new YangModelBuilder(absFiles);\r
- Map<String, org.opendaylight.controller.yang.model.api.Module> builtModules = builder.build();\r
-\r
- System.out.println("Modules built: "+ builtModules.size());\r
- }\r
+ public static void main(String[] args) throws Exception {\r
+\r
+ String yangFilesDir;\r
+ if (args.length > 0) {\r
+ yangFilesDir = args[0];\r
+ } else {\r
+ yangFilesDir = "src/main/resources/demo";\r
+ }\r
+\r
+ File resourceDir = new File(yangFilesDir);\r
+ if (!resourceDir.exists()) {\r
+ throw new IllegalArgumentException(\r
+ "Specified resource directory does not exists: "\r
+ + resourceDir.getAbsolutePath());\r
+ }\r
+\r
+ String[] dirList = resourceDir.list();\r
+ String[] absFiles = new String[dirList.length];\r
+\r
+ int i = 0;\r
+ for (String fileName : dirList) {\r
+ File abs = new File(resourceDir, fileName);\r
+ absFiles[i] = abs.getAbsolutePath();\r
+ i++;\r
+ }\r
+\r
+ YangModelParserImpl parser = new YangModelParserImpl();\r
+ Set<Module> builtModules = parser.parseYangModels(absFiles);\r
+\r
+ System.out.println("Modules built: " + builtModules.size());\r
+ }\r
\r
}\r