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.controller.yang.model.parser.api;
11 import java.io.InputStream;
12 import java.util.List;
16 import org.opendaylight.controller.yang.model.api.Module;
17 import org.opendaylight.controller.yang.model.api.SchemaContext;
18 import org.opendaylight.controller.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 one or more Yang model files and return the definitions of Yang
29 * modules defined in *.yang files; <br>
30 * This method SHOULD be used if user need to parse multiple yang models
31 * that are referenced either through import or include statements.
35 * @return Set of Yang Modules
37 Set<Module> parseYangModels(final List<File> yangFiles);
40 * Parse one or more Yang model files and return the definitions of Yang
41 * modules defined in *.yang files. <br>
42 * This method SHOULD be used if user has already parsed context and need to
43 * parse additinal yang models which can have dependencies on models in this
49 * SchemaContext containing already parsed yang models
50 * @return Set of Yang Modules
52 Set<Module> parseYangModels(final List<File> yangFiles, final SchemaContext context);
55 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
56 * mapped to Files from which they were parsed.
60 * @return Map of Yang Modules
62 Map<File, Module> parseYangModelsMapped(final List<File> yangFiles);
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.
70 * @param yangModelStreams
71 * yang streams to parse
72 * @return Set of Yang Modules
74 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams);
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
83 * @param yangModelStreams
84 * yang streams to parse
86 * SchemaContext containing already parsed yang models
87 * @return Set of Yang Modules
89 Set<Module> parseYangModelsFromStreams(final List<InputStream> yangModelStreams, final SchemaContext context);
92 * Equivalent to {@link #parseYangModels(List)} that returns parsed modules
93 * mapped to IputStreams from which they were parsed.
95 * @param yangModelStreams
96 * yang streams to parse
97 * @return Map of Yang Modules
99 Map<InputStream, Module> parseYangModelsFromStreamsMapped(final List<InputStream> yangModelStreams);
102 * Creates {@link SchemaContext} from specified Modules. The modules SHOULD
103 * not contain any unresolved Schema Nodes or Type Definitions. By
104 * unresolved Schema Nodes or Type Definitions we mean that the Module
105 * should not contain ANY Schema Nodes that contains
106 * {@link UnknownTypeDefinition} and all dependencies although via import or
107 * include definitions are resolved.
110 * Set of Yang Modules
111 * @return Schema Context instance constructed from whole Set of Modules.
113 SchemaContext resolveSchemaContext(final Set<Module> modules);