Class ValueReader

java.lang.Object
com.fasterxml.jackson.jr.ob.api.ValueReader
Direct Known Subclasses:
AnyReader, ArrayReader, BeanReader, CollectionReader, EnumReader, MapReader, SimpleValueReader

public abstract class ValueReader extends Object
API and base class for all "deserializer" implementations used to actually read values of Java types from (JSON) input.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Class<?>
    Type of values this reader will read
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ValueReader(Class<?> valueType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    _tokenDesc(com.fasterxml.jackson.core.JsonParser p)
    Helper method for getting description of the token parser currently points to, for use in descriptions and exception messages.
    static String
    _tokenDesc(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.JsonToken t)
    Helper method for getting description of given token for use in descriptions and exception messages.
    protected String
    Helper method for getting description of type of values this reader produces from input: used for example in exception messages.
    abstract Object
    read(JSONReader reader, com.fasterxml.jackson.core.JsonParser p)
    Method called to deserialize value of type supported by this reader, using given parser.
    readNext(JSONReader reader, com.fasterxml.jackson.core.JsonParser p)
    Method called to deserialize value of type supported by this reader, using given parser.
    Accessor for non-generic (type-erased) type of values this reader produces from input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _valueType

      protected final Class<?> _valueType
      Type of values this reader will read
      Since:
      2.10
  • Constructor Details

    • ValueReader

      protected ValueReader(Class<?> valueType)
  • Method Details

    • read

      public abstract Object read(JSONReader reader, com.fasterxml.jackson.core.JsonParser p) throws IOException
      Method called to deserialize value of type supported by this reader, using given parser. Parser is already positioned to the (first) token of the value to read.
      Parameters:
      reader - Context object that allows calling other read methods for contained values of different types (for example for collection readers).
      p - Underlying parser used for reading decoded token stream
      Throws:
      IOException
    • readNext

      public Object readNext(JSONReader reader, com.fasterxml.jackson.core.JsonParser p) throws IOException
      Method called to deserialize value of type supported by this reader, using given parser. Parser is not yet positioned to the (first) token of the value to read and needs to be advanced.

      Default implementation simply calls `p.nextToken()` first, then calls {#link read(JSONReader, JsonParser), but some implementations may decide to implement this differently to use (slightly) more efficient accessors in JsonParser, like JsonParser.nextIntValue(int).

      Parameters:
      reader - Context object that allows calling other read methods for contained values of different types (for example for collection readers).
      p - Underlying parser used for reading decoded token stream
      Throws:
      IOException
    • valueType

      public Class<?> valueType()
      Accessor for non-generic (type-erased) type of values this reader produces from input.
      Since:
      2.10
    • _valueTypeDesc

      protected String _valueTypeDesc()
      Helper method for getting description of type of values this reader produces from input: used for example in exception messages.
      Since:
      2.20
    • _tokenDesc

      public static String _tokenDesc(com.fasterxml.jackson.core.JsonParser p) throws IOException
      Helper method for getting description of the token parser currently points to, for use in descriptions and exception messages.
      Throws:
      IOException
    • _tokenDesc

      public static String _tokenDesc(com.fasterxml.jackson.core.JsonParser p, com.fasterxml.jackson.core.JsonToken t) throws IOException
      Helper method for getting description of given token for use in descriptions and exception messages.
      Throws:
      IOException