Updated Json Stream Writer to use gson JsonWriter.
[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 java.net.URI;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14
15
16 /**
17  * Abstract class tracking a virtual level of {@link JSONNormalizedNodeStreamWriter}
18  * recursion. It only tracks the namespace associated with this node.
19  */
20 abstract class JSONStreamWriterURIContext extends JSONStreamWriterContext {
21     private final URI namespace;
22
23     protected JSONStreamWriterURIContext(final JSONStreamWriterContext parent, final URI namespace) {
24         super(parent, false);
25         this.namespace = namespace;
26     }
27
28     @Override
29     protected final URI getNamespace() {
30         return namespace;
31     }
32
33     @Override
34     protected void emitStart(final SchemaContext schema, final JsonWriter writer) throws IOException {
35         // No-op
36     }
37 }