Package org.apache.juneau.uon
Class UonParserSession
java.lang.Object
org.apache.juneau.ContextSession
org.apache.juneau.BeanSession
org.apache.juneau.parser.ParserSession
org.apache.juneau.parser.ReaderParserSession
org.apache.juneau.uon.UonParserSession
- All Implemented Interfaces:
HttpPartParserSession
- Direct Known Subclasses:
OpenApiParserSession
,UrlEncodingParserSession
Session object that lives for the duration of a single use of
UonParser
.
Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
-
Nested Class Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
UonParserSession
(UonParserSession.Builder builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic UonParserSession.Builder
Creates a new builder for this object.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.final UonReader
getUonReader
(ParserPipe pipe, boolean decodeChars) Creates aUonReader
from the specified parser pipe.protected final boolean
Decode"%xx" sequences.protected final boolean
Validate end.<T> T
parse
(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) 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 final Object
Convenience method for parsing an attribute from the specified parser.protected final String
parseAttrName
(UonReader r, boolean encoded) Parses an attribute name from the specified reader.protected final String
parseString
(UonReader r, boolean isUrlParamValue) Parses a string value from the specified reader.protected JsonMap
Returns the properties on this bean as a map for debugging.Methods inherited from class org.apache.juneau.parser.ReaderParserSession
create, createPipe, getFileCharset, getStreamCharset, isReaderParser
Methods inherited from class org.apache.juneau.parser.ParserSession
cast, convertAttrToType, create, getClassMeta, getDebugOutputLines, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getOuter, getPosition, getSchema, getStringBuilder, isAutoCloseStreams, isStrict, isTrimStrings, isUnbuffered, mark, onBeanSetterException, onUnknownProperty, parse, parse, parse, parse, parse, parse, parseArgs, parseIntoCollection, parseIntoMap, returnStringBuilder, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, trim, trim, unmark, unswap
Methods inherited from class org.apache.juneau.BeanSession
_class, addWarning, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, create, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMediaType, getNamePropertyName, getNotBeanClasses, getNotBeanPackagesNames, getNotBeanPackagesPrefixes, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, newGenericMap, object, string, toArray, toBeanMap, toBeanMap, toBeanMap
Methods inherited from class org.apache.juneau.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toString
-
Constructor Details
-
UonParserSession
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx
- The context creating this session.- Returns:
- A new builder.
-
doParse
protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException Description copied from class:ParserSession
Workhorse method.Subclasses are expected to implement this method or
Parser.doParse(ParserSession,ParserPipe,ClassMeta)
.The default implementation of this method simply calls
Parser.doParse(ParserSession,ParserPipe,ClassMeta)
.- Overrides:
doParse
in classParserSession
- Type Parameters:
T
- The class type of the object to create.- Parameters:
pipe
- Where to get the input from.type
- The class type of the object to create. Ifnull orObject.
, object type is based on what's being parsed. For example, when parsing JSON text, it may return aclass String ,Number ,JsonMap , etc...- Returns:
- The parsed object.
- Throws:
IOException
- Thrown by underlying stream.ParseException
- Malformed input encountered.ExecutableException
- Exception occurred on invoked constructor/method/field.
-
doParseIntoMap
protected <K,V> Map<K,V> doParseIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) throws ExceptionDescription copied from class:ParserSession
Implementation method.Default implementation throws an
UnsupportedOperationException
.- Overrides:
doParseIntoMap
in classParserSession
- Type Parameters:
K
- The key type.V
- The value type.- Parameters:
pipe
- The parser input.m
- The map being loaded.keyType
- The class type of the keys, ornull to default toString.
.class valueType
- The class type of the values, ornull to default to whatever is being parsed.- Returns:
- The same map that was passed in to allow this method to be chained.
- Throws:
Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.
-
doParseIntoCollection
protected <E> Collection<E> doParseIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception Description copied from class:ParserSession
Implementation method.Default implementation throws an
UnsupportedOperationException
.- Overrides:
doParseIntoCollection
in classParserSession
- Type Parameters:
E
- The element type.- Parameters:
pipe
- The parser input.c
- The collection being loaded.elementType
- The class type of the elements, ornull to default to whatever is being parsed.- Returns:
- The same collection that was passed in to allow this method to be chained.
- Throws:
Exception
- If thrown from underlying stream, or if the input contains a syntax error or is malformed.
-
parse
public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException Description copied from interface:HttpPartParserSession
Converts the specified input to the specified class type.- Specified by:
parse
in interfaceHttpPartParserSession
- 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.
-
parseAnything
public <T> T parseAnything(ClassMeta<?> eType, UonReader r, Object outer, boolean isUrlParamValue, BeanPropertyMeta pMeta) throws IOException, ParseException, ExecutableException Workhorse method.- Type Parameters:
T
- The class type being parsed, ornull if unknown.- Parameters:
eType
- The class type being parsed, ornull if unknown.r
- The reader being parsed.outer
- The outer object (for constructing nested inner classes).isUrlParamValue
- Iftrue , then we're parsing a top-level URL-encoded value which is treated a bit different than the default case.pMeta
- The current bean property being parsed.- Returns:
- The parsed object.
- Throws:
IOException
- Thrown by underlying stream.ParseException
- Malformed input encountered.ExecutableException
- Exception occurred on invoked constructor/method/field.
-
parseAttr
Convenience method for parsing an attribute from the specified parser.- Parameters:
r
- The reader.encoded
- Whether the attribute is encoded.- Returns:
- The parsed object
- Throws:
IOException
- Exception thrown by underlying stream.ParseException
- Attribute was malformed.
-
parseAttrName
protected final String parseAttrName(UonReader r, boolean encoded) throws IOException, ParseException Parses an attribute name from the specified reader.- Parameters:
r
- The reader.encoded
- Whether the attribute is encoded.- Returns:
- The parsed attribute name.
- Throws:
IOException
- Exception thrown by underlying stream.ParseException
- Attribute name was malformed.
-
parseString
protected final String parseString(UonReader r, boolean isUrlParamValue) throws IOException, ParseException Parses a string value from the specified reader.- Parameters:
r
- The input reader.isUrlParamValue
- Whether this is a URL parameter.- Returns:
- The parsed string.
- Throws:
IOException
- Exception thrown by underlying stream.ParseException
- Malformed input found.
-
getUonReader
Creates aUonReader
from the specified parser pipe.- Parameters:
pipe
- The parser input.decodeChars
- Whether the reader should automatically decode URL-encoded characters.- Returns:
- A new
UonReader
object. - Throws:
IOException
- Thrown by underlying stream.
-
isDecoding
Decode"%xx" sequences.- 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.- 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:ContextSession
Returns the properties on this bean as a map for debugging.- Overrides:
properties
in classReaderParserSession
- Returns:
- The properties on this bean as a map for debugging.
-