com.fasterxml.jackson.databind.JsonNode.isBigInteger()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isBigInteger()方法的一些代码示例,展示了JsonNode.isBigInteger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isBigInteger()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isBigInteger

JsonNode.isBigInteger介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Override
public long getLong()
{
  try {
    long longValue;
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      longValue = value.longValue();
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
    else if (value.isValueNode()) {
      longValue = parseLong(value.asText());
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
  }
  catch (NumberFormatException ignore) {
    // ignore
  }
  throw new PrestoException(
      DECODER_CONVERSION_NOT_SUPPORTED,
      format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
}

代码示例来源:origin: prestodb/presto

@Override
  protected long getMillis()
  {
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      return value.longValue();
    }
    if (value.isValueNode()) {
      try {
        return parseLong(value.asText());
      }
      catch (NumberFormatException e) {
        throw new PrestoException(
            DECODER_CONVERSION_NOT_SUPPORTED,
            format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
      }
    }
    throw new PrestoException(
        DECODER_CONVERSION_NOT_SUPPORTED,
        format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
  }
}

代码示例来源:origin: prestodb/presto

@Override
  protected long getMillis()
  {
    try {
      if (value.isIntegralNumber()
          && !value.isBigInteger()) {
        return multiplyExact(value.longValue(), 1000);
      }
      if (value.isValueNode()) {
        return multiplyExact(parseLong(value.asText()), 1000);
      }
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
    }
    catch (NumberFormatException | ArithmeticException e) {
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
    }
  }
}

代码示例来源:origin: apache/usergrid

if ( json.isBigInteger() ) {
  return json.asInt();

代码示例来源:origin: apache/usergrid

if ( json.isBigInteger() ) {
  return json.asInt();

代码示例来源:origin: org.walkmod/walkmod-core

public Map<String, Object> getParams(JsonNode next) {
  if (next.has("params")) {
    Iterator<Entry<String, JsonNode>> it2 = next.get("params").fields();
    Map<String, Object> params = new HashMap<String, Object>();
    while (it2.hasNext()) {
      Entry<String, JsonNode> param = it2.next();
      JsonNode value = param.getValue();
      if (value.isTextual()) {
        params.put(param.getKey(), value.asText());
      } else if (value.isInt()) {
        params.put(param.getKey(), value.asInt());
      } else if (value.isBoolean()) {
        params.put(param.getKey(), value.asBoolean());
      } else if (value.isDouble() || value.isFloat() || value.isBigDecimal()) {
        params.put(param.getKey(), value.asDouble());
      } else if (value.isLong() || value.isBigInteger()) {
        params.put(param.getKey(), value.asLong());
      } else {
        params.put(param.getKey(), value);
      }
      params.put(param.getKey(), param.getValue().asText());
    }
    return params;
  }
  return null;
}

代码示例来源:origin: walkmod/walkmod-core

public Map<String, Object> getParams(JsonNode next) {
  if (next.has("params")) {
    Iterator<Entry<String, JsonNode>> it2 = next.get("params").fields();
    Map<String, Object> params = new HashMap<String, Object>();
    while (it2.hasNext()) {
      Entry<String, JsonNode> param = it2.next();
      JsonNode value = param.getValue();
      if (value.isTextual()) {
        params.put(param.getKey(), value.asText());
      } else if (value.isInt()) {
        params.put(param.getKey(), value.asInt());
      } else if (value.isBoolean()) {
        params.put(param.getKey(), value.asBoolean());
      } else if (value.isDouble() || value.isFloat() || value.isBigDecimal()) {
        params.put(param.getKey(), value.asDouble());
      } else if (value.isLong() || value.isBigInteger()) {
        params.put(param.getKey(), value.asLong());
      } else {
        params.put(param.getKey(), value);
      }
      params.put(param.getKey(), param.getValue().asText());
    }
    return params;
  }
  return null;
}

代码示例来源:origin: io.prestosql/presto-record-decoder

@Override
public long getLong()
{
  try {
    long longValue;
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      longValue = value.longValue();
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
    else if (value.isValueNode()) {
      longValue = parseLong(value.asText());
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
  }
  catch (NumberFormatException ignore) {
    // ignore
  }
  throw new PrestoException(
      DECODER_CONVERSION_NOT_SUPPORTED,
      format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
}

代码示例来源:origin: com.facebook.presto/presto-record-decoder

@Override
public long getLong()
{
  try {
    long longValue;
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      longValue = value.longValue();
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
    else if (value.isValueNode()) {
      longValue = parseLong(value.asText());
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
  }
  catch (NumberFormatException ignore) {
    // ignore
  }
  throw new PrestoException(
      DECODER_CONVERSION_NOT_SUPPORTED,
      format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
}

代码示例来源:origin: prestosql/presto

@Override
public long getLong()
{
  try {
    long longValue;
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      longValue = value.longValue();
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
    else if (value.isValueNode()) {
      longValue = parseLong(value.asText());
      if (longValue >= minValue && longValue <= maxValue) {
        return longValue;
      }
    }
  }
  catch (NumberFormatException ignore) {
    // ignore
  }
  throw new PrestoException(
      DECODER_CONVERSION_NOT_SUPPORTED,
      format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
}

代码示例来源:origin: io.prestosql/presto-record-decoder

@Override
  protected long getMillis()
  {
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      return value.longValue();
    }
    if (value.isValueNode()) {
      try {
        return parseLong(value.asText());
      }
      catch (NumberFormatException e) {
        throw new PrestoException(
            DECODER_CONVERSION_NOT_SUPPORTED,
            format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
      }
    }
    throw new PrestoException(
        DECODER_CONVERSION_NOT_SUPPORTED,
        format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
  }
}

代码示例来源:origin: com.facebook.presto/presto-record-decoder

@Override
  protected long getMillis()
  {
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      return value.longValue();
    }
    if (value.isValueNode()) {
      try {
        return parseLong(value.asText());
      }
      catch (NumberFormatException e) {
        throw new PrestoException(
            DECODER_CONVERSION_NOT_SUPPORTED,
            format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
      }
    }
    throw new PrestoException(
        DECODER_CONVERSION_NOT_SUPPORTED,
        format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
  }
}

代码示例来源:origin: prestosql/presto

@Override
  protected long getMillis()
  {
    if (value.isIntegralNumber() && !value.isBigInteger()) {
      return value.longValue();
    }
    if (value.isValueNode()) {
      try {
        return parseLong(value.asText());
      }
      catch (NumberFormatException e) {
        throw new PrestoException(
            DECODER_CONVERSION_NOT_SUPPORTED,
            format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
      }
    }
    throw new PrestoException(
        DECODER_CONVERSION_NOT_SUPPORTED,
        format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
  }
}

代码示例来源:origin: io.prestosql/presto-record-decoder

@Override
  protected long getMillis()
  {
    try {
      if (value.isIntegralNumber()
          && !value.isBigInteger()) {
        return multiplyExact(value.longValue(), 1000);
      }
      if (value.isValueNode()) {
        return multiplyExact(parseLong(value.asText()), 1000);
      }
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
    }
    catch (NumberFormatException | ArithmeticException e) {
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
    }
  }
}

代码示例来源:origin: prestosql/presto

@Override
  protected long getMillis()
  {
    try {
      if (value.isIntegralNumber()
          && !value.isBigInteger()) {
        return multiplyExact(value.longValue(), 1000);
      }
      if (value.isValueNode()) {
        return multiplyExact(parseLong(value.asText()), 1000);
      }
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
    }
    catch (NumberFormatException | ArithmeticException e) {
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
    }
  }
}

代码示例来源:origin: com.facebook.presto/presto-record-decoder

@Override
  protected long getMillis()
  {
    try {
      if (value.isIntegralNumber()
          && !value.isBigInteger()) {
        return multiplyExact(value.longValue(), 1000);
      }
      if (value.isValueNode()) {
        return multiplyExact(parseLong(value.asText()), 1000);
      }
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse non-value node as '%s' for column '%s'", columnHandle.getType(), columnHandle.getName()));
    }
    catch (NumberFormatException | ArithmeticException e) {
      throw new PrestoException(
          DECODER_CONVERSION_NOT_SUPPORTED,
          format("could not parse value '%s' as '%s' for column '%s'", value.asText(), columnHandle.getType(), columnHandle.getName()));
    }
  }
}

代码示例来源:origin: liveoak-io/liveoak

private RelationalOperand parseRelationalOperand(JsonNode node) {
  Object value;
  if (node.isTextual()) {
    value = node.textValue();
  } else if (node.isBoolean()) {
    value = node.booleanValue();
  } else if (node.isInt()) {
    value = node.intValue();
  } else if (node.isLong()) {
    value = node.longValue();
  } else if (node.isBigInteger()) {
    value = node.bigIntegerValue();
  } else if (node.isFloat()) {
    value = node.floatValue();
  } else if (node.isDouble()) {
    value = node.doubleValue();
  } else if (node.isBigDecimal()) {
    value = node.decimalValue();
  } else if (node.isNull()) {
    value = null;
  } else {
    throw new IllegalArgumentException("Unexpected value of: " + node);
  }
  return new Value(value);
}

代码示例来源:origin: com.cloudera.cdk/cdk-morphlines-json

} else if (datum.isFloat()) {
 record.put(fieldName, datum.floatValue());
} else if (datum.isBigInteger()) {
 record.put(fieldName, datum.bigIntegerValue());
} else if (datum.isBigDecimal()) {

代码示例来源:origin: com.reprezen.jsonoverlay/jsonoverlay

@Override
protected Number _fromJson(JsonNode json) {
  if (json.isBigDecimal()) {
    return json.decimalValue();
  } else if (json.isBigInteger()) {
    return json.bigIntegerValue();
  }
  // no methods for Byte, even though numberNode(Byte) is provided.
  // experimentations shows that bytes show up as ints. Oh well..
  else if (json.isDouble()) {
    return json.doubleValue();
  } else if (json.isFloat()) {
    return json.floatValue();
  } else if (json.isInt()) {
    return json.intValue();
  } else if (json.isLong()) {
    return json.longValue();
  } else if (json.isShort()) {
    return json.shortValue();
  } else {
    return null;
  }
}

代码示例来源:origin: io.atlasmap/atlas-json-core

private Object handleNumberNode(JsonNode valueNode, JsonField jsonField) {
  if (valueNode.isInt()) {
    jsonField.setFieldType(FieldType.INTEGER);
    return valueNode.intValue();
  } else if (valueNode.isDouble()) {
    jsonField.setFieldType(FieldType.DOUBLE);
    return valueNode.doubleValue();
  } else if (valueNode.isBigDecimal()) {
    jsonField.setFieldType(FieldType.DECIMAL);
    return valueNode.decimalValue();
  } else if (valueNode.isFloat()) {
    jsonField.setFieldType(FieldType.DOUBLE);
    return valueNode.floatValue();
  } else if (valueNode.isLong()) {
    jsonField.setFieldType(FieldType.LONG);
    return valueNode.longValue();
  } else if (valueNode.isShort()) {
    jsonField.setFieldType(FieldType.SHORT);
    return valueNode.shortValue();
  } else if (valueNode.isBigInteger()) {
    jsonField.setFieldType(FieldType.BIG_INTEGER);
    return valueNode.bigIntegerValue();
  } else {
    jsonField.setFieldType(FieldType.NUMBER);
    return valueNode.numberValue();
  }
}

相关文章