Class ParserSession

All Implemented Interfaces:
BeanSession, ConverterSession
Direct Known Subclasses:
InputStreamParserSession, ReaderParserSession

public class ParserSession extends MarshallingSession
Session object that lives for the duration of a single use of Parser.
Notes:
  • This class is not thread safe and is typically discarded after one use.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static ParserSession.Builder<?> create(Parser ctx)
      Creates a new builder for this object.
      Parameters:
      ctx - The context creating this session.
      Cannot be null.
      Returns:
      A new builder.
    • setName

      protected static final void setName(ClassMeta<?> cm, Object o, Object name) throws ExecutableException
      Convenience method for calling the @NameProperty method on the specified object if it exists.
      Parameters:
      cm - The class type of the object.
      Can be null (no-op).
      o - The object.
      name - The name to set.
      Throws:
      ExecutableException - Exception occurred on invoked constructor/method/field.
    • setParent

      protected static final void setParent(ClassMeta<?> cm, Object o, Object parent) throws ExecutableException
      Convenience method for calling the @ParentProperty method on the specified object if it exists.
      Parameters:
      cm - The class type of the object.
      Can be null (no-op).
      o - The object.
      parent - The parent to set.
      Throws:
      ExecutableException - Exception occurred on invoked constructor/method/field.
    • parentBean

      protected final Object parentBean()
      Returns the nearest enclosing bean used as the parent for @ParentProperty injection.

      Unlike getOuter() (which also serves as the instantiation context for non-static member/inner classes), this value tracks only the nearest enclosing bean as the object graph is parsed, deliberately skipping any intermediate collections/maps/arrays. It is null at the document root (no enclosing bean), which means a bean parsed at the root or directly inside a top-level collection has no parent injected.

      Returns:
      The nearest enclosing bean, or null if there is none.
    • swapParentBean

      protected final Object swapParentBean(Object value)
      Sets the nearest-enclosing-bean tracker used for @ParentProperty injection.

      Callers should invoke this when they begin populating a bean's properties (passing that bean), then pass the returned previous value back to this method once done, restoring the tracker stack-style.

      Parameters:
      value - The new nearest enclosing bean (typically the bean currently being populated).
      Returns:
      The previous value, to be passed back to this method to restore the tracker.
    • getInputAsString

      Returns the input as a string.

      This always returns a value for input of type CharSequence.
      For other input types, use Context.Builder#debug() setting to enable caching to a string before parsing so that this method returns the input.

      Returns:
      The input as a string, or null if no pipe has been created or we're reading from an uncached reader or input stream source.
    • getLastLocation

      public final JsonMap getLastLocation()
      Returns information used to determine at what location in the parse a failure occurred.
      Returns:
      A map, typically containing something like {line:123,column:456,currentProperty:"foobar"}
    • getListener

      Returns the listener associated with this session.
      Returns:
      The listener associated with this session, or null if there is no listener.
    • getListener

      public <T extends ParserListener> T getListener(Class<T> c)
      Returns the listener associated with this session.
      Type Parameters:
      T - The listener type.
      Parameters:
      c - The listener class to cast to.
      Returns:
      The listener associated with this session, or null if there is no listener.
    • getPosition

      Returns the current position into the reader or input stream.
      Returns:
      The current position into the reader or input stream.
      Never null.
    • getSchema

      public final HttpPartSchema getSchema()
      HTTP part schema of object being parsed.
      Returns:
      HTTP part schema of object being parsed, or null if not specified.
    • isReaderParser

      public boolean isReaderParser()
      Returns true if this parser subclasses from ReaderParser.
      Returns:
      true if this parser subclasses from ReaderParser.
    • read

      public final <T> T read(Object input, Class<T> type) throws ParseException, IOException
      Same as read(Object, Type, Type...) except optimized for a non-parameterized class.

      This is the preferred parse method for simple types since you don't need to cast the results.

      Examples:

      ReaderParser parser = JsonParser.DEFAULT; // Parse into a string. String string = parser.read(json, String.class); // Parse into a bean. MyBean bean = parser.read(json, MyBean.class); // Parse into a bean array. MyBean[] beanArray = parser.read(json, MyBean[].class); // Parse into a linked-list of objects. List list = parser.read(json, LinkedList.class); // Parse into a map of object keys/values. Map map = parser.read(json, TreeMap.class);

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input. See read(Object, Type, Type...) for details.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
      IOException - Thrown by the underlying stream.
    • read

      public final <T> T read(Object input, ClassMeta<T> type) throws ParseException, IOException
      Same as read(Object, Type, Type...) except the type has already been converted into a ClassMeta object.

      This is mostly an internal method used by the framework.

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input. See read(Object, Type, Type...) for details.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
      IOException - Thrown by the underlying stream.
    • read

      public final <T> T read(Object input, Type type, Type... args) throws ParseException, IOException
      Parses input into the specified object type.

      The type can be a simple type (e.g. beans, strings, numbers) or parameterized type (collections/maps).

      Examples:

      ReaderParser parser = JsonParser.DEFAULT; // Parse into a linked-list of strings. List list1 = parser.read(json, LinkedList.class, String.class); // Parse into a linked-list of beans. List list2 = parser.read(json, LinkedList.class, MyBean.class); // Parse into a linked-list of linked-lists of strings. List list3 = parser.read(json, LinkedList.class, LinkedList.class, String.class); // Parse into a map of string keys/values. Map map1 = parser.read(json, TreeMap.class, String.class, String.class); // Parse into a map containing string keys and values of lists containing beans. Map map2 = parser.read(json, TreeMap.class, String.class, List.class, MyBean.class);

      Collection classes are assumed to be followed by zero or one objects indicating the element type.

      Map classes are assumed to be followed by zero or two meta objects indicating the key and value types.

      The array can be arbitrarily long to indicate arbitrarily complex data structures.

      Notes:
      Type Parameters:
      T - The class type of the object to create.
      Parameters:
      input - The input.
      Character-based parsers can handle the following input class types:
      Stream-based parsers can handle the following input class types:
      type - The object type to create.
      Can be any of the following: ClassMeta, Class, ParameterizedType, GenericArrayType
      args - The type arguments of the class if it's a collection or map.
      Can be any of the following: ClassMeta, Class, ParameterizedType, GenericArrayType
      Ignored if the main type is not a map or collection.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
      IOException - Thrown by the underlying stream.
      See Also:
    • read

      public final <T> T read(String input, Class<T> type) throws ParseException
      Same as read(Object, Class) but parses from a string and doesn't throw an IOException.

      This is the preferred parse method for simple types since you don't need to cast the results.

      Examples:

      ReaderParser parser = JsonParser.DEFAULT; // Parse into a string. String string = parser.read(json, String.class); // Parse into a bean. MyBean bean = parser.read(json, MyBean.class); // Parse into a bean array. MyBean[] beanArray = parser.read(json, MyBean[].class); // Parse into a linked-list of objects. List list = parser.read(json, LinkedList.class); // Parse into a map of object keys/values. Map map = parser.read(json, TreeMap.class);

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input. See read(Object, Type, Type...) for details.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
    • read

      public final <T> T read(String input, ClassMeta<T> type) throws ParseException
      Same as read(Object, ClassMeta) except parses from a string and doesn't throw an IOException.

      This is mostly an internal method used by the framework.

      Type Parameters:
      T - The class type of the object being created.
      Parameters:
      input - The input. See read(Object, Type, Type...) for details.
      type - The object type to create.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
    • read

      public final <T> T read(String input, Type type, Type... args) throws ParseException
      Same as read(Object,Type,Type...) but parses from a string and doesn't throw an IOException.
      Type Parameters:
      T - The class type of the object to create.
      Parameters:
      input - The input.
      Character-based parsers can handle the following input class types:
      Stream-based parsers can handle the following input class types:
      type - The object type to create.
      Can be any of the following: ClassMeta, Class, ParameterizedType, GenericArrayType
      args - The type arguments of the class if it's a collection or map.
      Can be any of the following: ClassMeta, Class, ParameterizedType, GenericArrayType
      Ignored if the main type is not a map or collection.
      Returns:
      The parsed object.
      Throws:
      ParseException - Malformed input encountered.
      See Also:
    • readArgs

      public final Object[] readArgs(Object input, Type[] argTypes) throws ParseException
      Parses the specified array input with each entry in the object defined by the argTypes argument.

      Used for converting arrays (e.g. "[arg1,arg2,...]") into an Object[] that can be passed to the Method.invoke(target, args) method.

      Used in the following locations:

      Parameters:
      input - The input. Subclasses can support different input types.
      argTypes - Specifies the type of objects to create for each entry in the array.
      Returns:
      An array of parsed objects.
      Throws:
      ParseException - Malformed input encountered.
    • readIntoCollection

      public final <E> Collection<E> readIntoCollection(Object input, Collection<E> c, Type elementType) throws ParseException
      Parses the contents of the specified reader and loads the results into the specified collection.

      Used in the following locations:

      Type Parameters:
      E - The element class type.
      Parameters:
      input - The input. See read(Object, ClassMeta) for supported input types.
      c - The collection being loaded.
      elementType - The class type of the elements, or null to default to whatever is being parsed.
      Returns:
      The same collection that was passed in to allow this method to be chained.
      Throws:
      ParseException - Malformed input encountered.
      UnsupportedOperationException - If not implemented.
    • readIntoMap

      public final <K, V> Map<K,V> readIntoMap(Object input, Map<K,V> m, Type keyType, Type valueType) throws ParseException
      Parses the contents of the specified reader and loads the results into the specified map.

      Reader must contain something that serializes to a map (such as text containing a JSON object).

      Used in the following locations:

      Type Parameters:
      K - The key class type.
      V - The value class type.
      Parameters:
      input - The input. See read(Object, ClassMeta) for supported input types.
      m - The map being loaded.
      keyType - The class type of the keys, or null to default to String.class.
      valueType - The class type of the values, or null to default to whatever is being parsed.
      Returns:
      The same map that was passed in to allow this method to be chained.
      Throws:
      ParseException - Malformed input encountered.
      UnsupportedOperationException - If not implemented.
    • readToBeanConsumer

      public final <T> void readToBeanConsumer(Object input, BeanConsumer<T> consumer, Class<T> elementType) throws ParseException, IOException
      Parses the input and streams each parsed element into the given BeanConsumer.

      This is the primary API for large-dataset parsing where parsed beans should be consumed lazily (e.g. inserted directly into a database) rather than collected into an in-memory collection.

      The parser drives the full consumer lifecycle:

      1. Calls BeanConsumer.begin() before parsing starts
      2. Calls ThrowingConsumer.acceptThrows(Object) for each parsed element
      3. If ThrowingConsumer.acceptThrows(Object) throws, calls BeanConsumer.onError(Exception); if onError() absorbs the exception, parsing continues to the next element
      4. Always calls BeanConsumer.complete() at the end (like finally)

      The default implementation parses the input into a List first and then feeds each element to the consumer. Format-specific subclasses may override doReadToBeanConsumer(org.apache.juneau.marshall.parser.ParserPipe, org.apache.juneau.commons.function.BeanConsumer<T>, java.lang.Class<T>) for true streaming behavior without loading all elements into memory.

      Type Parameters:
      T - The element type.
      Parameters:
      input - The input to parse.
      consumer - The consumer to receive parsed elements.
      elementType - The type of each element.
      Throws:
      ParseException - If a parse error occurs that causes onError() to rethrow.
      IOException - If an I/O error occurs reading the input.
    • doReadToBeanConsumer

      protected <T> void doReadToBeanConsumer(ParserPipe pipe, BeanConsumer<T> consumer, Class<T> elementType) throws ParseException, IOException
      Format-specific implementation for readToBeanConsumer(java.lang.Object, org.apache.juneau.commons.function.BeanConsumer<T>, java.lang.Class<T>).

      The default implementation parses the input as a List and feeds each element to the consumer. Override this method in format-specific parsers to support true streaming without collecting all elements into memory.

      Type Parameters:
      T - The element type.
      Parameters:
      pipe - The parser input pipe.
      consumer - The consumer to receive parsed elements.
      elementType - The type of each element.
      Throws:
      ParseException - If a parse error occurs.
      IOException - If an I/O error occurs.
    • checkRequired

      protected final <T> BeanMap<T> checkRequired(BeanMap<T> m)
      Throws MissingRequiredPropertyException if the bean map is missing @BeanProp(required=true) properties.

      Call once per bean, after all input properties have been put into the map and before BeanMap.getBean() constructs it. Do not call it for intermediate bean maps that are filled in later.

      Type Parameters:
      T - The bean type.
      Parameters:
      m - The bean map. Can be null.
      Returns:
      The same bean map.
    • cast

      protected final Object cast(MarshalledMap m, BeanPropertyMeta pMeta, ClassMeta<?> eType)
      Converts the specified MarshalledMap into a bean identified by the "_type" property in the map.
      Parameters:
      m - The map to convert to a bean.
      Must not be null.
      pMeta - The current bean property being parsed.
      Can be null (the @MarshalledProp(dictionary={}) registry lookup is skipped).
      eType - The current expected type being parsed.
      Can be null (the @Marshalled(dictionary={}) registry lookup on the expected type is skipped).
      Returns:
      The converted bean, or the same map if the "_type" entry wasn't found or didn't resolve to a bean.
    • convertAttrToType

      protected final <T> T convertAttrToType(Object outer, String s, ClassMeta<T> type) throws ParseException
      Converts the specified string to the specified type.
      Type Parameters:
      T - The class type to convert the string to.
      Parameters:
      outer - The outer object if we're converting to an inner object that needs to be created within the context of an outer object.
      Can be null if the target is not a non-static inner class requiring an enclosing instance.
      s - The string to convert.
      Can be null (returns null).
      type - The class type to convert the string to.
      Can be null (defaults to Object).
      Returns:
      The string converted as an object of the specified type, or null if the input string was null.
      Throws:
      ParseException - Malformed input encountered.
      ExecutableException - Exception occurred on invoked constructor/method/field.
    • createPipe

      protected ParserPipe createPipe(Object input)
      Wraps the specified input object into a ParserPipe object so that it can be easily converted into a stream or reader.
      Parameters:
      input - The input.
      For character-based parsers, this can be any of the following types:
      For byte-based parsers, this can be any of the following types:
      Returns:
      A new ParserPipe wrapper around the specified input object.
    • doRead

      protected <T> T doRead(ParserPipe pipe, ClassMeta<T> type) throws IOException, ParseException, ExecutableException
      Workhorse 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).

      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. If null or Object.class, object type is based on what's being parsed. For example, when parsing JSON text, it may return a 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
      Implementation method.

      Default implementation throws an UnsupportedOperationException.

      Type Parameters:
      E - The element type.
      Parameters:
      pipe - The parser input.
      c - The collection being loaded.
      elementType - The class type of the elements, or null 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 Exception
      Implementation method.

      Default implementation throws an UnsupportedOperationException.

      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, or null to default to String.class.
      valueType - The class type of the values, or null 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.
    • getClassMeta

      protected final ClassMeta<?> getClassMeta(String typeName, BeanPropertyMeta pMeta, ClassMeta<?> eType)
      Give the specified dictionary name, resolve it to a class.
      Parameters:
      typeName - The dictionary name to resolve.
      pMeta - The bean property we're currently parsing.
      Can be null (the @MarshalledProp(dictionary={}) registry lookup is skipped).
      eType - The expected type we're currently parsing.
      Can be null (the @Marshalled(dictionary={}) registry lookup on the expected type is skipped).
      Returns:
      The resolved class, or null if the type name could not be resolved.
    • getDebugOutputLines

      protected final int getDebugOutputLines()
      Debug output lines.
      Returns:
      The number of lines of input before and after the error location to be printed as part of the exception message.
      See Also:
    • getJavaMethod

      protected final Method getJavaMethod()
      Returns the Java method that invoked this parser.

      When using the REST API, this is the Java method invoked by the REST call. Can be used to access annotations defined on the method or class.

      Returns:
      The Java method that invoked this parser, or null if not set.
    • getListenerClass

      protected final Class<? extends ParserListener> getListenerClass()
      Parser listener.
      Returns:
      Class used to listen for errors and warnings that occur during parsing, or null if none was configured.
      See Also:
    • getOuter

      protected final Object getOuter()
      Returns the outer object used for instantiating top-level non-static member classes.

      When using the REST API, this is the servlet object.

      Returns:
      The outer object, or null if none was specified.
    • getStringBuilder

      protected final StringBuilder getStringBuilder()
      Creates a reusable StringBuilder object from an internal pool.

      String builders are returned to the pool by calling returnStringBuilder(StringBuilder).

      Returns:
      A new or previously returned string builder.
    • isAutoCloseStreams

      protected final boolean isAutoCloseStreams()
      Auto-close streams.
      Returns:
      true if InputStreams and Readers passed into parsers will be closed after parsing is complete.
      See Also:
    • isTrimStrings

      protected final boolean isTrimStrings()
      Trim parsed strings.
      Returns:
      true if string values will be trimmed of whitespace using String.trim() before being added to the POJO.
      See Also:
    • getNulls

      public final Nulls getNulls()
      Returns the effective Nulls default for this session — the per-session override (set via ParserSession.Builder.nulls(Nulls)) when present, otherwise the parser context's Parser.getNulls() value.
      Returns:
      The current session-level value (never null; Nulls.NOT_SET when unconfigured).
      Since:
      10.0.0
    • isUnbuffered

      protected final boolean isUnbuffered()
      Unbuffered.
      Returns:
      true if parsers don't use internal buffering during parsing.
      See Also:
    • getDurationFormat

      protected final DurationFormat getDurationFormat()
      Duration parse hint format.
      Returns:
      The configured duration parse hint format.
    • getPeriodFormat

      protected final PeriodFormat getPeriodFormat()
      Period parse hint format.
      Returns:
      The configured period parse hint format.
    • getCalendarFormat

      protected final CalendarFormat getCalendarFormat()
      Calendar parse hint format.
      Returns:
      The configured calendar parse hint format.
    • getDateFormat

      protected final DateFormat getDateFormat()
      Date parse hint format.
      Returns:
      The configured date parse hint format.
    • getTemporalFormat

      protected final TemporalFormat getTemporalFormat()
      Temporal parse hint format.
      Returns:
      The configured temporal parse hint format.
    • getTimeZoneFormat

      protected final TimeZoneFormat getTimeZoneFormat()
      Time-zone parse hint format.
      Returns:
      The configured time-zone parse hint format.
    • getLocaleFormat

      protected final LocaleFormat getLocaleFormat()
      Locale parse hint format.
      Returns:
      The configured locale parse hint format.
    • readDuration

      protected final Duration readDuration(String s)
      Parses an ISO 8601 / numeric wire value into a Duration using this session's configured duration format as the disambiguation hint.
      Parameters:
      s - The wire value to parse. null or empty returns null.
      Returns:
      The parsed Duration, or null if s is null or empty.
    • readPeriod

      protected final Period readPeriod(String s)
      Parses an ISO 8601 / numeric wire value into a Period using this session's configured period format as the disambiguation hint.
      Parameters:
      s - The wire value to parse. null or empty returns null.
      Returns:
      The parsed Period, or null if s is null or empty.
    • readDate

      protected final <T> T readDate(String s, ClassMeta<T> cm)
      Parses an ISO 8601 wire value into a Date target using this session's configured date format and time zone.
      Type Parameters:
      T - The target type (unbounded to match Iso8601Utils.parseDate(java.lang.String, org.apache.juneau.marshall.ClassMeta<T>, org.apache.juneau.marshall.DateFormat, java.util.TimeZone)).
      Parameters:
      s - The wire value to parse. null returns null.
      cm - The target class metadata.
      Returns:
      The parsed value, or null if s is null or the target is not a recognized Date type.
    • readCalendar

      protected final <T> T readCalendar(String s, ClassMeta<T> cm)
      Parses an ISO 8601 wire value into a Calendar or XMLGregorianCalendar target using this session's configured calendar format and time zone.
      Type Parameters:
      T - The target type (unbounded because XMLGregorianCalendar is not a Calendar subclass).
      Parameters:
      s - The wire value to parse. null returns null.
      cm - The target class metadata.
      Returns:
      The parsed value, or null if s is null or the target is not a recognized calendar type.
    • readTemporal

      protected final <T> T readTemporal(String s, ClassMeta<T> cm)
      Parses an ISO 8601 wire value into the specified Temporal subtype using this session's configured temporal format and time zone.
      Type Parameters:
      T - The target type (unbounded to match Iso8601Utils.parseTemporal(java.lang.String, org.apache.juneau.marshall.ClassMeta<T>, org.apache.juneau.marshall.TemporalFormat, java.util.TimeZone)).
      Parameters:
      s - The wire value to parse. null returns null.
      cm - The target class metadata.
      Returns:
      The parsed value, or null if s is null or the target is not a Temporal subtype.
    • enterParseDepth

      protected final void enterParseDepth() throws ParseException
      Enters one level of recursive databind parsing, enforcing the shared ParserSession.Builder.maxParseDepth(int) budget (default 1000).

      Binary codec sessions (CBOR, Protobuf, MsgPack) call this at their recursive databind entry point before descending into a nested array/map/message element, and must call exitParseDepth() in a matching finally block regardless of outcome. Exceeding the budget throws a ParseException so an adversarial deeply-nested document fails cleanly instead of exhausting the call stack with a StackOverflowError.

      Intentionally not applied to the JSON/XML/text parsers, whose recursive-descent parsers already rely on StackOverflowError conversion at the outer parse boundary.

      Throws:
      ParseException - If the configured maximum parse depth was exceeded.
    • exitParseDepth

      protected final void exitParseDepth()
      Exits one level of recursive databind parsing previously entered via enterParseDepth().

      Must be called exactly once per successful enterParseDepth() call, in a matching finally block so the depth counter is restored even when the nested parse throws.

    • allocateLocal

      protected final <T> T allocateLocal(String what, Supplier<T> alloc) throws ParseException
      Runs a local, parser-controlled allocation (e.g. pre-sizing an array/collection/buffer from a wire-declared count) and converts an OutOfMemoryError thrown specifically from it into a bounded ParseException.

      Only an OutOfMemoryError thrown from alloc's own execution is converted here. Any other OutOfMemoryError — one raised elsewhere in the call stack, signaling a JVM that is genuinely running out of heap — is not this method's concern and is never observed by it; a dying JVM is not a client input-validation failure and must not be reported as one. Format-specific parser sessions should route untrusted-length-driven local allocations through this helper instead of relying on a blanket catch at an outer parse boundary.

      Type Parameters:
      T - The allocated object's type.
      Parameters:
      what - A short human-readable description of what's being allocated, used in the exception message if the allocation fails.
      Must not be null.
      alloc - The allocation to attempt.
      Must not be null.
      Returns:
      The allocated object.
      Throws:
      ParseException - If alloc itself threw an OutOfMemoryError.
    • mark

      protected void mark()
      Marks the current position.
    • onBeanSetterException

      protected final void onBeanSetterException(BeanPropertyMeta p, Throwable t)
      Specialized warning when an exception is thrown while executing a bean setter.
      Parameters:
      p - The bean map entry representing the bean property.
      Must not be null.
      t - The throwable that the bean setter threw.
    • onUnknownProperty

      protected final <T> void onUnknownProperty(String propertyName, BeanMap<T> beanMap, Object value) throws ParseException
      Method that gets called when an unknown bean property name is encountered.
      Type Parameters:
      T - The class type of the bean map that doesn't have the expected property.
      Parameters:
      propertyName - The unknown bean property name.
      Must not be null.
      beanMap - The bean that doesn't have the expected property.
      Must not be null.
      value - The parsed value.
      Can be null, in which case whether the property is ignored is governed by MarshallingContext.Builder.disableIgnoreUnknownNullBeanProperties() rather than MarshallingContext.Builder.ignoreUnknownBeanProperties().
      Throws:
      ParseException - Automatically thrown if MarshallingContext.Builder.ignoreUnknownBeanProperties() setting on this parser is false
    • properties

      Description copied from class: ContextSession
      Returns the properties on this bean as a map for debugging.
      Overrides:
      properties in class MarshallingSession
      Returns:
      The properties on this bean as a map for debugging.
    • returnStringBuilder

      protected final void returnStringBuilder(StringBuilder sb)
      Returns a StringBuilder object back into the internal reuse pool.
      Parameters:
      sb - The string builder to return to the pool. No-op if null.
    • setCurrentClass

      protected final void setCurrentClass(ClassMeta<?> currentClass)
      Sets the current class being parsed for proper error messages.
      Parameters:
      currentClass - The current class being parsed.
    • setCurrentProperty

      protected final void setCurrentProperty(BeanPropertyMeta currentProperty)
      Sets the current bean property being parsed for proper error messages.
      Parameters:
      currentProperty - The current property being parsed.
    • setPipe

      protected ParserPipe setPipe(ParserPipe pipe)
      The createPipe(Object) method should call this method to set the pipe for debugging purposes.
      Parameters:
      pipe - The pipe created for this session.
      Returns:
      The same pipe.
    • trim

      protected final <K> K trim(K o)
      Trims the specified object if it's a String and isTrimStrings() returns true.
      Type Parameters:
      K - The object type.
      Parameters:
      o - The object to trim.
      Returns:
      The trimmed string if it's a string.
    • trim

      protected final String trim(String s)
      Trims the specified string if isTrimStrings() returns true.
      Parameters:
      s - The input string to trim.
      Returns:
      The trimmed string, or null if the input was null.
    • unmark

      protected void unmark()
      Unmarks the current position.
    • unswap

      protected Object unswap(ObjectSwap swap, Object o, ClassMeta<?> eType) throws ParseException
      Invokes the specified swap on the specified object.
      Parameters:
      swap - The swap to invoke.
      Must not be null.
      o - The input object.
      eType - The expected type.
      Returns:
      The swapped object.
      Throws:
      ParseException - If swap method threw an exception.