return (D) Short.valueOf(jsonNode.shortValue());
return new ByteWritable((byte) value.intValue()); case SHORT: return (new ShortWritable(value.shortValue())); case INT: return new IntWritable(value.intValue());
@Override public Object parseJsonNode(JsonNode input, Schema schema) { Preconditions.checkState(input.isInt(), "'%s' is not a '%s'", input.textValue(), expectedClass().getSimpleName()); return input.shortValue(); } }
@Override public Object parseJsonNode(JsonNode input, Schema schema) { Object result; if (input.isNumber()) { result = input.shortValue(); } else if (input.isTextual()) { result = parseString(input.textValue(), schema); } else { throw new UnsupportedOperationException( String.format( "Could not parse '%s' to %s", input, this.expectedClass().getSimpleName() ) ); } return result; } }
@Override protected void decode(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame, List<Object> list) throws Exception { String text = textWebSocketFrame.text(); JsonNode root = jsonMapper.readTree(text); ProtocolModel protocolModel = new ProtocolModel(); if (root.has("version")) { protocolModel.setVersion(root.get("version").shortValue()); } if (root.has("commandId")) { protocolModel.setCommandId(root.get("commandId").asInt()); } if (root.has("seqId")) { protocolModel.setSeqId(root.get("seqId").asInt()); } if (root.has("shellId")) { protocolModel.setShellId(root.get("shellId").asLong()); } if (root.has("body")) { protocolModel.setBody(root.get("body").toString().getBytes()); } list.add(protocolModel); } }
Object o = id.shortValue(); return (T) o;
list.add(datum.asLong()); } else if (datum.isShort()) { list.add(datum.shortValue()); } else if (datum.isDouble()) { list.add(datum.asDouble());
list.add(datum.asLong()); } else if (datum.isShort()) { list.add(datum.shortValue()); } else if (datum.isDouble()) { list.add(datum.asDouble());
list.add(datum.asLong()); } else if (datum.isShort()) { list.add(datum.shortValue()); } else if (datum.isDouble()) { list.add(datum.asDouble());
public Object get(String key) { JsonNode node = map.get(key); if (node instanceof NullNode) { return null; } else if (node instanceof ShortNode) { return node.shortValue(); } else if (node instanceof IntNode) { return node.intValue(); } else if (node instanceof LongNode) { return node.longValue(); } else if (node instanceof FloatNode) { return node.floatValue(); } else if (node instanceof DoubleNode) { return node.doubleValue(); } else if (node instanceof TextNode) { return node.textValue(); } else if (node instanceof BooleanNode) { return node.booleanValue(); }else{ return node.asText(); } } }
/** * Unwraps a JSON node as an object. */ @Nullable static Object unwrap(@Nullable JsonNode node) { if (node == null) { return null; } else if (node.isArray()) { return StreamSupport.stream(node.spliterator(), false) .map(JsonUtil::unwrap).collect(Collectors.toList()); } else if (node.isBoolean()) { return node.booleanValue(); } else if (node.isDouble()) { return node.doubleValue(); } else if (node.isFloat()) { return node.floatValue(); } else if (node.isShort()) { return node.shortValue(); } else if (node.isInt()) { return node.intValue(); } else if (node.isLong()) { return node.longValue(); } else if (node.isTextual()) { return node.asText(); } else if (node.isNull()) { return null; } else { return node; } }
record.put(fieldName, datum.asLong()); } else if (datum.isShort()) { record.put(fieldName, datum.shortValue()); } else if (datum.isDouble()) { record.put(fieldName, datum.asDouble());
record.put(fieldName, datum.asLong()); } else if (datum.isShort()) { record.put(fieldName, datum.shortValue()); } else if (datum.isDouble()) { record.put(fieldName, datum.asDouble());
record.put(fieldName, datum.asLong()); } else if (datum.isShort()) { record.put(fieldName, datum.shortValue()); } else if (datum.isDouble()) { record.put(fieldName, datum.asDouble());
return new ByteWritable((byte) value.intValue()); case SHORT: return (new ShortWritable(value.shortValue())); case INT: return new IntWritable(value.intValue());
@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; } }
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(); } }