@Beta public final class CachingNormalizedNodeSerializer extends Object implements BindingSerializer<Object,TreeNode>
BindingNormalizedNodeCache
to cache already serialized values.
This serializer implements BindingStreamEventWriter
along with
BindingSerializer
.
BindingSerializer
interface is used by generated implementations of
TreeNodeSerializer
to provide Binding object for inspection and to
prevent streaming of already serialized object.
UNKNOWN_SIZE
Modifier and Type | Method and Description |
---|---|
void |
anyxmlNode(String name,
Object value)
Emits anyxml node event.
|
void |
close() |
protected BindingStreamEventWriter |
delegate() |
void |
endNode()
Emits end event for node.
|
void |
flush() |
void |
leafNode(String localName,
Object value)
Emits a leaf node event with supplied value.
|
void |
leafSetEntryNode(Object value)
Emits a leaf set entry node
|
static org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> |
serialize(AbstractBindingNormalizedNodeCacheHolder cacheHolder,
DataContainerCodecContext<?,?> subtreeRoot,
TreeNode data)
Serializes supplied data using stream writer with child cache enabled or
using cache directly if cache is avalaible also for supplied Codec node.
|
org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> |
serialize(TreeNode input)
Serializes input if it is cached, returns null otherwise.
|
static org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> |
serializeUsingStreamWriter(AbstractBindingNormalizedNodeCacheHolder cacheHolder,
DataContainerCodecContext<?,?> subtreeRoot,
TreeNode data)
Serializes supplied data using stream writer with child cache enabled.
|
void |
startAnydataNode(String name,
Object value)
Emits anydata node event.
|
void |
startAugmentationNode(Class<? extends Augmentation<?>> augmentationType)
Emits start of augmentation node.
|
void |
startCase(Class<? extends TreeNode> caze,
int childSizeHint)
Starts a case node.
|
<T extends TreeNode> |
startChoiceNode(Item<T> choice,
int childSizeHint)
Emits start of choice node.
|
void |
startContainerNode(Class<? extends TreeNode> container,
int childSizeHint)
Emits start of new container.
|
void |
startLeafSet(String localName,
int childSizeHint)
Emits a start of leaf set (leaf-list).
|
<I extends TreeNode,T> |
startMapEntryNode(IdentifiableItem<I,T> keyValues,
int childSizeHint)
Emits start of map entry.
|
<T extends TreeNode & org.opendaylight.yangtools.concepts.Identifiable<?>> |
startMapNode(Class<T> mapEntryType,
int childSizeHint)
Emits start of unordered map node event.
|
void |
startOrderedLeafSet(String localName,
int childSizeHint)
Emits a start of leaf set (leaf-list).
|
<T extends TreeNode & org.opendaylight.yangtools.concepts.Identifiable<?>> |
startOrderedMapNode(Class<T> mapEntryType,
int childSizeHint)
Emits start of ordered map node event.
|
void |
startUnkeyedList(Class<? extends TreeNode> localName,
int childSizeHint)
Emits start of unkeyed list node event.
|
void |
startUnkeyedListItem(int childSizeHint)
Emits start of new unkeyed list item.
|
protected BindingStreamEventWriter delegate()
public org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> serialize(TreeNode input)
If input is cached it uses
NormalizedNodeWithAddChildWriter.addChild(NormalizedNode)
to
provide already serialized value to underlying NormalizedNodeWriter in
order to reuse value instead of creating new one using Normalized Node
stream APIs.
Note that this optional is serialization of child node invoked from
TreeNodeSerializer
, which may opt-out from streaming of data when
non-null result is returned.
serialize
in interface BindingSerializer<Object,TreeNode>
input
- Input objectpublic static org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> serialize(AbstractBindingNormalizedNodeCacheHolder cacheHolder, DataContainerCodecContext<?,?> subtreeRoot, TreeNode data)
cacheHolder
- - Binding to Normalized Node Cache holdersubtreeRoot
- - codec Node for provided data objectdata
- - data to be serializedpublic static org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode<?,?> serializeUsingStreamWriter(AbstractBindingNormalizedNodeCacheHolder cacheHolder, DataContainerCodecContext<?,?> subtreeRoot, TreeNode data)
cacheHolder
- - binding to Normalized Node Cache holdersubtreeRoot
- - codec Node for provided data objectdata
- - data to be serializedpublic void leafNode(String localName, Object value) throws IOException
BindingStreamEventWriter
leafNode
in interface BindingStreamEventWriter
localName
- name of node as defined in schema, namespace and revision are
derived from parent node.value
- Value of leaf node.IOException
- if an underlying IO error occurspublic void startLeafSet(String localName, int childSizeHint) throws IOException
BindingStreamEventWriter
Emits start of leaf set, during writing leaf set event, only
BindingStreamEventWriter.leafSetEntryNode(Object)
calls are valid. Leaf set event is
finished by calling BindingStreamEventWriter.endNode()
.
startLeafSet
in interface BindingStreamEventWriter
localName
- name of node as defined in schema, namespace and revision are
derived from parent node.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic void startOrderedLeafSet(String localName, int childSizeHint) throws IOException
BindingStreamEventWriter
Emits start of leaf set, during writing leaf set event, only
BindingStreamEventWriter.leafSetEntryNode(Object)
calls are valid. Leaf set event is
finished by calling BindingStreamEventWriter.endNode()
.
startOrderedLeafSet
in interface BindingStreamEventWriter
localName
- name of node as defined in schema, namespace and revision are
derived from parent node.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic void leafSetEntryNode(Object value) throws IOException
BindingStreamEventWriter
leafSetEntryNode
in interface BindingStreamEventWriter
value
- Value of leaf set entry node.IOException
- if an underlying IO error occurspublic void startContainerNode(Class<? extends TreeNode> container, int childSizeHint) throws IOException
BindingStreamEventWriter
End of container event is emitted by invoking BindingStreamEventWriter.endNode()
.
Valid sub-events are:
BindingStreamEventWriter.leafNode(String, Object)
BindingStreamEventWriter.startContainerNode(Class, int)
BindingStreamEventWriter.startChoiceNode(Item, int)
BindingStreamEventWriter.startLeafSet(String, int)
BindingStreamEventWriter.startMapNode(Class, int)
BindingStreamEventWriter.startUnkeyedList(Class, int)
BindingStreamEventWriter.startAugmentationNode(Class)
startContainerNode
in interface BindingStreamEventWriter
container
- name of node as defined in schema, namespace and revision are
derived from parent node.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic void startUnkeyedList(Class<? extends TreeNode> localName, int childSizeHint) throws IOException
BindingStreamEventWriter
End of unkeyed list event is emitted by invoking BindingStreamEventWriter.endNode()
.
Valid sub-event is only BindingStreamEventWriter.startUnkeyedListItem(int)
. All other
methods will throw IllegalArgumentException
.
startUnkeyedList
in interface BindingStreamEventWriter
localName
- name of node as defined in schema, namespace and revision are
derived from parent node.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic void startUnkeyedListItem(int childSizeHint) throws IOException
BindingStreamEventWriter
Un-keyed list item event is finished by invoking BindingStreamEventWriter.endNode()
.
Valid sub-events are:
BindingStreamEventWriter.leafNode(String, Object)
BindingStreamEventWriter.startContainerNode(Class, int)
BindingStreamEventWriter.startChoiceNode(Item, int)
BindingStreamEventWriter.startLeafSet(String, int)
BindingStreamEventWriter.startMapNode(Class, int)
BindingStreamEventWriter.startUnkeyedList(Class, int)
BindingStreamEventWriter.startAugmentationNode(Class)
startUnkeyedListItem
in interface BindingStreamEventWriter
childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic <T extends TreeNode & org.opendaylight.yangtools.concepts.Identifiable<?>> void startMapNode(Class<T> mapEntryType, int childSizeHint) throws IOException
BindingStreamEventWriter
End of map node event is emitted by invoking BindingStreamEventWriter.endNode()
. Valid
subevents is only BindingStreamEventWriter.startMapEntryNode(IdentifiableItem, int)
. All other methods will
throw IllegalArgumentException
.
startMapNode
in interface BindingStreamEventWriter
mapEntryType
- Class of list.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic <T extends TreeNode & org.opendaylight.yangtools.concepts.Identifiable<?>> void startOrderedMapNode(Class<T> mapEntryType, int childSizeHint) throws IOException
BindingStreamEventWriter
End of map node event is emitted by invoking BindingStreamEventWriter.endNode()
. Valid
sub-event is only BindingStreamEventWriter.startMapEntryNode(IdentifiableItem, int)
. All other methods will
throw IllegalArgumentException
.
startOrderedMapNode
in interface BindingStreamEventWriter
mapEntryType
- Class of list item, which has defined key.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic <I extends TreeNode,T> void startMapEntryNode(IdentifiableItem<I,T> keyValues, int childSizeHint) throws IOException
BindingStreamEventWriter
End of map entry event is emitted by invoking BindingStreamEventWriter.endNode()
.
Valid sub-events are:
BindingStreamEventWriter.leafNode(String, Object)
BindingStreamEventWriter.startContainerNode(Class, int)
BindingStreamEventWriter.startChoiceNode(Item, int)
BindingStreamEventWriter.startLeafSet(String, int)
BindingStreamEventWriter.startMapNode(Class, int)
BindingStreamEventWriter.startUnkeyedList(Class, int)
BindingStreamEventWriter.startAugmentationNode(Class)
startMapEntryNode
in interface BindingStreamEventWriter
keyValues
- Key of map entry nodechildSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic <T extends TreeNode> void startChoiceNode(Item<T> choice, int childSizeHint) throws IOException
BindingStreamEventWriter
Valid sub-event is BindingStreamEventWriter.startCase(Class, int)
, which selects case
which should be written.
startChoiceNode
in interface BindingStreamEventWriter
choice
- Choice class.childSizeHint
- Non-negative count of expected direct child nodes or
BindingStreamEventWriter.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.IOException
- if an underlying IO error occurspublic void startCase(Class<? extends TreeNode> caze, int childSizeHint) throws IOException
BindingStreamEventWriter
Valid sub-events are:
BindingStreamEventWriter.leafNode(String, Object)
BindingStreamEventWriter.startContainerNode(Class, int)
BindingStreamEventWriter.startChoiceNode(Item, int)
BindingStreamEventWriter.startLeafSet(String, int)
BindingStreamEventWriter.startMapNode(Class, int)
BindingStreamEventWriter.startUnkeyedList(Class, int)
BindingStreamEventWriter.startAugmentationNode(Class)
startCase
in interface BindingStreamEventWriter
caze
- Case classIOException
- if an underlying IO error occurspublic void startAugmentationNode(Class<? extends Augmentation<?>> augmentationType) throws IOException
BindingStreamEventWriter
End of augmentation event is emitted by invoking BindingStreamEventWriter.endNode()
.
Valid sub-events are:
BindingStreamEventWriter.leafNode(String, Object)
BindingStreamEventWriter.startContainerNode(Class, int)
BindingStreamEventWriter.startChoiceNode(Item, int)
BindingStreamEventWriter.startLeafSet(String, int)
BindingStreamEventWriter.startMapNode(Class, int)
BindingStreamEventWriter.startUnkeyedList(Class, int)
Note this is only method, which does not require childSizeHint, since
maximum value is always size of possibleChildren
.
startAugmentationNode
in interface BindingStreamEventWriter
augmentationType
- augmentation classIOException
- if an underlying IO error occurspublic void anyxmlNode(String name, Object value) throws IOException
BindingStreamEventWriter
anyxmlNode
in interface BindingStreamEventWriter
IOException
- if an underlying IO error occurspublic void startAnydataNode(String name, Object value) throws IOException
BindingStreamEventWriter
startAnydataNode
in interface BindingStreamEventWriter
IOException
- if an underlying IO error occurspublic void endNode() throws IOException
BindingStreamEventWriter
endNode
in interface BindingStreamEventWriter
IOException
- if an underlying IO error occurspublic void flush() throws IOException
flush
in interface Flushable
flush
in interface BindingStreamEventWriter
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface BindingStreamEventWriter
IOException
Copyright © 2019 OpenDaylight. All rights reserved.