public class DotNotes extends Object
JsonNodes being passed in, either flattening, inflating
or processing recursively. Also provides access to several dot notation
utility methods, such as key parsing.| Modifier and Type | Class and Description |
|---|---|
static class |
DotNotes.NodeIterator
A very small interface used for processing the iteration
through a set of path and key tuples.
|
| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.JsonNode |
create(com.fasterxml.jackson.databind.JsonNode target,
String path,
com.fasterxml.jackson.databind.JsonNode value)
Uses a dot-noted path in order to create a given value in the given leaf of a tree.
|
static String |
escape(NotedKey key)
Escapes a key input, to ensure that the returned String is a valid
key format.
|
static String |
escape(Number num)
Wrapper to $
escape(NotedKey) in order to allow easy passing
of a Number value without having to manually force into a NotedKey. |
static String |
escape(String str)
Wrapper to $
escape(NotedKey) in order to allow easy passing
of a String value without having to manually force into a NotedKey. |
static com.fasterxml.jackson.databind.JsonNode |
get(com.fasterxml.jackson.databind.JsonNode node,
String path)
Uses a String path to create a List of keys in order to move
through a nested $
JsonNode in order to find a specific
value. |
static boolean |
isEscaped(String key)
Determines whether a String is already in an escaped format.
|
static List<NotedKey> |
keys(String s)
Takes a dot-noted String and converts it to a List of keys.
|
static void |
recurse(com.fasterxml.jackson.databind.JsonNode node,
DotNotes.NodeIterator handler)
A small wrapper to $
recurse(JsonNode, NodeIterator, String) to allow omitting
a third parameter, passing null instead. |
static void |
recurse(com.fasterxml.jackson.databind.JsonNode node,
DotNotes.NodeIterator handler,
String start)
Moves through the provided JsonNode, emitting values to the $
DotNotes.NodeIterator.execute(NotedKey, JsonNode, String)
method of a provided handler. |
public static com.fasterxml.jackson.databind.JsonNode create(com.fasterxml.jackson.databind.JsonNode target,
String path,
com.fasterxml.jackson.databind.JsonNode value)
throws ParseException
JsonNode from scratch, or be used to populate
a pre-existing one.target - the target $JsonNode to create intopath - the path to createvalue - the value to set the path toJsonNode after key creationParseException - if any parsing issues occurpublic static String escape(NotedKey key) throws ParseException
NotedKey instance in order to
enforce Array vs Object typing.key - the key to escapeString with valid escapingParseExceptionpublic static String escape(Number num) throws ParseException
escape(NotedKey) in order to allow easy passing
of a Number value without having to manually force into a NotedKey.num - the number to passParseExceptionpublic static String escape(String str) throws ParseException
escape(NotedKey) in order to allow easy passing
of a String value without having to manually force into a NotedKey.str - the String to passParseExceptionpublic static com.fasterxml.jackson.databind.JsonNode get(com.fasterxml.jackson.databind.JsonNode node,
String path)
throws ParseException
JsonNode in order to find a specific
value. If the value is found, it is returned. If it can not be
found, a $MissingNode will be returned.node - the node to use for the searchpath - the path to find the value forJsonNode if found, a $MissingNode if notParseException - if any parsing issues occurpublic static boolean isEscaped(String key)
key - the key to validatepublic static List<NotedKey> keys(String s) throws ParseException
NotedKeys
will be returned.s - the String to parseNotedKeysParseException - if any parsing issues occurpublic static void recurse(com.fasterxml.jackson.databind.JsonNode node,
DotNotes.NodeIterator handler)
throws ParseException
recurse(JsonNode, NodeIterator, String) to allow omitting
a third parameter, passing null instead.node - the node to passhandler - the handler to passParseExceptionpublic static void recurse(com.fasterxml.jackson.databind.JsonNode node,
DotNotes.NodeIterator handler,
String start)
throws ParseException
DotNotes.NodeIterator.execute(NotedKey, JsonNode, String)
method of a provided handler. A prefix can be provided in order to start all paths with a custom prefix. Paths will
not be generated if $DotNotes.NodeIterator.requirePathGeneration() returns false.node - the node to iterate throughhandler - the handler to emit tostart - the starting prefix String, if anyParseExceptionCopyright © 2017. All rights reserved.