protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors"); } return n; }
} else if (node.isTextual()) { return node.asText(); } else if (node.isNumber()) { if (node.isInt()) { return node.asInt();
case FLOAT: case DOUBLE: return defaultValue.isNumber(); case BOOLEAN: return defaultValue.isBoolean();
case FLOAT: case DOUBLE: if(!defaultJson.isNumber()) { expectedVal = "number";
if (fieldNode.isNumber()) { return fieldNode.getNumberValue();
if (fieldNode.isNumber()) { return fieldNode.getNumberValue();
break; case INT: if (!n.isNumber()) throw new AvroTypeException("Non-numeric default value for int: "+n); e.writeInt(n.getIntValue()); break; case LONG: if (!n.isNumber()) throw new AvroTypeException("Non-numeric default value for long: "+n); e.writeLong(n.getLongValue()); break; case FLOAT: if (!n.isNumber()) throw new AvroTypeException("Non-numeric default value for float: "+n); e.writeFloat((float) n.getDoubleValue()); break; case DOUBLE: if (!n.isNumber()) throw new AvroTypeException("Non-numeric default value for double: "+n); e.writeDouble(n.getDoubleValue());
protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors"); } return n; }
private Integer getIntegerField(final JsonNode pNode, final String pFieldName) { Preconditions.checkNotNull(pNode); Preconditions.checkNotNull(pFieldName); return pNode.get(pFieldName) != null && pNode.get(pFieldName).isNumber() ? pNode.get(pFieldName) .getIntValue() : null; }
private Integer getIntegerField(final JsonNode pNode, final String pFieldName) { Preconditions.checkNotNull(pNode); Preconditions.checkNotNull(pFieldName); return pNode.get(pFieldName) != null && pNode.get(pFieldName).isNumber() ? pNode.get(pFieldName) .getIntValue() : null; }
public static String getValueByType(JsonNode value){ if(value.isNumber()) return value.asText(); return "'"+value.asText()+"'"; } public static String mapKey(String key,Map<String,String> fieldsMap){
private boolean isNumber(final JsonNode node) { return !representsNull(node) && node.isValueNode() && node.isNumber(); }
private Byte getByte(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an byte"); if (!node.isNumber()) { // there is no node.isByte() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().byteValue(); }
private Float getFloat(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a float"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().floatValue(); }
private Short getShort(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "an short"); if (!node.isNumber()) { // there is no node.isShort() throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue().shortValue(); }
protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors"); } return n; }
private Object extractId(JsonNode idNode) { if (idNode == null) return null; if (idNode.isNumber()) return idNode.getNumberValue(); if (idNode.isTextual()) return idNode.getTextValue(); if (idNode.isNull()) return null; throw new IllegalArgumentException("Not a valid id type: " + idNode); } }
private Number getNumber(final String path, final JsonNode node) { if (representsNull(node)) { return null; } checkValue(path, node, "a number"); if (!node.isNumber()) { throw new IllegalArgumentException(formatExMsg(path, "is not a number")); } return node.getNumberValue(); }
protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors"); } return n; }
protected JsonNode currentNumericNode() throws JsonParseException { JsonNode n = currentNode(); if (n == null || !n.isNumber()) { JsonToken t = (n == null) ? null : n.asToken(); throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors"); } return n; }