public class UonParserSession extends ReaderParserSession implements HttpPartParserSession
UonParser
.
This class is NOT thread safe. It is typically discarded after one-time use although it can be reused against multiple inputs.
Modifier | Constructor and Description |
---|---|
protected |
UonParserSession(UonParser ctx,
ParserSessionArgs args)
Create a new session using properties specified in the context.
|
protected |
UonParserSession(UonParser ctx,
ParserSessionArgs args,
boolean decoding)
Create a specialized parser session for parsing URL parameters.
|
Modifier and Type | Method and Description |
---|---|
protected <T> T |
doParse(ParserPipe pipe,
ClassMeta<T> type)
Workhorse method.
|
protected <E> Collection<E> |
doParseIntoCollection(ParserPipe pipe,
Collection<E> c,
Type elementType)
Implementation method.
|
protected <K,V> Map<K,V> |
doParseIntoMap(ParserPipe pipe,
Map<K,V> m,
Type keyType,
Type valueType)
Implementation method.
|
UonReader |
getUonReader(ParserPipe pipe,
boolean decodeChars)
Creates a
UonReader from the specified parser pipe. |
protected boolean |
isDecoding()
Configuration property: Decode
|
protected boolean |
isValidateEnd()
Configuration property: Validate end.
|
<T> T |
parse(HttpPartSchema schema,
String in,
Class<T> toType)
Same as
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, Class) but defaults to a |
<T> T |
parse(HttpPartSchema schema,
String in,
ClassMeta<T> toType)
Same as
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, ClassMeta) but defaults to a |
<T> T |
parse(HttpPartSchema schema,
String in,
Type toType,
Type... toTypeArgs)
Same as
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, Type, Type...) but defaults to a |
<T> T |
parse(HttpPartType partType,
HttpPartSchema schema,
String in,
Class<T> toType)
Converts the specified input to the specified class type.
|
<T> T |
parse(HttpPartType partType,
HttpPartSchema schema,
String in,
ClassMeta<T> toType)
Converts the specified input to the specified class type.
|
<T> T |
parse(HttpPartType partType,
HttpPartSchema schema,
String in,
Type toType,
Type... toTypeArgs)
Converts the specified input to the specified class type.
|
<T> T |
parseAnything(ClassMeta<?> eType,
UonReader r,
Object outer,
boolean isUrlParamValue,
BeanPropertyMeta pMeta)
Workhorse method.
|
protected Object |
parseAttr(UonReader r,
boolean encoded)
Convenience method for parsing an attribute from the specified parser.
|
protected String |
parseAttrName(UonReader r,
boolean encoded)
Parses an attribute name from the specified reader.
|
protected String |
parseString(UonReader r,
boolean isUrlParamValue)
Parses a string value from the specified reader.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
createPipe, getFileCharset, getStreamCharset, isReaderParser
cast, convertAttrToType, getClassMeta, getDebugOutputLines, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getOuter, getPosition, isAutoCloseStreams, isStrict, isTrimStrings, isUnbuffered, mark, onUnknownProperty, parse, parse, parse, parse, parse, parse, parseArgs, parseIntoCollection, parseIntoMap, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, trim, trim, unmark, unswap
_class, checkForWarnings, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionaryClasses, getBeanFieldVisibility, getBeanFilters, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getBpi, getBpro, getBpwo, getBpx, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getExamples, getImplClasses, getLocale, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPojoSwaps, getPropertyNamer, getSchema, getStringBuilder, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isDebug, isFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnorePropertiesWithoutSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, object, returnStringBuilder, string, toArray, toBeanMap, toBeanMap
addToCache, addToCache, addWarning, getClassProperty, getFromCache, getInstanceArrayProperty, getInstanceProperty, getLogger, getProperties, getProperty, getProperty, getProperty, getPropertyKeys, getWarnings, hasProperty, hasWarnings, toString
protected UonParserSession(UonParser ctx, ParserSessionArgs args)
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.args
- Runtime session arguments.protected UonParserSession(UonParser ctx, ParserSessionArgs args, boolean decoding)
The main difference is that characters are never decoded, and the UonParser.UON_decoding
property is always ignored.
ctx
- The context creating this session object.
The context contains all the configuration settings for this object.args
- Runtime session arguments.decoding
- Whether to decode characters.protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException
ParserSession
Subclasses are expected to implement this method.
doParse
in class ParserSession
T
- The class type of the object to create.pipe
- Where to get the input from.type
- The class type of the object to create.
If Object.class
, object type is based on what's being parsed.
For example, when parsing JSON text, it may return a IOException
- Thrown by underlying stream.ParseException
- Malformed input encountered.ExecutableException
- Exception occurred on invoked constructor/method/field.protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K,V> m, Type keyType, Type valueType) throws Exception
ParserSession
Default implementation throws an UnsupportedOperationException
.
doParseIntoMap
in class ParserSession
pipe
- The parser input.m
- The map being loaded.keyType
- The class type of the keys, or String.class
.valueType
- The class type of the values, or Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.protected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception
ParserSession
Default implementation throws an UnsupportedOperationException
.
doParseIntoCollection
in class ParserSession
pipe
- The parser input.c
- The collection being loaded.elementType
- The class type of the elements, or Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException
HttpPartParserSession
parse
in interface HttpPartParserSession
partType
- The part type being parsed.schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException
HttpPartParserSession
parse
in interface HttpPartParserSession
partType
- The part type being parsed.schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, Type toType, Type... toTypeArgs) throws ParseException, SchemaValidationException
HttpPartParserSession
parse
in interface HttpPartParserSession
partType
- The part type being parsed.schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.toTypeArgs
- The POJO type arguments for Collection and Map types.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parse(HttpPartSchema schema, String in, Class<T> toType) throws ParseException, SchemaValidationException
HttpPartParserSession
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, Class)
but defaults to a parse
in interface HttpPartParserSession
schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parse(HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException
HttpPartParserSession
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, ClassMeta)
but defaults to a parse
in interface HttpPartParserSession
schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parse(HttpPartSchema schema, String in, Type toType, Type... toTypeArgs) throws ParseException, SchemaValidationException
HttpPartParserSession
HttpPartParserSession.parse(HttpPartType, HttpPartSchema, String, Type, Type...)
but defaults to a parse
in interface HttpPartParserSession
schema
- Schema information about the part.
in
- The input being parsed.toType
- The POJO type to transform the input into.toTypeArgs
- The POJO type arguments for Collection and Map types.ParseException
- Malformed input encountered.SchemaValidationException
- If the input or resulting HTTP part object fails schema validation.public <T> T parseAnything(ClassMeta<?> eType, UonReader r, Object outer, boolean isUrlParamValue, BeanPropertyMeta pMeta) throws IOException, ParseException, ExecutableException
T
- The class type being parsed, or eType
- The class type being parsed, or r
- The reader being parsed.outer
- The outer object (for constructing nested inner classes).isUrlParamValue
- If pMeta
- The current bean property being parsed.IOException
- Thrown by underlying stream.ParseException
- Malformed input encountered.ExecutableException
- Exception occurred on invoked constructor/method/field.protected final Object parseAttr(UonReader r, boolean encoded) throws IOException, ParseException
r
- The reader.encoded
- Whether the attribute is encoded.IOException
- Exception thrown by underlying stream.ParseException
- Attribute was malformed.protected final String parseAttrName(UonReader r, boolean encoded) throws IOException, ParseException
r
- The reader.encoded
- Whether the attribute is encoded.IOException
- Exception thrown by underlying stream.ParseException
- Attribute name was malformed.protected final String parseString(UonReader r, boolean isUrlParamValue) throws IOException, ParseException
r
- The input reader.isUrlParamValue
- Whether this is a URL parameter.IOException
- Exception thrown by underlying stream.ParseException
- Malformed input found.public final UonReader getUonReader(ParserPipe pipe, boolean decodeChars) throws IOException
UonReader
from the specified parser pipe.pipe
- The parser input.decodeChars
- Whether the reader should automatically decode URL-encoded characters.UonReader
object.IOException
- Thrown by underlying stream.protected final boolean isDecoding()
UonParser.UON_decoding
protected final boolean isValidateEnd()
UonParser.UON_validateEnd
public ObjectMap toMap()
Session
toMap
in class ReaderParserSession
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.