2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\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
8 package org.opendaylight.controller;
\r
10 import java.io.File;
\r
11 import java.util.Set;
\r
13 import org.opendaylight.controller.yang.model.api.Module;
\r
14 import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;
\r
18 public static void main(String[] args) throws Exception {
\r
20 String yangFilesDir;
\r
21 if (args.length > 0) {
\r
22 yangFilesDir = args[0];
\r
24 yangFilesDir = "src/main/resources/demo";
\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
34 String[] dirList = resourceDir.list();
\r
35 String[] absFiles = new String[dirList.length];
\r
38 for (String fileName : dirList) {
\r
39 File abs = new File(resourceDir, fileName);
\r
40 absFiles[i] = abs.getAbsolutePath();
\r
44 YangModelParserImpl parser = new YangModelParserImpl();
\r
45 Set<Module> builtModules = parser.parseYangModels(absFiles);
\r
47 System.out.println("Modules built: " + builtModules.size());
\r