2 * Copyright (c) 2015 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.parser.spi.source;
12 * Statement stream source, which is used for inference of effective model.
15 * Statement stream source is required to emit its statements using supplied
16 * {@link StatementWriter}.
19 * Since YANG allows language extensions defined in sources (which defines how
20 * source is serialized), instances of extensions present anywhere and forward
21 * references, each source needs to be processed in three steps, where each step
22 * uses different set of supported statements.
24 * Steps (in order of invocation) are:
27 * <li>{@link #writeLinkage(StatementWriter, QNameToStatementDefinition)} -
28 * Source MUST emit only statements related in linkage, which are present in
29 * supplied statement definition map. This step is used to build cross-source
30 * linkage and visibility relationship, and to determine XMl namespaces and
33 * {@link #writeLinkageAndStatementDefinitions(StatementWriter, QNameToStatementDefinition, PrefixToModule)}
34 * - Source MUST emit only statements related to linkage and language extensions
35 * definitions, which are present in supplied statement definition map. This
36 * step is used to build statement definitions in order to fully processed
39 * {@link #writeFull(StatementWriter, QNameToStatementDefinition, PrefixToModule)}
40 * - Source MUST emit all statements present in source. This step is used to
41 * build full declared statement model of source.</li>
45 public interface StatementStreamSource {
49 * Emits only linkage-related statements to supplied {@code writer}.
52 * {@link StatementWriter} which should be used to emit
55 * Map of available statement definitions. Only these statements
56 * may be written to statement writer, source MUST ignore and MUST NOT
57 * emit any other statements.
59 * @throws SourceException
60 * If source was is not valid, or provided statement writer
61 * failed to write statements.
63 void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException;
67 * Emits only linkage and language extension statements to supplied
71 * {@link StatementWriter} which should be used to emit
74 * Map of available statement definitions. Only these statements
75 * may be written to statement writer, source MUST ignore and MUST NOT
76 * emit any other statements.
78 * Map of source-specific prefixes to namespaces
80 * @throws SourceException
81 * If source was is not valid, or provided statement writer
82 * failed to write statements.
84 void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException;
88 * Emits every statements present in this statement source to supplied
92 * {@link StatementWriter} which should be used to emit
95 * Map of available statement definitions.
97 * Map of source-specific prefixes to namespaces
98 * @throws SourceException
99 * If source was is not valid, or provided statement writer
100 * failed to write statements.
102 void writeFull(StatementWriter writer,QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException;