Bug 5504 - Controller crashes with OOM. oldRoot/currentRoot, toString()
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / stream / NormalizedNodeStreamWriter.java
index 5f4e66c5c6a8dd23f8ae9e579b4fcf6722a97479..c0312864dc1536e29e3c57ee7b2c825b6fc9550d 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.data.api.schema.stream;
 import java.io.Closeable;
 import java.io.Flushable;
 import java.io.IOException;
+import org.opendaylight.yangtools.yang.common.QName;
 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;
@@ -49,7 +50,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
  * <li><code>leaf-list</code> - Leaf list start is emitted using
  * {@link #startLeafSet(NodeIdentifier, int)}. Leaf list end is emitted using
  * {@link #endNode()}. Leaf list entries are emmited using
- * {@link #leafSetEntryNode(Object)}.
+ * {@link #leafSetEntryNode(QName, Object)}.
  *
  * <li><code>anyxml - AN node event is emitted using
  * {@link #leafNode(NodeIdentifier, Object)}. {@link #endNode()} MUST NOT BE emitted
@@ -117,7 +118,7 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      * Emits a start of leaf set (leaf-list).
      * <p>
      * Emits start of leaf set, during writing leaf set event, only
-     * {@link #leafSetEntryNode(Object)} calls are valid. Leaf set event is
+     * {@link #leafSetEntryNode(QName, Object)} calls are valid. Leaf set event is
      * finished by calling {@link #endNode()}.
      *
      * @param name
@@ -138,9 +139,37 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      */
     void startLeafSet(NodeIdentifier name, int childSizeHint) throws IOException;
 
+    /**
+     *
+     * Emits a start of leaf set (leaf-list).
+     * <p>
+     * Emits start of leaf set, during writing leaf set event, only
+     * {@link #leafSetEntryNode(QName, Object)} calls are valid. Leaf set event is
+     * finished by calling {@link #endNode()}.
+     *
+     * @param name
+     *            name of node as defined in schema, namespace and revision are
+     *            derived from parent node.
+     * @param childSizeHint
+     *            Non-negative count of expected direct child nodes or
+     *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+     *            and should not fail writing of child events, if there are more
+     *            events than count.
+     * @throws IllegalArgumentException
+     *             If emitted leaf node is invalid in current context or was
+     *             emitted multiple times.
+     * @throws IllegalStateException
+     *             If node was emitted inside <code>map</code>,
+     *             <code>choice</code> <code>unkeyed list</code> node.
+     * @throws IOException if an underlying IO error occurs
+     */
+    void startOrderedLeafSet(NodeIdentifier name, int childSizeHint) throws IOException, IllegalArgumentException;
+
     /**
      * Emits a leaf set entry node
      *
+     * @param name
+     *            name of the node as defined in the schema.
      * @param value
      *            Value of leaf set entry node. Supplied object MUST BE constant over time.
      * @throws IllegalArgumentException
@@ -149,7 +178,7 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      *             If node was emitted outside <code>leaf set</code> node.
      * @throws IOException if an underlying IO error occurs
      */
-    void leafSetEntryNode(Object value) throws IOException;
+    void leafSetEntryNode(QName name, Object value) throws IOException;
 
     /**
      *
@@ -257,7 +286,13 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      *            name of node as defined in schema, namespace and revision are
      *            derived from parent node.
      * @param childSizeHint
+     *            Non-negative count of expected direct child nodes or
+     *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+     *            and should not fail writing of child events, if there are more
+     *            events than count.
      * @throws IllegalArgumentException
+     *             If emitted node is invalid in current context or was emitted
+     *             multiple times.
      * @throws IllegalStateException
      *             If node was emitted inside <code>map</code>,
      *             <code>choice</code> <code>unkeyed list</code> node.
@@ -287,6 +322,11 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      *
      * @param identifier
      *            QName to value pairs of keys of map entry node. Values  MUST BE constant over time.
+     * @param childSizeHint
+     *            Non-negative count of expected direct child nodes or
+     *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+     *            and should not fail writing of child events, if there are more
+     *            events than count.
      * @throws IllegalArgumentException
      *             If key contains incorrect value.
      * @throws IllegalStateException
@@ -308,7 +348,14 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      * @param name
      *            name of node as defined in schema, namespace and revision are
      *            derived from parent node.
+     * @param childSizeHint
+     *            Non-negative count of expected direct child nodes or
+     *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+     *            and should not fail writing of child events, if there are more
+     *            events than count.
      * @throws IllegalArgumentException
+     *             If emitted node is invalid in current context or was emitted
+     *             multiple times.
      * @throws IllegalStateException
      *             If node was emitted inside <code>map</code>,
      *             <code>choice</code> <code>unkeyed list</code> node.
@@ -324,7 +371,13 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      *            name of node as defined in schema, namespace and revision are
      *            derived from parent node.
      * @param childSizeHint
+     *            Non-negative count of expected direct child nodes or
+     *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+     *            and should not fail writing of child events, if there are more
+     *            events than count.
      * @throws IllegalArgumentException
+     *             If emitted node is invalid in current context or was emitted
+     *             multiple times.
      * @throws IllegalStateException
      *             If node was emitted inside <code>map</code>,
      *             <code>choice</code> <code>unkeyed list</code> node.
@@ -362,8 +415,13 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      * Emits anyxml node event.
      *
      * @param name
+     *            name of node as defined in schema, namespace and revision are
+     *            derived from parent node.
      * @param value
+     *             Value of AnyXml node.
      * @throws IllegalArgumentException
+     *             If emitted node is invalid in current context or was emitted
+     *             multiple times.
      * @throws IllegalStateException
      *             If node was emitted inside <code>map</code>,
      *             <code>choice</code> <code>unkeyed list</code> node.
@@ -371,6 +429,41 @@ public interface NormalizedNodeStreamWriter extends Closeable, Flushable {
      */
     void anyxmlNode(NodeIdentifier name, Object value) throws IOException;
 
+    /**
+    *
+    * Emits start of new yang modeled anyXml node.
+    *
+    * <p>
+    * End of yang modeled anyXml node event is emitted by invoking {@link #endNode()}.
+    *
+    * <p>
+    * Valid sub-events are:
+    * <ul>
+    * <li>{@link #leafNode}</li>
+    * <li>{@link #startContainerNode}</li>
+    * <li>{@link #startLeafSet}</li>
+    * <li>{@link #startMapNode}</li>
+    * <li>{@link #startUnkeyedList}</li>
+    * </ul>
+    *
+    * @param name
+    *            name of node as defined in schema, namespace and revision are
+    *            derived from parent node.
+    * @param childSizeHint
+    *            Non-negative count of expected direct child nodes or
+    *            {@link #UNKNOWN_SIZE} if count is unknown. This is only hint
+    *            and should not fail writing of child events, if there are more
+    *            events than count.
+    * @throws IllegalArgumentException
+    *             If emitted node is invalid in current context or was emitted
+    *             multiple times.
+    * @throws IllegalStateException
+    *             If node was emitted inside <code>map</code>,
+    *             <code>choice</code> <code>unkeyed list</code> node.
+    * @throws IOException if an underlying IO error occurs
+    */
+    void startYangModeledAnyXmlNode(NodeIdentifier name, int childSizeHint) throws IOException;
+
     /**
      * Emits end event for node.
      *