Class UonUtils

java.lang.Object
org.apache.juneau.marshall.uon.UonUtils

public class UonUtils extends Object
Utility methods for the UON and UrlEncoding serializers and parsers.
See Also:
  • Method Details

    • needsQuotes

      public static boolean needsQuotes(String s)
      Returns true 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 be null.
      Returns:
      true if the specified string needs to be quoted per UON notation.
    • mergePairs

      Merges MULTI key=uonValue tokens into a new JsonMap.

      Each token is one top-level pair (for example environment=prod or flags=(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 be null.
      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 MULTI key=uonValue token into dest.
      Parameters:
      dest - The destination map. Must not be null.
      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 a key=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 be null.
      Returns:
      The parsed value.
      Throws:
      ParseException - Malformed UON value.
      SchemaValidationException - If the UON value fails schema validation.