Interface BindingStreamEventWriter
- All Superinterfaces:
AutoCloseable
,Closeable
,Flushable
Emitting Event Stream
container
- Container node representation, start event is emitted usingstartContainerNode(Class, int)
and node end event is emitted usingendNode()
. Container node is implementingDataObject
interface.list
- YANG list statement has two representation in event stream - unkeyed list and map. Unkeyed list is YANG list which did not specify key.Map
- Map start event is emitted usingstartMapNode(Class, int)
and is ended usingendNode()
. Each map entry start is emitted usingstartMapEntryNode(Identifier, int)
with Map of keys and finished usingendNode()
.UnkeyedList
- Unkeyed list represent list without keys, unkeyed list start is emitted usingstartUnkeyedList(Class, int)
list end is emitted usingendNode()
. Each list item is emitted usingstartUnkeyedListItem(int)
and ended usingendNode()
.leaf
- Leaf node event is emitted usingleafNode(String, Object)
.endNode()
MUST be not emitted for leaf node.leaf-list
- Leaf list start is emitted usingstartLeafSet(String, int)
. Leaf list end is emitted usingendNode()
. Leaf list entries are emitted usingleafSetEntryNode(Object)
.anyxml
- Anyxml node event is emitted usingleafNode(String, Object)
.endNode()
MUST be not emitted for anyxml node.choice
Choice node event is emitted bystartChoiceNode(Class, int)
event and must be immediately followed bystartCase(Class, int)
event. Choice node is finished by emitting anendNode()
event.case
- Case node may be emitted only inside choice node by invokingstartCase(Class, int)
. Case node is finished be emitting anendNode()
event.augment
- Represents augmentation, augmentation node is started by invokingstartAugmentationNode(Class)
and finished by invokingendNode()
.
Implementation notes
This interface is not intended to be implemented by users of generated Binding DTOs but to be used by utilities, which needs to emit NormalizedNode model from Binding DTOs.This interface is intended as API definition of facade for real Event / Stream Writer, without explicitly requiring stream writer and related interfaces to be imported by all generated Binding DTOs.
Existence of this interface in base Java Binding package is required to support runtime generation of users of this interface in OSGI and OSGI-like environment, since this package is only package which is imported by all generated Binding DTOs and wired in OSGI.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Methods in this interface allow users to hint the underlying implementation about the sizing of container-like constructors (leafLists, containers, etc.). -
Method Summary
Modifier and TypeMethodDescriptionvoid
anyxmlNode
(String name, Object value) Emits anyxml node event.void
close()
void
endNode()
Emits end event for node.void
flush()
void
Emits a leaf node event with supplied value.void
leafSetEntryNode
(Object value) Emits a leaf set entry node.void
startAugmentationNode
(Class<? extends Augmentation<?>> augmentationType) Emits start of augmentation node.void
startCase
(Class<? extends DataObject> caze, int childSizeHint) Starts a case node.void
startChoiceNode
(Class<? extends DataContainer> choice, int childSizeHint) Emits start of choice node.void
startContainerNode
(Class<? extends DataObject> container, int childSizeHint) Emits start of new container.void
startLeafSet
(String localName, int childSizeHint) Emits a start of leaf set (leaf-list).void
startMapEntryNode
(Key<?> keyValues, int childSizeHint) Emits start of map entry.void
startMapNode
(Class<? extends EntryObject<?, ?>> mapEntryType, int childSizeHint) Emits start of unordered map node event.void
startOrderedLeafSet
(String localName, int childSizeHint) Emits a start of leaf set (leaf-list).void
startOrderedMapNode
(Class<? extends EntryObject<?, ?>> mapEntryType, int childSizeHint) Emits start of ordered map node event.void
startUnkeyedList
(Class<? extends DataObject> localName, int childSizeHint) Emits start of unkeyed list node event.void
startUnkeyedListItem
(int childSizeHint) Emits start of new unkeyed list item.
-
Field Details
-
UNKNOWN_SIZE
static final int UNKNOWN_SIZEMethods in this interface allow users to hint the underlying implementation about the sizing of container-like constructors (leafLists, containers, etc.). These hints may be taken into account by a particular implementation to improve performance, but clients are not required to provide hints. This constant should be used by clients who either do not have the sizing information, or do not wish to divulge it (for whatever reasons). Implementations are free to ignore these hints completely, but if they do use them, they are expected to be resilient in face of missing and mismatched hints, which is to say the user can specify startLeafSet(..., 1) and then call leafNode() 15 times.The acceptable hint values are non-negative integers and this constant, all other values will result, based on implementation preference, in the hint being completely ignored or IllegalArgumentException being thrown.
- See Also:
-
-
Method Details
-
leafNode
Emits a leaf node event with supplied value.- Parameters:
localName
- name of node as defined in schema, namespace and revision are derived from parent node.value
- Value of leaf node.- Throws:
IllegalArgumentException
- If emitted leaf node has invalid value in current context or was emitted multiple times.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startLeafSet
Emits a start of leaf set (leaf-list). Emits start of leaf set, during writing leaf set event, onlyleafSetEntryNode(Object)
calls are valid. Leaf set event is finished by callingendNode()
.- Parameters:
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 orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startOrderedLeafSet
Emits a start of leaf set (leaf-list).Emits start of leaf set, during writing leaf set event, only
leafSetEntryNode(Object)
calls are valid. Leaf set event is finished by callingendNode()
.- Parameters:
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 orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
leafSetEntryNode
Emits a leaf set entry node.- Parameters:
value
- Value of leaf set entry node.- Throws:
IllegalArgumentException
- If emitted leaf node has invalid value.IllegalStateException
- If node was emitted outsideleaf set
node.IOException
- if an underlying IO error occurs
-
startContainerNode
void startContainerNode(Class<? extends DataObject> container, int childSizeHint) throws IOException Emits start of new container. End of container event is emitted by invokingendNode()
.Valid sub-events are:
- Parameters:
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 orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startUnkeyedList
Emits start of unkeyed list node event.End of unkeyed list event is emitted by invoking
endNode()
. Valid subevents is onlystartUnkeyedListItem(int)
. All other methods will throwIllegalArgumentException
.- Parameters:
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 orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startUnkeyedListItem
Emits start of new unkeyed list item.Unkeyed list item event is finished by invoking
endNode()
. Valid sub-events are:- Parameters:
childSizeHint
- Non-negative count of expected direct child nodes orUNKNOWN_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:
IllegalStateException
- If node was emitted outsideunkeyed list
node.IOException
- if an underlying IO error occurs
-
startMapNode
void startMapNode(Class<? extends EntryObject<?, ?>> mapEntryType, int childSizeHint) throws IOExceptionEmits start of unordered map node event.End of map node event is emitted by invoking
endNode()
. Valid subevent is onlystartMapEntryNode(Identifier, int)
. All other methods will throwIllegalArgumentException
.- Parameters:
mapEntryType
- Class of list item, which has defined key.childSizeHint
- Non-negative count of expected direct child nodes orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startOrderedMapNode
void startOrderedMapNode(Class<? extends EntryObject<?, ?>> mapEntryType, int childSizeHint) throws IOExceptionEmits start of ordered map node event.End of map node event is emitted by invoking
endNode()
. Valid subevent is onlystartMapEntryNode(Identifier, int)
. All other methods will throwIllegalArgumentException
.- Parameters:
mapEntryType
- Class of list item, which has defined key.childSizeHint
- Non-negative count of expected direct child nodes orUNKNOWN_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.IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
startMapEntryNode
Emits start of map entry.End of map entry event is emitted by invoking
endNode()
.Valid sub-events are:
- Parameters:
keyValues
- Key of map entry nodechildSizeHint
- Non-negative count of expected direct child nodes orUNKNOWN_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.IllegalStateException
- If node was emitted outsidemap entry
node.IOException
- if an underlying IO error occurs
-
startChoiceNode
Emits start of choice node.Valid sub-event in
startCase(Class, int)
, which selects case which should be written.- Parameters:
choice
- Choice class.childSizeHint
- Non-negative count of expected direct child nodes orUNKNOWN_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:
IllegalStateException
- If node was emitted insidemap
,choice
,unkeyed list
node.IOException
- if an underlying IO error occurs
-
startCase
Starts a case node.Valid sub-events are:
- Parameters:
caze
- Case class- Throws:
IOException
- if an underlying IO error occurs
-
startAugmentationNode
Emits start of augmentation node.End of augmentation event is emitted by invoking
endNode()
.Valid sub-events are:
leafNode(String, Object)
startContainerNode(Class, int)
startChoiceNode(Class, int)
startLeafSet(String, int)
startMapNode(Class, int)
startUnkeyedList(Class, int)
Note this is only method, which does not require childSizeHint, since maximum value is always size of
possibleChildren
.- Parameters:
augmentationType
- augmentation class- Throws:
IllegalArgumentException
- If augmentation is invalid in current context.IOException
- if an underlying IO error occurs
-
anyxmlNode
Emits anyxml node event.- Parameters:
name
- node namevalue
- node value- Throws:
IllegalStateException
- If node was emitted insidemap
,choice
unkeyed list
node.IOException
- if an underlying IO error occurs
-
endNode
Emits end event for node.- Throws:
IllegalStateException
- If there is no open node.IOException
- if an underlying IO error occurs
-
flush
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-