com.fasterxml.jackson.databind.node

Class NumericNode

    • Constructor Detail

      • NumericNode

        protected NumericNode()
    • Method Detail

      • isNumber

        public final boolean isNumber()
        Overrides:
        isNumber in class JsonNode
        Returns:
        True if this node represents a numeric JSON value
      • numberType

        public abstract JsonParser.NumberType numberType()
        Description copied from class: BaseJsonNode
        Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.
        Specified by:
        numberType in interface TreeNode
        Overrides:
        numberType in class BaseJsonNode
        Returns:
        Type of number contained, if any; or null if node does not contain numeric value.
      • numberValue

        public abstract Number numberValue()
        Description copied from class: JsonNode
        Returns numeric value for this node, if and only if this node is numeric (JsonNode.isNumber() returns true); otherwise returns null
        Overrides:
        numberValue in class JsonNode
        Returns:
        Number value this node contains, if any (null for non-number nodes).
      • intValue

        public abstract int intValue()
        Description copied from class: JsonNode
        Returns integer value for this node, if and only if this node is numeric (JsonNode.isNumber() returns true). For other types returns 0. For floating-point numbers, value is truncated using default Java coercion, similar to how cast from double to int operates.
        Overrides:
        intValue in class JsonNode
        Returns:
        Integer value this node contains, if any; 0 for non-number nodes.
      • longValue

        public abstract long longValue()
        Overrides:
        longValue in class JsonNode
      • doubleValue

        public abstract double doubleValue()
        Overrides:
        doubleValue in class JsonNode
      • canConvertToInt

        public abstract boolean canConvertToInt()
        Description copied from class: JsonNode
        Method that can be used to check whether this node is a numeric node (JsonNode.isNumber() would return true) AND its value fits within Java's 32-bit signed integer type, int. Note that floating-point numbers are convertible if the integral part fits without overflow (as per standard Java coercion rules)
        Overrides:
        canConvertToInt in class JsonNode
      • canConvertToLong

        public abstract boolean canConvertToLong()
        Description copied from class: JsonNode
        Method that can be used to check whether this node is a numeric node (JsonNode.isNumber() would return true) AND its value fits within Java's 64-bit signed integer type, long. Note that floating-point numbers are convertible if the integral part fits without overflow (as per standard Java coercion rules)
        Overrides:
        canConvertToLong in class JsonNode
      • asText

        public abstract String asText()
        Description copied from class: JsonNode
        Method that will return a valid String representation of the container value, if the node is a value node (method JsonNode.isValueNode() returns true), otherwise empty String.
        Specified by:
        asText in class JsonNode
      • asInt

        public final int asInt()
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an int (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.

        Overrides:
        asInt in class JsonNode
      • asInt

        public final int asInt(int defaultValue)
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

        Overrides:
        asInt in class JsonNode
      • asLong

        public final long asLong()
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an long (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.

        Overrides:
        asLong in class JsonNode
      • asLong

        public final long asLong(long defaultValue)
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

        Overrides:
        asLong in class JsonNode
      • asDouble

        public final double asDouble()
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an int (including structured types like Objects and Arrays), default value of 0.0 will be returned; no exceptions are thrown.

        Overrides:
        asDouble in class JsonNode
      • asDouble

        public final double asDouble(double defaultValue)
        Description copied from class: JsonNode
        Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.

        If representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

        Overrides:
        asDouble in class JsonNode

Copyright © 2012 FasterXML. All Rights Reserved.