Added new parse method to YangModelParser.
[yangtools.git] / yang / yang-parser-api / src / main / java / org / opendaylight / yangtools / yang / model / parser / api / YangModelParser.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.parser.api;
9
10 import java.io.File;
11 import java.io.InputStream;
12 import java.util.List;
13 import java.util.Map;
14 import java.util.Set;
15
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
19
20 /**
21  * Yang Model Parser interface is designed for parsing yang models and convert
22  * the information to Data Schema Tree.
23  * 
24  */
25 public interface YangModelParser {
26
27     /**
28      * Parse yangFile file and all yang files found in directory.
29      *
30      * @param yangFile
31      *            file to parse
32      * @param directory
33      *            directory which contains additional yang files
34      * @return Set of Yang Modules
35      */
36     Set<Module> parseYangModels(final File yangFile, final File directory);
37
38     /**
39      * Parse one or more Yang model files and return the definitions of Yang
40      * modules defined in *.yang files; <br>
41      * This method SHOULD be used if user need to parse multiple yang models
42      * that are referenced either through import or include statements.
43      * 
44      * @param yangFiles
45      *            yang files to parse
46      * @return Set of Yang Modules
47      */
48     Set<Module> parseYangModels(final List<File> yangFiles);
49
50     /**
51      * Parse one or more Yang model files and return the definitions of Yang
52      * modules defined in *.yang files. <br>
53      * This method SHOULD be used if user has already parsed context and need to
54      * parse additinal yang models which can have dependencies on models in this
55      * context.
56      * 
57      * @param yangFiles
58      *            yang files to parse
59      * @param context
60      *            SchemaContext containing already parsed yang models
61      * @return Set of Yang Modules
62      */
63     Set<Module> parseYangModels(final List<File> yangFiles, final SchemaContext context);
64
65     /**
66      * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
67      * mapped to Files from which they were parsed.
68      * 
69      * @param yangFiles
70      *            yang files to parse
71      * @return Map of Yang Modules
72      */
73     Map<File, Module> parseYangModelsMapped(final List<File> yangFiles);
74
75     /**
76      * Parse one or more Yang model streams and return the definitions of Yang
77      * modules defined in *.yang files; <br>
78      * This method SHOULD be used if user need to parse multiple yang models
79      * that are referenced either through import or include statements.
80      * 
81      * @param yangModelStreams
82      *            yang streams to parse
83      * @return Set of Yang Modules
84      */
85     Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams);
86
87     /**
88      * Parse one or more Yang model streams and return the definitions of Yang
89      * modules defined in *.yang files. <br>
90      * This method SHOULD be used if user has already parsed context and need to
91      * parse additinal yang models which can have dependencies on models in this
92      * context.
93      * 
94      * @param yangModelStreams
95      *            yang streams to parse
96      * @param context
97      *            SchemaContext containing already parsed yang models
98      * @return Set of Yang Modules
99      */
100     Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams, final SchemaContext context);
101
102     /**
103      * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
104      * mapped to IputStreams from which they were parsed.
105      * 
106      * @param yangModelStreams
107      *            yang streams to parse
108      * @return Map of Yang Modules
109      */
110     Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams);
111
112     /**
113      * Creates {@link SchemaContext} from specified Modules. The modules SHOULD
114      * not contain any unresolved Schema Nodes or Type Definitions. By
115      * unresolved Schema Nodes or Type Definitions we mean that the Module
116      * should not contain ANY Schema Nodes that contains
117      * {@link UnknownTypeDefinition} and all dependencies although via import or
118      * include definitions are resolved.
119      * 
120      * @param modules
121      *            Set of Yang Modules
122      * @return Schema Context instance constructed from whole Set of Modules.
123      */
124     SchemaContext resolveSchemaContext(final Set<Module> modules);
125 }