Class UonParser

All Implemented Interfaces:
AnnotationProvider, HttpPartParser, UonMetaProvider
Direct Known Subclasses:
OpenApiParser, UonParser.Decoding, UrlEncodingParser

public class UonParser extends ReaderParser implements HttpPartParser, UonMetaProvider
Parses UON (a notation for URL-encoded query parameter values) text into POJO models.
Media types

Handles Content-Type types: text/uon

Description

This parser uses a state machine, which makes it very fast and efficient.

Notes:
  • This class is thread safe and reusable.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static UonParser.Builder create()
      Creates a new builder for this object.
      Returns:
      A new builder.
    • copy

      Description copied from class: Context
      Creates a builder from this context object.

      Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.

      Overrides:
      copy in class Parser
      Returns:
      A new Builder object.
    • createSession

      Description copied from class: Context
      Create a session builder based on the properties defined on this context.

      Use this method for creating sessions where you want to override basic settings. Otherwise, use Context.getSession() directly.

      Overrides:
      createSession in class ReaderParser
      Returns:
      A new session builder.
    • getSession

      Description copied from class: Context
      Returns a session to use for this context.

      Note that subclasses may opt to return a reusable non-modifiable session.

      Overrides:
      getSession in class ReaderParser
      Returns:
      A new session object.
    • getPartSession

      Description copied from interface: HttpPartParser
      Creates a new parser session.
      Specified by:
      getPartSession in interface HttpPartParser
      Returns:
      A new parser session.
    • parse

      public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException
      Converts the specified input to the specified class type.
      Type Parameters:
      T - The POJO type to transform the input into.
      Parameters:
      partType - The part type being parsed.
      schema - Schema information about the part.
      May be null.
      Not all part parsers use the schema information.
      in - The input being parsed.
      toType - The POJO type to transform the input into.
      Returns:
      The parsed value.
      Throws:
      ParseException - Malformed input encountered.
      SchemaValidationException - If the input or resulting HTTP part object fails schema validation.
    • parse

      public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException
      Converts the specified input to the specified class type.
      Type Parameters:
      T - The POJO type to transform the input into.
      Parameters:
      partType - The part type being parsed.
      schema - Schema information about the part.
      May be null.
      Not all part parsers use the schema information.
      in - The input being parsed.
      toType - The POJO type to transform the input into.
      Returns:
      The parsed value.
      Throws:
      ParseException - Malformed input encountered.
      SchemaValidationException - If the input or resulting HTTP part object fails schema validation.
    • parse

      public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type... toTypeArgs) throws ParseException, SchemaValidationException
      Converts the specified input to the specified class type.
      Type Parameters:
      T - The POJO type to transform the input into.
      Parameters:
      partType - The part type being parsed.
      schema - Schema information about the part.
      May be null.
      Not all part parsers use the schema information.
      in - The input being parsed.
      toType - The POJO type to transform the input into.
      toTypeArgs - The generic type arguments of the POJO type to transform the input into.
      Returns:
      The parsed value.
      Throws:
      ParseException - Malformed input encountered.
      SchemaValidationException - If the input or resulting HTTP part object fails schema validation.
    • getUonClassMeta

      Description copied from interface: UonMetaProvider
      Returns the language-specific metadata on the specified class.
      Specified by:
      getUonClassMeta in interface UonMetaProvider
      Parameters:
      cm - The class to return the metadata on.
      Returns:
      The metadata.
    • getUonBeanPropertyMeta

      Description copied from interface: UonMetaProvider
      Returns the language-specific metadata on the specified bean property.
      Specified by:
      getUonBeanPropertyMeta in interface UonMetaProvider
      Parameters:
      bpm - The bean property to return the metadata on.
      Returns:
      The metadata.
    • isDecoding

      protected final boolean isDecoding()
      Decode "%xx" sequences enabled
      Returns:
      true if URI encoded characters should be decoded, false if they've already been decoded before being passed to this parser.
      See Also:
    • isValidateEnd

      protected final boolean isValidateEnd()
      Validate end enabled.
      Returns:
      true if after parsing a POJO from the input, verifies that the remaining input in the stream consists of only comments or whitespace.
      See Also:
    • getClassMeta

      public <T> ClassMeta<T> getClassMeta(Class<T> c)
      Description copied from interface: HttpPartParser
      Returns metadata about the specified class.
      Specified by:
      getClassMeta in interface HttpPartParser
      Type Parameters:
      T - The class type.
      Parameters:
      c - The class type.
      Returns:
      Metadata about the specified class.
    • getClassMeta

      public <T> ClassMeta<T> getClassMeta(Type t, Type... args)
      Description copied from interface: HttpPartParser
      Returns metadata about the specified class.
      Specified by:
      getClassMeta in interface HttpPartParser
      Type Parameters:
      T - The class type.
      Parameters:
      t - The class type.
      args - The class type args.
      Returns:
      Metadata about the specified class.
    • properties

      protected JsonMap properties()
      Description copied from class: Context
      Returns the properties on this bean as a map for debugging.
      Overrides:
      properties in class ReaderParser
      Returns:
      The properties on this bean as a map for debugging.