2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.parser.api;
11 import java.io.InputStream;
12 import java.util.List;
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;
21 * Yang Model Parser interface is designed for parsing yang models and convert
22 * the information to Data Schema Tree.
25 public interface YangModelParser {
28 * Parse yangFile file and all yang files found in directory.
33 * directory which contains additional yang files
34 * @return Set of Yang Modules
36 Set<Module> parseYangModels(final File yangFile, final File directory);
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.
46 * @return Set of Yang Modules
48 Set<Module> parseYangModels(final List<File> yangFiles);
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
60 * SchemaContext containing already parsed yang models
61 * @return Set of Yang Modules
63 Set<Module> parseYangModels(final List<File> yangFiles, final SchemaContext context);
66 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
67 * mapped to Files from which they were parsed.
71 * @return Map of Yang Modules
73 Map<File, Module> parseYangModelsMapped(final List<File> yangFiles);
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.
81 * @param yangModelStreams
82 * yang streams to parse
83 * @return Set of Yang Modules
85 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams);
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
94 * @param yangModelStreams
95 * yang streams to parse
97 * SchemaContext containing already parsed yang models
98 * @return Set of Yang Modules
100 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams, final SchemaContext context);
103 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
104 * mapped to IputStreams from which they were parsed.
106 * @param yangModelStreams
107 * yang streams to parse
108 * @return Map of Yang Modules
110 Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams);
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.
121 * Set of Yang Modules
122 * @return Schema Context instance constructed from whole Set of Modules.
124 SchemaContext resolveSchemaContext(final Set<Module> modules);