package org.opendaylight.yangtools.yang.data.util;
import java.io.IOException;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.SchemaAwareNormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.rfc7952.data.api.StreamWriterMetadataExtension;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-public class ListNodeDataWithSchema extends CompositeNodeDataWithSchema {
-
- public ListNodeDataWithSchema(final DataSchemaNode schema) {
+/**
+ * Utility class used for tracking parser state as needed by a StAX-like parser.
+ * This class is to be used only by respective XML and JSON parsers in yang-data-codec-xml and yang-data-codec-gson.
+ *
+ * <p>
+ * Represents a YANG list node.
+ */
+public class ListNodeDataWithSchema extends CompositeNodeDataWithSchema<ListSchemaNode>
+ implements MultipleEntryDataWithSchema<ListEntryNodeDataWithSchema> {
+ public ListNodeDataWithSchema(final ListSchemaNode schema) {
super(schema);
}
@Override
- public void write(final SchemaAwareNormalizedNodeStreamWriter writer) throws IOException {
- final ListSchemaNode schema = (ListSchemaNode) getSchema();
+ public void write(final NormalizedNodeStreamWriter writer, final StreamWriterMetadataExtension metaWriter)
+ throws IOException {
+ final ListSchemaNode schema = getSchema();
writer.nextDataSchemaNode(schema);
if (schema.getKeyDefinition().isEmpty()) {
writer.startUnkeyedList(provideNodeIdentifier(), childSizeHint());
} else {
writer.startMapNode(provideNodeIdentifier(), childSizeHint());
}
- super.write(writer);
+ super.write(writer, metaWriter);
writer.endNode();
}
+ @Override
+ public final ListEntryNodeDataWithSchema newChildEntry() {
+ final ListEntryNodeDataWithSchema child = ListEntryNodeDataWithSchema.forSchema(getSchema());
+ addChild(child);
+ return child;
+ }
}