Add XMLNamespace
[yangtools.git] / yang / yang-data-codec-gson / src / main / java / org / opendaylight / yangtools / yang / data / codec / gson / JSONStreamWriterURIContext.java
1 /*
2  * Copyright (c) 2014 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.data.codec.gson;
9
10 import com.google.gson.stream.JsonWriter;
11 import java.io.IOException;
12 import org.opendaylight.yangtools.yang.common.XMLNamespace;
13 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
14
15 /**
16  * Abstract class tracking a virtual level of {@link JSONNormalizedNodeStreamWriter}
17  * recursion. It only tracks the namespace associated with this node.
18  */
19 abstract class JSONStreamWriterURIContext extends JSONStreamWriterContext {
20     private final XMLNamespace namespace;
21
22     JSONStreamWriterURIContext(final JSONStreamWriterContext parent, final XMLNamespace namespace) {
23         this(parent, namespace, false);
24     }
25
26     JSONStreamWriterURIContext(final JSONStreamWriterContext parent, final XMLNamespace namespace,
27             final boolean mandatory) {
28         super(parent, mandatory);
29         this.namespace = namespace;
30     }
31
32     @Override
33     protected final XMLNamespace getNamespace() {
34         return namespace;
35     }
36
37     @Override
38     protected void emitStart(final EffectiveModelContext schema, final JsonWriter writer) throws IOException {
39         // No-op
40     }
41 }