Package org.apache.juneau.marshall.uon
Class UonParserSession
java.lang.Object
org.apache.juneau.marshall.ContextSession
org.apache.juneau.marshall.MarshallingSession
org.apache.juneau.marshall.parser.ParserSession
org.apache.juneau.marshall.parser.ReaderParserSession
org.apache.juneau.marshall.uon.UonParserSession
- All Implemented Interfaces:
BeanSession,ConverterSession,HttpPartParserSession,RecordReadable
- Direct Known Subclasses:
OpenApiParserSession,UrlEncodingParserSession
public class UonParserSession
extends ReaderParserSession
implements HttpPartParserSession, RecordReadable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class.static final classConcrete default builder leaf for the non-subclassedcreate()path (CRTP terminal). -
Field Summary
Fields inherited from class org.apache.juneau.marshall.parser.ParserSession
DEFAULT_MAX_PARSE_DEPTHFields inherited from class org.apache.juneau.marshall.MarshallingSession
NAME_PROPERTY_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUonParserSession(UonParserSession.Builder<?> builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic UonParserSession.Builder<?>Creates a new builder for this object.protected <T> TdoRead(ParserPipe pipe, ClassMeta<T> type) Workhorse method.protected <E> Collection<E>doReadIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) Implementation method.protected <K,V> Map<K, V> doReadIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) Implementation method.static final UonReadergetUonReader(ParserPipe pipe, boolean decodeChars) Creates aUonReaderfrom the specified parser pipe.protected final booleanDecode"%xx" sequences.booleanStreaming-quality signal queryable before opening a cursor.protected final booleanValidate end.Returns the properties on this bean as a map for debugging.<T> Tread(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) Converts the specified input to the specified class type.<T> TreadAnything(ClassMeta<?> eType, UonReader r, Object outer, boolean isUrlParamValue, BeanPropertyMeta pMeta) Workhorse method.protected final ObjectConvenience method for parsing an attribute from the specified parser.protected final StringreadAttrName(UonReader r, boolean encoded) Parses an attribute name from the specified reader.readRecords(Object input) Opens a low-levelRecordReadercursor over the specified input.protected final StringreadString(UonReader r, boolean isUrlParamValue) Parses a string value from the specified reader.Methods inherited from class org.apache.juneau.marshall.parser.ReaderParserSession
create, createPipe, getStreamCharset, isReaderParserMethods inherited from class org.apache.juneau.marshall.parser.ParserSession
allocateLocal, cast, checkRequired, convertAttrToType, create, doReadToBeanConsumer, enterParseDepth, exitParseDepth, getCalendarFormat, getClassMeta, getDateFormat, getDebugOutputLines, getDurationFormat, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getLocaleFormat, getNulls, getOuter, getPeriodFormat, getPosition, getSchema, getStringBuilder, getTemporalFormat, getTimeZoneFormat, isAutoCloseStreams, isTrimStrings, isUnbuffered, mark, onBeanSetterException, onUnknownProperty, parentBean, read, read, read, read, read, read, readArgs, readCalendar, readDate, readDuration, readIntoCollection, readIntoMap, readPeriod, readTemporal, readToBeanConsumer, returnStringBuilder, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, swapParentBean, trim, trim, unmark, unswapMethods inherited from class org.apache.juneau.marshall.MarshallingSession
addWarning, convertToMemberType, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, convertToType, create, get, getActiveView, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassLoader, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMarshallingContext, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isPropertyInActiveView, isRecordComponentOrder, isUnsortedProperties, isUseInterfaceProxies, isUseJavaBeanIntrospector, isValidateSchema, newBean, newBean, newBeanMap, newBeanMap, newGenericList, newGenericMap, newGenericMap, object, parseToList, parseToMap, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.marshall.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
get
-
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.
-
readRecords
Description copied from interface:RecordReadableOpens a low-levelRecordReadercursor over the specified input.When invoked on a convenience
Parserthe cursor is opened with default session args (mirroringread(...)). Callers that need request-derived configuration (locale, timezone, schema, swaps) should instead callcreateSession(args).build()and invoke this method on the resultingParserSession(which is also aRecordReadable).- Specified by:
readRecordsin interfaceRecordReadable- Parameters:
input- The input. Subtypes define the supported types (typicallyReader/CharSequence/InputStream/byte[]/File).- Returns:
- A new
RecordReadercursor. - Throws:
IOException- If a problem occurred reading 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.
-
getUonReader
Creates aUonReaderfrom the specified parser pipe.- Parameters:
pipe- The parser input.decodeChars- Whether the reader should automatically decode URL-encoded characters.- Returns:
- A new
UonReaderobject. - Throws:
IOException- Thrown by underlying stream.
-
read
public <T> T read(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> toType) throws ParseException, SchemaValidationException Description copied from interface:HttpPartParserSessionConverts the specified input to the specified class type.- Specified by:
readin 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.
-
readAnything
public <T> T readAnything(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.
Must not benull .outer- The outer object (for constructing nested inner classes).
Can benull if there is no enclosing (outer) object; the parsed object is then not linked to a parent.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.
Can benull if no bean property metadata applies (e.g. the root value or an unknown property).- Returns:
- The parsed object.
- Throws:
IOException- Thrown by underlying stream.ParseException- Malformed input encountered.ExecutableException- Exception occurred on invoked constructor/method/field.
-
doRead
protected <T> T doRead(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException Description copied from class:ParserSessionWorkhorse method.Subclasses are expected to implement this method or
Parser.doRead(ParserSession,ParserPipe,ClassMeta).The default implementation of this method simply calls
Parser.doRead(ParserSession,ParserPipe,ClassMeta).- Overrides:
doReadin 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.
-
doReadIntoCollection
protected <E> Collection<E> doReadIntoCollection(ParserPipe pipe, Collection<E> c, Type elementType) throws Exception Description copied from class:ParserSessionImplementation method.Default implementation throws an
UnsupportedOperationException.- Overrides:
doReadIntoCollectionin 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.
-
doReadIntoMap
protected <K,V> Map<K,V> doReadIntoMap(ParserPipe pipe, Map<K, V> m, Type keyType, Type valueType) throws ExceptionDescription copied from class:ParserSessionImplementation method.Default implementation throws an
UnsupportedOperationException.- Overrides:
doReadIntoMapin 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.
-
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:
-
readAttr
Convenience method for parsing an attribute from the specified parser.- Parameters:
r- The reader.
Must not benull .encoded- Whether the attribute is encoded.- Returns:
- The parsed object, or
null if the attribute was the literal"null" . - Throws:
IOException- Exception thrown by underlying stream.ParseException- Attribute was malformed.
-
readAttrName
protected final String readAttrName(UonReader r, boolean encoded) throws IOException, ParseException Parses an attribute name from the specified reader.- Parameters:
r- The reader.
Must not benull .encoded- Whether the attribute is encoded.- Returns:
- The parsed attribute name, or
null if the attribute name was the literal"null" . - Throws:
IOException- Exception thrown by underlying stream.ParseException- Attribute name was malformed.
-
readString
protected final String readString(UonReader r, boolean isUrlParamValue) throws IOException, ParseException Parses a string value from the specified reader.- Parameters:
r- The input reader.
Must not benull .isUrlParamValue- Whether this is a URL parameter.- Returns:
- The parsed string, or
null if the value was the literal"null" . - Throws:
IOException- Exception thrown by underlying stream.ParseException- Malformed input found.
-
properties
Description copied from class:ContextSessionReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classReaderParserSession- Returns:
- The properties on this bean as a map for debugging.
-