import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.gson.stream.JsonWriter;
-
import java.io.IOException;
import java.io.Writer;
import java.net.URI;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
final JSONCodec<Object> codec = codecs.codecFor(schema.getType());
context.emittingChild(codecs.getSchemaContext(), writer, indent);
- context.writeJsonIdentifier(codecs.getSchemaContext(), writer, name.getNodeType());
+ context.writeChildJsonIdentifier(codecs.getSchemaContext(), writer, name.getNodeType());
writeValue(codec.serialize(value), codec.needQuotes());
}
@Override
public void anyxmlNode(final NodeIdentifier name, final Object value) throws IOException {
+ @SuppressWarnings("unused")
final AnyXmlSchemaNode schema = tracker.anyxmlNode(name);
// FIXME: should have a codec based on this :)
context.emittingChild(codecs.getSchemaContext(), writer, indent);
- context.writeJsonIdentifier(codecs.getSchemaContext(), writer, name.getNodeType());
+ context.writeChildJsonIdentifier(codecs.getSchemaContext(), writer, name.getNodeType());
writeValue(String.valueOf(value), true);
}
package org.opendaylight.yangtools.yang.data.codec.gson;
import com.google.common.base.Preconditions;
-
import java.io.IOException;
import java.io.Writer;
import java.net.URI;
-
import javax.annotation.Nonnull;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
}
/**
- * Write a JSON node identifier, optionally prefixing it with the module name
+ * Write a child JSON node identifier, optionally prefixing it with the module name
* corresponding to its namespace.
*
* @param schema Schema context
* @param qname Namespace/name tuple
* @throws IOException when the writer reports it
*/
- protected final void writeJsonIdentifier(final SchemaContext schema, final Writer writer, final QName qname) throws IOException {
+ final void writeChildJsonIdentifier(final SchemaContext schema, final Writer writer, final QName qname) throws IOException {
writer.append('"');
// Prepend module name if namespaces do not match
writer.append("\":");
}
+ /**
+ * Write our JSON node identifier, optionally prefixing it with the module name
+ * corresponding to its namespace.
+ *
+ * @param schema Schema context
+ * @param writer Output writer
+ * @param qname Namespace/name tuple
+ * @throws IOException when the writer reports it
+ */
+ protected final void writeMyJsonIdentifier(final SchemaContext schema, final Writer writer, final QName qname) throws IOException {
+ parent.writeChildJsonIdentifier(schema, writer, qname);
+ }
+
/**
* Return the namespace associated with current node.
*
}
return parent;
}
+
}
@Override
protected void emitStart(final SchemaContext schema, final Writer writer) throws IOException {
- writeJsonIdentifier(schema, writer, getQName());
+ writeMyJsonIdentifier(schema, writer, getQName());
writer.append('[');
}
import java.io.IOException;
import java.io.Writer;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@Override
protected void emitStart(final SchemaContext schema, final Writer writer) throws IOException {
- writeJsonIdentifier(schema, writer, getQName());
+ writeMyJsonIdentifier(schema, writer, getQName());
super.emitStart(schema, writer);
}
-}
\ No newline at end of file
+}