Package org.apache.juneau.marshall.uon
Class UonUtils
java.lang.Object
org.apache.juneau.marshall.uon.UonUtils
Utility methods for the UON and UrlEncoding serializers and parsers.
See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidMerges one MULTIkey=uonValue token intodest .static JsonMapmergePairs(String... tokens) Merges MULTIkey=uonValue tokens into a newJsonMap.static booleanReturnstrue if the specified string needs to be quoted per UON notation.static ObjectparseValue(String raw) Parses a UON value from the right-hand side of akey=uonValue pair.
-
Method Details
-
needsQuotes
Returnstrue if the specified string needs to be quoted per UON notation.For example, strings that start with '(' or '@' or look like boolean or numeric values need to be quoted.
- Parameters:
s- The string to test.
Must not benull .- Returns:
true if the specified string needs to be quoted per UON notation.
-
mergePairs
Merges MULTIkey=uonValue tokens into a newJsonMap.Each token is one top-level pair (for example
environment=prod orflags=(a,b,c) ). A parenthesized UON object as a single token ((a=1,b=2) ) is expanded. Later keys overwrite earlier ones. Blank tokens are ignored.- Parameters:
tokens- The raw tokens. Can benull .- Returns:
- A new map, never
null . - Throws:
ParseException- Malformed UON value.SchemaValidationException- If a UON value fails schema validation.
-
mergePair
public static void mergePair(JsonMap dest, String token) throws ParseException, SchemaValidationException Merges one MULTIkey=uonValue token intodest .- Parameters:
dest- The destination map. Must not benull .token- The raw token. Blank tokens are ignored.- Throws:
ParseException- Malformed UON value.SchemaValidationException- If a UON value fails schema validation.
-
parseValue
Parses a UON value from the right-hand side of akey=uonValue pair.List-shaped values authored as
(a,b,c) (without the UON@ array prefix) are treated as UON arrays. Unquoted strings that the parser would otherwise coerce to a number are kept as strings unless they are a UON number literal.- Parameters:
raw- The raw UON value. Must not benull .- Returns:
- The parsed value.
- Throws:
ParseException- Malformed UON value.SchemaValidationException- If the UON value fails schema validation.
-