Bug 3874: Support of yang modeled AnyXML - XML deserialization
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / AnyxmlSchemaLocationStatementImpl.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.stmt.rfc6020;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
12 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
13 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
18 import org.opendaylight.yangtools.yang.parser.spi.source.AnyxmlSchemaLocationNamespace;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AnyxmlSchemaLocationEffectiveStatementImpl;
20
21 @Beta
22 public final class AnyxmlSchemaLocationStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements
23         UnknownStatement<SchemaNodeIdentifier> {
24
25     AnyxmlSchemaLocationStatementImpl(
26             StmtContext<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, ?> context) {
27         super(context);
28     }
29
30     public static class AnyxmlSchemaLocationSupport
31             extends
32             AbstractStatementSupport<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, EffectiveStatement<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>>> {
33
34         public AnyxmlSchemaLocationSupport() {
35             super(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION);
36         }
37
38         @Override
39         public SchemaNodeIdentifier parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
40             return Utils.nodeIdentifierFromPath(ctx, value);
41         }
42
43         @Override
44         public void onFullDefinitionDeclared(
45                 Mutable<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, EffectiveStatement<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>>> stmt) {
46             stmt.getParentContext().addToNs(AnyxmlSchemaLocationNamespace.class,
47                     SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION, stmt);
48         }
49
50         @Override
51         public UnknownStatement<SchemaNodeIdentifier> createDeclared(
52                 StmtContext<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, ?> ctx) {
53             return new AnyxmlSchemaLocationStatementImpl(ctx);
54         }
55
56         @Override
57         public EffectiveStatement<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>> createEffective(
58                 final StmtContext<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, EffectiveStatement<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>>> ctx) {
59             return new AnyxmlSchemaLocationEffectiveStatementImpl(ctx);
60         }
61     }
62
63     @Override
64     public SchemaNodeIdentifier getArgument() {
65         return argument();
66     }
67 }