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.Collection;
13 import java.util.List;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.api.type.UnknownTypeDefinition;
22 * Yang Model Parser interface is designed for parsing yang models and convert
23 * the information to Data Schema Tree.
26 // FIXME: refactor methods returning input streams, after introducing (?)
27 public interface YangModelParser {
30 * Parse yangFile file and all yang files found in directory.
35 * directory which contains additional yang files
36 * @return Set of Yang Modules
37 * @deprecated Use {@link YangContextParser#parseFile(File, File)} instead
40 Set<Module> parseYangModels(final File yangFile, final File directory);
43 * Parse one or more Yang model files and return the definitions of Yang
44 * modules defined in *.yang files; <br>
45 * This method SHOULD be used if user need to parse multiple yang models
46 * that are referenced either through import or include statements.
50 * @return Set of Yang Modules
51 * @deprecated Use {@link YangContextParser#parseFiles(Collection)} instead
54 Set<Module> parseYangModels(final List<File> yangFiles);
57 * Parse one or more Yang model files and return the definitions of Yang
58 * modules defined in *.yang files. <br>
59 * This method SHOULD be used if user has already parsed context and need to
60 * parse additinal yang models which can have dependencies on models in this
66 * SchemaContext containing already parsed yang models
67 * @return Set of Yang Modules
68 * @deprecated Use {@link YangContextParser#parseFiles(Collection, SchemaContext)} instead
71 Set<Module> parseYangModels(final List<File> yangFiles, final SchemaContext context);
74 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
75 * mapped to Files from which they were parsed.
79 * @return Map of Yang Modules
81 Map<File, Module> parseYangModelsMapped(final Collection<File> yangFiles);
84 * Parse one or more Yang model streams and return the definitions of Yang
85 * modules defined in *.yang files; <br>
86 * This method SHOULD be used if user need to parse multiple yang models
87 * that are referenced either through import or include statements.
89 * @param yangModelStreams
90 * yang streams to parse
91 * @return Set of Yang Modules
92 * @deprecated Use {@link YangContextParser#parseSources(Collection)} instead
95 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams);
98 * Parse one or more Yang model streams and return the definitions of Yang
99 * modules defined in *.yang files. <br>
100 * This method SHOULD be used if user has already parsed context and need to
101 * parse additinal yang models which can have dependencies on models in this
104 * @param yangModelStreams
105 * yang streams to parse
107 * SchemaContext containing already parsed yang models
108 * @return Set of Yang Modules
109 * @deprecated Use {@link YangContextParser#parseSources(Collection, SchemaContext)} instead
112 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams, final SchemaContext context);
115 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
116 * mapped to InputStreams from which they were parsed.
118 * @param yangModelStreams
119 * yang streams to parse
120 * @return Map of Yang Modules
122 //TODO: when working with input streams do not swallow IOException, it should be propagated without having to wrap it in a runtime exception
123 //FIXME: it is not defined in which state are the returning streams.
124 Map<InputStream, Module> parseYangModelsFromStreamsMapped(final Collection<InputStream> yangModelStreams);
127 * Creates {@link SchemaContext} from specified Modules. The modules SHOULD
128 * not contain any unresolved Schema Nodes or Type Definitions. By
129 * unresolved Schema Nodes or Type Definitions we mean that the Module
130 * should not contain ANY Schema Nodes that contains
131 * {@link UnknownTypeDefinition} and all dependencies although via import or
132 * include definitions are resolved.
135 * Set of Yang Modules
136 * @return Schema Context instance constructed from whole Set of Modules.
138 SchemaContext resolveSchemaContext(final Set<Module> modules);