Enum StreamReadCapability

  • All Implemented Interfaces:
    JacksonFeature, java.io.Serializable, java.lang.Comparable<StreamReadCapability>

    public enum StreamReadCapability
    extends java.lang.Enum<StreamReadCapability>
    implements JacksonFeature
    Set of on/off capabilities that a JsonParser for given format (or in case of buffering, original format) has. Used in some cases to adjust aspects of things like content conversions, coercions and validation by format-agnostic functionality. Specific or expected usage documented by individual capability entry Javadocs.
    Since:
    2.12
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      DUPLICATE_PROPERTIES
      Capability that indicates that data format can expose multiple properties with same name ("duplicates") within one Object context.
      EXACT_FLOATS
      Capability that indicates whether data format supports reporting of accurate floating point values (with respect to reported numeric type, JsonParser.NumberType.DOUBLE) or not.
      SCALARS_AS_OBJECTS
      Capability that indicates that data format may in some cases expose Scalar values (whether typed or untyped) as Object values.
      UNTYPED_SCALARS
      Capability that indicates that data format only exposed "untyped" scalars: that is, instead of Number, Boolean and String types all scalar values are reported as text (JsonToken.VALUE_STRING) unless some sort of coercion is implied by caller.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean enabledByDefault()
      Accessor for checking whether this feature is enabled by default.
      boolean enabledIn​(int flags)
      Convenience method for checking whether feature is enabled in given bitmask.
      int getMask()
      Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.
      static StreamReadCapability valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static StreamReadCapability[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • DUPLICATE_PROPERTIES

        public static final StreamReadCapability DUPLICATE_PROPERTIES
        Capability that indicates that data format can expose multiple properties with same name ("duplicates") within one Object context. This is usually not enabled, except for formats like xml that have content model that does not map cleanly to JSON-based token stream.

        Capability may be used for allowing secondary mapping of such duplicates in case of using Tree Model (see TreeNode), or "untyped" databinding (mapping content as generic Object).

        Capability is currently only enabled for XML format backend.

      • SCALARS_AS_OBJECTS

        public static final StreamReadCapability SCALARS_AS_OBJECTS
        Capability that indicates that data format may in some cases expose Scalar values (whether typed or untyped) as Object values. There are additional access methods at databind level: this capability may be used to decide whether to attempt to use such methods especially in potentially ambiguous cases.

        Capability is currently only enabled for XML format backend.

      • UNTYPED_SCALARS

        public static final StreamReadCapability UNTYPED_SCALARS
        Capability that indicates that data format only exposed "untyped" scalars: that is, instead of Number, Boolean and String types all scalar values are reported as text (JsonToken.VALUE_STRING) unless some sort of coercion is implied by caller.

        This capability is true for many textual formats like CSV, Properties and XML.

      • EXACT_FLOATS

        public static final StreamReadCapability EXACT_FLOATS
        Capability that indicates whether data format supports reporting of accurate floating point values (with respect to reported numeric type, JsonParser.NumberType.DOUBLE) or not. This usually depends on whether format stores such values natively (as IEEE binary FP formats for java.lang.Float and java.lang.Double; using some other value preserving presentation for java.math.BigDecimal) or not: most binary formats do, and most textual formats do not (at least for Float and Double, specifically).

        In case of JSON numbers (as well as for most if not all textual formats), all floating-point numbers are represented simply by decimal (10-base) textual representation and can only be represented accurately using BigDecimal. But for performance reasons they may be (depending on settings) be exposed as Doubles (that is, JsonParser.NumberType.DOUBLE). Note that methods like JsonParser.getNumberValueExact(), JsonParser.getValueAsString() and JsonParser.getDecimalValue() report values without precision loss.

        The main intended use case is to let non-Jackson code to handle cases where exact accuracy is necessary in a way that handling does not incur unnecessary conversions across different formats: for example, when reading binary format, simple access is essentially guaranteed to expose value exactly as encoded by the format (as float, double or BigDecimal), whereas for textual formats like JSON it is necessary to access value explicitly as BigDecimal using JsonParser#getDecimalValue.

        Capability is false for text formats like JSON, but true for binary formats like Smile, MessagePack, etc., where type is precisely and inexpensively indicated by format.

        Since:
        2.14
    • Method Detail

      • values

        public static StreamReadCapability[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (StreamReadCapability c : StreamReadCapability.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static StreamReadCapability valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • enabledByDefault

        public boolean enabledByDefault()
        Description copied from interface: JacksonFeature
        Accessor for checking whether this feature is enabled by default.
        Specified by:
        enabledByDefault in interface JacksonFeature
        Returns:
        Whether this instance is enabled by default or not
      • enabledIn

        public boolean enabledIn​(int flags)
        Description copied from interface: JacksonFeature
        Convenience method for checking whether feature is enabled in given bitmask.
        Specified by:
        enabledIn in interface JacksonFeature
        Parameters:
        flags - Bit field that contains a set of enabled features of this type
        Returns:
        True if this feature is enabled in passed bit field
      • getMask

        public int getMask()
        Description copied from interface: JacksonFeature
        Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.
        Specified by:
        getMask in interface JacksonFeature
        Returns:
        Bit mask of this feature