Class MsgPackDocumentExtractor


  • public final class MsgPackDocumentExtractor
    extends Object
    Represents an message pack document extractor.

    The extractor can wrap a message pack document, which is stored in a DirectBuffer and extract parts of this wrapped document with help of the given Mapping objects. The extracted parts are stored in a MsgPackTree object, which is returned after calling #extract(Mapping...).

    It is also possible that the extractor wraps an already existing MsgPackTree object and a message pack document on which the extracting should be done. The extracted parts are stored in the wrapped tree. This means nodes can be added or replaced in the wrapped message pack tree.

    A Mapping consist of a source json query and a target json path mapping. The source json query must match on the wrapped message pack document. The matching value will be stored in the resulting MsgPackTree object, the tree is either the wrapped tree or a tree which only consists of the extracted values.

    The resulting MsgPackTree consist of nodes for each part in the target json path mapping and leafs, which corresponds to the leaf in the target json path mapping. These leafs contains the values of the matched source json query, form the wrapped message pack document.

    Example:

     Wrapped document:
      {
         "sourceObject":{
             "foo":"bar"
         },
         "value1":1
      }
     
     
     Mappings:
      $.sourceObject -> $.targetObject.value1
      $.value1 -> $.newValue1
     
     
    
     Then the resulting tree will look like the following:
    
               $
            /     \
      newValue1   targetObject
        |           \
        1           value1
                     \
                     {"foo":"bar"}
     
    • Constructor Detail

      • MsgPackDocumentExtractor

        public MsgPackDocumentExtractor()
    • Method Detail

      • extract

        public MsgPackDiff extract​(org.agrona.DirectBuffer document,
                                   boolean strictMode,
                                   Mapping... mappings)