BUG-5717: add unique child identifier
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / source / StatementWriter.java
1 /*
2  * Copyright (c) 2015 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.parser.spi.source;
9
10 import javax.annotation.Nonnull;
11 import javax.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
14
15 public interface StatementWriter {
16
17     /**
18      *
19      * Starts statement with supplied name and location in source.
20      *
21      *
22      * <p>
23      * Each started statement must also be closed by
24      * {@link #endStatement(StatementSourceReference)} in order for stream to be
25      * correct.
26      * </p>
27      * <p>
28      * If statement has substatements, in order to start substatement, call to
29      * {@link #startStatement(int, QName, String, StatementSourceReference)} needs to be done
30      * for substatement.
31      *
32      * @param childId
33      *            Child identifier, unique among siblings
34      *
35      * @param name
36      *            Fully qualified name of statement.
37      * @param argument
38      *            String representation of value as appeared in source, null if not present
39      * @param ref
40      *            Identifier of location in source, which will be used for
41      *            reporting in case of statement processing error.
42      * @throws SourceException
43      *             if statement is not valid according to current context.
44      */
45     void startStatement(final int childId, @Nonnull QName name, @Nullable String argument,
46             @Nonnull StatementSourceReference ref);
47
48     /**
49      * Ends current opened statement.
50      *
51      * @param ref
52      *            Identifier of location in source, which will be used for
53      *            reporting in case of statement processing error.
54      * @throws SourceException
55      *             if closed statement is not valid in current context, or there
56      *             is no such statement
57      */
58     void endStatement(@Nonnull StatementSourceReference ref) throws SourceException;
59
60     /**
61      *
62      * @return current processing phase
63      */
64     @Nonnull ModelProcessingPhase getPhase();
65 }