break; case DataType.LONG: tuple.set(i, DataType.toLong(object)); break; case DataType.BOOLEAN:
/** * Force a data object to a Long, if possible. Any numeric type * can be forced to a Long (though precision may be lost), as well * as CharArray, ByteArray, or Boolean. Complex types cannot be * forced to an Long. This isn't particularly efficient, so if you * already <b>know</b> that the object you have is a Long you * should just cast it. Unlike {@link #toLong(Object, byte)} this * method will first determine the type of o and then do the cast. * Use {@link #toLong(Object, byte)} if you already know the type. * @param o object to cast * @return The object as a Long. * @throws ExecException if the type can't be forced to an Long. */ public static Long toLong(Object o) throws ExecException { return toLong(o, findType(o)); }
public DateTime exec(Tuple input) throws IOException { if (input == null || input.size() < 1 || input.get(0) == null) { return null; } return new DateTime(DataType.toLong(input.get(0))); }
private TypedObject getTypedObject(Object data, FieldDetail detail) throws ExecException { if (data == null) { return null; } byte type = detail.type; switch (type) { case DataType.BOOLEAN: return TypeSystem.asTypedObject(DataType.toBoolean(data, type)); case DataType.INTEGER: case DataType.LONG: return TypeSystem.asTypedObject(DataType.toLong(data, type)); case DataType.FLOAT: case DataType.DOUBLE: return TypeSystem.asTypedObject(DataType.toDouble(data, type)); case DataType.DATETIME: return TypeSystem.asTypedObject(new Timestamp(DataType.toDateTime(data, type).getMillis())); case DataType.BYTE: case DataType.BYTEARRAY: case DataType.CHARARRAY: return TypeSystem.asTypedObject(DataType.toString(data, type)); case DataType.BIGINTEGER: case DataType.BIGDECIMAL: return TypeSystem.asTypedObject(DataType.toBigDecimal(data, type)); default: //TUPLE, BAG, MAP, INTERNALMAP, GENERIC_WRITABLECOMPARABLE, ERROR, UNKNOWN, NULL and anything else return null; } }
return DataType.toInteger(o); case DataType.LONG: return DataType.toLong(o); case DataType.DOUBLE: return DataType.toDouble(o);
break; case DataType.LONG: tuple.set(i, DataType.toLong(object)); break; case DataType.BOOLEAN: