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.stmt.reactor;
10 import java.util.List;
12 import java.util.LinkedList;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import java.util.Collection;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
20 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
22 class RootStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
23 extends StatementContextBase<A, D, E> {
25 private final SourceSpecificContext sourceContext;
26 private final A argument;
27 private LinkedList<?> linkedList;
29 RootStatementContext(ContextBuilder<A, D, E> builder,
30 SourceSpecificContext sourceContext) throws SourceException {
32 this.sourceContext = sourceContext;
33 this.argument = builder.getDefinition().parseArgumentValue(this,
34 builder.getRawArgument());
37 RootStatementContext(RootStatementContext<A, D, E> original,
38 QNameModule newQNameModule) throws SourceException {
41 sourceContext = original.sourceContext;
42 this.argument = original.argument;
44 copyDeclaredStmts(original, newQNameModule);
46 copyEffectiveStmts(original, newQNameModule);
50 private void copyDeclaredStmts(RootStatementContext<A, D, E> original,
51 QNameModule newQNameModule) throws SourceException {
52 Collection<? extends StmtContext<?, ?, ?>> originalDeclaredSubstatements = original
53 .declaredSubstatements();
54 for (StmtContext<?, ?, ?> stmtContext : originalDeclaredSubstatements) {
55 this.addEffectiveSubstatement(stmtContext
56 .createCopy(newQNameModule,this));
60 private void copyEffectiveStmts(RootStatementContext<A, D, E> original,
61 QNameModule newQNameModule) throws SourceException {
62 Collection<? extends StmtContext<?, ?, ?>> originalEffectiveSubstatements = original
63 .effectiveSubstatements();
64 for (StmtContext<?, ?, ?> stmtContext : originalEffectiveSubstatements) {
65 this.addEffectiveSubstatement(stmtContext
66 .createCopy(newQNameModule,this));
71 public StatementContextBase<?, ?, ?> getParentContext() {
76 public NamespaceStorageNode getParentNamespaceStorage() {
81 public Registry getBehaviourRegistry() {
86 public RootStatementContext<?, ?, ?> getRoot() {
90 SourceSpecificContext getSourceContext() {
95 public A getStatementArgument() {
100 public StatementContextBase<A, D, E> createCopy(QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent)
101 throws SourceException {
103 StatementContextBase<A, D, E> copy = new RootStatementContext<A, D, E>(
104 this, newQNameModule);
109 public List<Object> getArgumentsFromRoot() {
110 LinkedList<Object> argumentList = new LinkedList<Object>();
111 argumentList.add(argument);