Class UonParser
- All Implemented Interfaces:
HttpPartParser,RecordReadable,UonMetaProvider
- Direct Known Subclasses:
OpenApiParser,UonParser.Decoding,UrlEncodingParser
Media types
Handles
Description
This parser uses a state machine, which makes it very fast and efficient.
Example input (Map of name/age):
(name=Alice,age=30)
Complex (nested object + array):
(name=Alice,age=30,address=(street=123+Main+St,city=Boston,state=MA),tags=@(a,b,c))
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUonParser.Builder<SELF extends UonParser.Builder<SELF>>Builder class.static classDefault parser, decoding.static final classNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.Parser
Parser.NullNested classes/interfaces inherited from interface org.apache.juneau.marshall.httppart.HttpPartParser
HttpPartParser.Creator, HttpPartParser.Void -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanstatic final UonParserReusable instance ofUonParser, all default settings.static final UonParserReusable instance ofUonParserwith decodeChars set to true.protected final booleanFields inherited from class org.apache.juneau.marshall.parser.Parser
autoCloseStreams, consumes, debugOutputLines, listener, nulls, trimStrings, unbufferedFields inherited from class org.apache.juneau.marshall.MarshallingContextable
marshallingContextFields inherited from class org.apache.juneau.marshall.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static UonParser.Builder<?>create()Creates a new builder for this object.Create a session builder based on the properties defined on this context.<T> ClassMeta<T>getClassMeta(Class<T> c) Returns metadata about the specified class.<T> ClassMeta<T>getClassMeta(Type t, Type... args) Returns metadata about the specified class.Creates a new parser session.Returns a session to use for this context.Returns the language-specific metadata on the specified bean property.getUonClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.protected final booleanDecode"%xx" sequences enabledbooleanStreaming-quality signal queryable before opening a cursor.protected final booleanValidate end enabled.Returns the properties on this bean as a map for debugging.<T> Tread(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) Converts the specified input to the specified class type.<T> Tread(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type... toTypeArgs) Converts the specified input to the specified class type.<T> Tread(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) Converts the specified input to the specified class type.readRecords(Object input) Convenience delegator that opens a whole-valueRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).Methods inherited from class org.apache.juneau.marshall.parser.ReaderParser
getStreamCharset, isReaderParserMethods inherited from class org.apache.juneau.marshall.parser.Parser
canHandle, createParserBuilder, doRead, getDebugOutputLines, getListener, getMediaTypes, getNulls, getPrimaryMediaType, isAutoCloseStreams, isTrimStrings, isUnbuffered, read, read, read, read, read, read, readArgs, readIntoCollection, readIntoMap, readWithOuterMethods inherited from class org.apache.juneau.marshall.MarshallingContextable
getDurationFormat, getMarshallingContext, getPeriodFormatMethods inherited from class org.apache.juneau.marshall.Context
createBuilder, getAnnotationProvider, init, isDebug, toString
-
Field Details
-
Constructor Details
-
UonParser
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
copy
Description copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
-
createSession
Description copied from class:ContextCreate 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:
createSessionin classReaderParser- Returns:
- A new session builder.
-
getClassMeta
Description copied from interface:HttpPartParserReturns metadata about the specified class.- Specified by:
getClassMetain interfaceHttpPartParser- Type Parameters:
T- The class type.- Parameters:
c- The class type.- Returns:
- Metadata about the specified class.
-
getClassMeta
Description copied from interface:HttpPartParserReturns metadata about the specified class.- Specified by:
getClassMetain interfaceHttpPartParser- Type Parameters:
T- The class type.- Parameters:
t- The class type.args- The class type args.- Returns:
- Metadata about the specified class.
-
getPartSession
Description copied from interface:HttpPartParserCreates a new parser session.- Specified by:
getPartSessionin interfaceHttpPartParser- Returns:
- A new parser session.
-
getSession
Description copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSessionin classReaderParser- Returns:
- A new session object.
-
readRecords
Convenience delegator that opens a whole-valueRecordReaderover the input using default session arguments (mirrorsParser.read(Object, Class)).The real implementation lives on
UonParserSession.readRecords(Object). Callers that need request-derived configuration (locale, timezone, schema, swaps) should callcreateSession()and invokeUonParserSession.readRecords(Object)on the built session instead.- Specified by:
readRecordsin interfaceRecordReadable- Parameters:
input- The input.- Returns:
- A new
RecordReadercursor. - Throws:
IOException- If a problem occurred opening the underlying input.
-
isRecordStreaming
Description copied from interface:RecordReadableStreaming-quality signal queryable before opening a cursor.- Specified by:
isRecordStreamingin interfaceRecordReadable- Returns:
true ifRecordReadable.readRecords(Object)returns an O(1)-memory streaming cursor;false for buffered (whole-value) formats backed byRecordAdapter.
-
getUonBeanPropertyMeta
Description copied from interface:UonMetaProviderReturns the language-specific metadata on the specified bean property.- Specified by:
getUonBeanPropertyMetain interfaceUonMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getUonClassMeta
Description copied from interface:UonMetaProviderReturns the language-specific metadata on the specified class.- Specified by:
getUonClassMetain interfaceUonMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
read
public <T> T read(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 benull .
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.
-
read
public <T> T read(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 benull .
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.
-
read
public <T> T read(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 benull .
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.
-
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
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:
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classReaderParser- Returns:
- The properties on this bean as a map for debugging.
-