c35a81ac9c1a2bb9f10599d8fcd01c636b6d5069
[yangtools.git] / yang / yang-parser-api / src / main / java / org / opendaylight / yangtools / yang / model / parser / api / YangContextParser.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.IOException;
12 import java.util.Collection;
13
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15
16 import com.google.common.io.ByteSource;
17
18 /**
19  * Parse yang models and convert data to SchemaContext.
20  *
21  */
22 public interface YangContextParser extends YangModelParser {
23
24     /**
25      * Parse yangFile file and all yang files found in directory.
26      *
27      * @param yangFile
28      *            file to parse
29      * @param dependenciesDirectory
30      *            directory which contains additional yang files
31      * @return parsed data as SchemaContext. Resulting context will contains
32      *         only module parsed from yangFile and modules which yangFile needs
33      *         as dependencies.
34      */
35     SchemaContext parseFile(final File yangFile, final File dependenciesDirectory) throws IOException, YangSyntaxErrorException;
36
37     /**
38      * Parse one or more Yang model files and return the definitions of Yang
39      * modules defined in *.yang files; <br>
40      * This method SHOULD be used if user need to parse multiple yang models
41      * that are referenced either through import or include statements.
42      *
43      * @param yangFiles
44      *            yang files to parse
45      * @return parsed data as SchemaContext
46      */
47     SchemaContext parseFiles(final Collection<File> yangFiles) throws IOException;
48
49     /**
50      * Parse one or more Yang model files and return the definitions of Yang
51      * modules defined in *.yang files. <br>
52      * This method SHOULD be used if user has already parsed context and need to
53      * parse additinal yang models which can have dependencies on models in this
54      * context.
55      *
56      * @param yangFiles
57      *            yang files to parse
58      * @param context
59      *            SchemaContext containing already parsed yang models
60      * @return parsed data as SchemaContext
61      */
62     SchemaContext parseFiles(final Collection<File> yangFiles, final SchemaContext context) throws IOException, YangSyntaxErrorException;
63
64     /**
65      * Parse one or more Yang model streams and return the definitions of Yang
66      * modules defined in *.yang files; <br>
67      * This method SHOULD be used if user need to parse multiple yang models
68      * that are referenced either through import or include statements.
69      *
70      * @param sources
71      *            yang streams to parse
72      * @return parsed data as SchemaContext
73      */
74     SchemaContext parseSources(final Collection<ByteSource> sources) throws IOException, YangSyntaxErrorException;
75
76     /**
77      * Parse one or more Yang model streams and return the definitions of Yang
78      * modules defined in *.yang files. <br>
79      * This method SHOULD be used if user has already parsed context and need to
80      * parse additinal yang models which can have dependencies on models in this
81      * context.
82      *
83      * @param sources
84      *            yang streams to parse
85      * @param context
86      *            SchemaContext containing already parsed yang models
87      * @return parsed data as SchemaContext
88      */
89     SchemaContext parseSources(final Collection<ByteSource> sources, final SchemaContext context) throws IOException, YangSyntaxErrorException;
90
91 }