Class MsgPackTree
- java.lang.Object
-
- io.zeebe.msgpack.mapping.MsgPackTree
-
- All Implemented Interfaces:
MsgPackDiff
public final class MsgPackTree extends Object implements MsgPackDiff
Represents a tree data structure, for a msg pack document.The nodes of the tree can be either a real node, which has child's, or a leaf, which has a mapping in the corresponding msg pack document to his value.
The message pack document tree can be created from scratch from a underlying document. This can be done with the
MsgPackDocumentIndexer. It can also be constructed from only a port of a message pack document. This can be done with theMsgPackDocumentExtractor.The message pack tree can consist from two different message pack documents. The underlying document, from which the tree is completely build and the extract document, which can be a part of another message pack document. The tree representation of the extract document will be as well added to the current message pack tree object.
Since the leafs contains a mapping, which consist of position and length, it is necessary that both documents are available for the message pack tree, so the leaf value can be resolved later. The leafs have to be distinguished, is it a leaf from the underlying document or is it from the extract document. For this distinction the
MsgPackNodeType#EXISTING_LEAF_NODEandMsgPackNodeType#EXTRACTED_LEAF_NODEare used.
-
-
Constructor Summary
Constructors Constructor Description MsgPackTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddArrayNode(String parentId, String arrayNodeName)intaddDocument(org.agrona.DirectBuffer document)StringaddMapNode(String parentId, String nodeName)StringaddValueNode(String parentId, String nodeName, int documentId, int valueOffset, int valueLength)StringappendToArray(String parentId, String arrayNodeName, int documentId, int elementOffset, int elementLength)Creates or converts the addressed node to an array and appends the value as a new element.voidclear()voidclearChildren(String nodeId)voidconvertToArrayNode(String nodeId)Keeps any children, e.g.voidconvertToMapNode(String nodeId)Keeps any children, e.g.Set<String>getChildren(String nodeId)booleanhasNode(String id)booleanisArrayNode(String nodeId)booleanisMapNode(String nodeId)booleanisValueNode(String nodeId)voidmergeInto(MsgPackTree other)Always replaces containers (object/array), unless it is the root objectintsize()voidwriteValueNode(MsgPackWriter writer, String nodeId)
-
-
-
Method Detail
-
size
public int size()
-
clear
public void clear()
-
getChildren
public Set<String> getChildren(String nodeId)
- Returns:
- the names (not IDs) of the child nodes
-
addDocument
public int addDocument(org.agrona.DirectBuffer document)
-
isValueNode
public boolean isValueNode(String nodeId)
-
isArrayNode
public boolean isArrayNode(String nodeId)
-
isMapNode
public boolean isMapNode(String nodeId)
-
writeValueNode
public void writeValueNode(MsgPackWriter writer, String nodeId)
-
mergeInto
public void mergeInto(MsgPackTree other)
Always replaces containers (object/array), unless it is the root object- Specified by:
mergeIntoin interfaceMsgPackDiff
-
convertToArrayNode
public void convertToArrayNode(String nodeId)
Keeps any children, e.g. when converting MAP to ARRAY
-
convertToMapNode
public void convertToMapNode(String nodeId)
Keeps any children, e.g. when converting ARRAY to MAP
-
appendToArray
public String appendToArray(String parentId, String arrayNodeName, int documentId, int elementOffset, int elementLength)
Creates or converts the addressed node to an array and appends the value as a new element. Replaces a previously existing non-array node completely.
-
addValueNode
public String addValueNode(String parentId, String nodeName, int documentId, int valueOffset, int valueLength)
-
hasNode
public boolean hasNode(String id)
-
clearChildren
public void clearChildren(String nodeId)
-
-