本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.TYPE_BIGNUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.TYPE_BIGNUMBER属性的具体用法?Java ValueMetaInterface.TYPE_BIGNUMBER怎么用?Java ValueMetaInterface.TYPE_BIGNUMBER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.TYPE_BIGNUMBER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCQLTypeForValueMeta
/**
* Return the Cassandra CQL column/key type for the given Kettle column. We
* use this type for CQL create column family statements since, for some
* reason, the internal type isn't recognized for the key. Internal types
* *are* recognized for column definitions. The CQL reference guide states
* that fully qualified (or relative to org.apache.cassandra.db.marshal) class
* names can be used instead of CQL types - however, using these when defining
* the key type always results in BytesType getting set for the key for some
* reason.
*
* @param vm the ValueMetaInterface for the Kettle column
* @return the corresponding CQL type
*/
public static String getCQLTypeForValueMeta(ValueMetaInterface vm) {
switch (vm.getType()) {
case ValueMetaInterface.TYPE_STRING:
return "varchar";
case ValueMetaInterface.TYPE_BIGNUMBER:
return "decimal";
case ValueMetaInterface.TYPE_BOOLEAN:
return "boolean";
case ValueMetaInterface.TYPE_INTEGER:
return "bigint";
case ValueMetaInterface.TYPE_NUMBER:
return "double";
case ValueMetaInterface.TYPE_DATE:
return "timestamp";
case ValueMetaInterface.TYPE_BINARY:
case ValueMetaInterface.TYPE_SERIALIZABLE:
return "blob";
}
return "blob";
}
示例2: convertDataType
public static int convertDataType(DataType type) {
switch (type.getName()) {
case SMALLINT:
case INT:
case BIGINT:
case COUNTER:
case TIME:
return ValueMetaInterface.TYPE_INTEGER; // 5 > java.lang.Long
case ASCII:
case TEXT:
case VARCHAR:
case UUID:
case TIMEUUID:
return ValueMetaInterface.TYPE_STRING; // 2 > java.lang.String
case INET:
return ValueMetaInterface.TYPE_INET; // 10 >
case BOOLEAN:
return ValueMetaInterface.TYPE_BOOLEAN; // 4 > java.lang.Boolean
case DECIMAL:
case FLOAT:
case DOUBLE:
return ValueMetaInterface.TYPE_NUMBER; // 1 > java.lang.Double
case VARINT:
return ValueMetaInterface.TYPE_BIGNUMBER; // 6 > java.math.BigDecimal
case TIMESTAMP:
return ValueMetaInterface.TYPE_DATE; // 3 > java.util.Date
case BLOB:
return ValueMetaInterface.TYPE_BINARY; // 8 > java.lang.byte[]
case LIST:
case MAP:
case SET:
return ValueMetaInterface.TYPE_SERIALIZABLE; // 0
default:
return ValueMetaInterface.TYPE_STRING;
}
}
示例3: setEntryValue
private void setEntryValue(StepInjectionMetaEntry entry, RowMetaAndData row, SourceStepField source) throws KettleValueException {
// A standard attribute, a single row of data...
//
Object value = null;
switch(entry.getValueType()) {
case ValueMetaInterface.TYPE_STRING: value = row.getString(source.getField(), null); break;
case ValueMetaInterface.TYPE_BOOLEAN: value = row.getBoolean(source.getField(), false); break;
case ValueMetaInterface.TYPE_INTEGER: value = row.getInteger(source.getField(), 0L); break;
case ValueMetaInterface.TYPE_NUMBER: value = row.getNumber(source.getField(), 0.0D); break;
case ValueMetaInterface.TYPE_DATE: value = row.getDate(source.getField(), null); break;
case ValueMetaInterface.TYPE_BIGNUMBER: value = row.getBigNumber(source.getField(), null); break;
}
entry.setValue(value);
}
示例4: getFieldDefinition
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr)
{
String retval="";
String fieldname = v.getName();
int length = v.getLength();
// Unused in vertica
//int precision = v.getPrecision();
if (add_fieldname) retval+=fieldname+" ";
int type = v.getType();
switch(type)
{
case ValueMetaInterface.TYPE_DATE : retval+="TIMESTAMP"; break;
case ValueMetaInterface.TYPE_BOOLEAN: retval+="BOOLEAN"; break;
case ValueMetaInterface.TYPE_NUMBER :
case ValueMetaInterface.TYPE_BIGNUMBER:
retval+="FLOAT";
break;
case ValueMetaInterface.TYPE_INTEGER:
retval+="INTEGER";
break;
case ValueMetaInterface.TYPE_STRING:
retval+="VARCHAR("+length+")";
break;
default:
retval+=" UNKNOWN";
break;
}
if (add_cr) retval+=Const.CR;
return retval;
}
示例5: getPrimitive
public static Object getPrimitive(ValueMetaInterface valueMeta, Object valueData) throws KettleValueException
{
switch(valueMeta.getType())
{
case ValueMetaInterface.TYPE_BIGNUMBER: return valueMeta.getBigNumber(valueData);
case ValueMetaInterface.TYPE_BINARY: return valueMeta.getBinary(valueData);
case ValueMetaInterface.TYPE_BOOLEAN: return valueMeta.getBoolean(valueData);
case ValueMetaInterface.TYPE_DATE: return valueMeta.getDate(valueData);
case ValueMetaInterface.TYPE_INTEGER: valueMeta.getInteger(valueData);
case ValueMetaInterface.TYPE_NUMBER: return valueMeta.getNumber(valueData);
// case ValueMetaInterface.TYPE_SERIALIZABLE: return valueMeta.(valueData);
case ValueMetaInterface.TYPE_STRING: return valueMeta.getString(valueData);
default: return null;
}
}
示例6: generateRandomRows
/**
* Generate some random rows to send to python in the case where a single variable (data frame) is being extracted
* and we want to try and determine the types of the output fields
*
* @param inputMeta incoming row meta
* @param r Random instance to use
* @return a list of randomly generated rows with types matching the incoming row types.
* @throws KettleException if a problem occurs
*/
protected static List<Object[]> generateRandomRows( RowMetaInterface inputMeta, Random r ) throws KettleException {
List<Object[]> rows = new ArrayList<Object[]>( NUM_RANDOM_ROWS );
// ValueMetaInterface numericVM = new ValueMeta( "num", ValueMetaInterface.TYPE_NUMBER ); //$NON-NLS-1$
ValueMetaInterface numericVM = ValueMetaFactory.createValueMeta( "num", ValueMetaInterface.TYPE_NUMBER ); //$NON-NLS-1$
for ( int i = 0; i < NUM_RANDOM_ROWS; i++ ) {
Object[] currentRow = new Object[inputMeta.size()];
for ( int j = 0; j < inputMeta.size(); j++ ) {
ValueMetaInterface vm = inputMeta.getValueMeta( j );
ValueMetaInterface tempVM = vm.clone();
tempVM.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL );
Object newVal;
double d = r.nextDouble();
switch ( vm.getType() ) {
case ValueMetaInterface.TYPE_NUMBER:
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
d *= 100.0;
newVal = d;
if ( vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ) {
newVal = tempVM.convertData( numericVM, newVal );
}
currentRow[j] =
vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? vm.convertData( numericVM, newVal ) :
tempVM.convertToBinaryStringStorageType( newVal );
break;
case ValueMetaInterface.TYPE_DATE:
newVal = new Date( new Date().getTime() + (long) ( d * 100000 ) );
currentRow[j] =
vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? newVal :
tempVM.convertToBinaryStringStorageType( newVal );
break;
case ValueMetaInterface.TYPE_TIMESTAMP:
newVal = new Timestamp( new Date().getTime() + (long) ( d * 100000 ) );
currentRow[j] =
vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? newVal :
tempVM.convertToBinaryStringStorageType( newVal );
break;
case ValueMetaInterface.TYPE_BOOLEAN:
newVal = r.nextBoolean();
currentRow[j] =
vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? newVal :
tempVM.convertToBinaryStringStorageType( newVal );
break;
default:
newVal = d < 0.5 ? "value1" : "value2";
currentRow[j] =
vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_NORMAL ? newVal :
tempVM.convertToBinaryStringStorageType( newVal );
}
}
rows.add( currentRow );
}
return rows;
}
示例7: rowsToCSV
protected static StringBuilder rowsToCSV( RowMetaInterface meta, List<Object[]> rows ) throws KettleValueException {
StringBuilder builder = new StringBuilder();
// header row
int i = 0;
for ( ValueMetaInterface v : meta.getValueMetaList() ) {
String name = quote( v.getName() );
builder.append( i > 0 ? "," : "" ).append( name );
i++;
}
builder.append( "\n" );
for ( Object[] row : rows ) {
for ( i = 0; i < meta.size(); i++ ) {
String value;
ValueMetaInterface vm = meta.getValueMeta( i );
if ( row[i] == null || Const.isEmpty( vm.getString( row[i] ) ) ) {
value = "?";
} else {
//switch ( meta.getValueMetaList().get( i ).getType() ) {
switch ( vm.getType() ) {
case ValueMetaInterface.TYPE_NUMBER:
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
value = vm.getString( row[i] );
break;
case ValueMetaInterface.TYPE_DATE:
int offset = TZ.getOffset( vm.getDate( row[i] ).getTime() );
value = "" + ( vm.getDate( row[i] ).getTime() + offset );
break;
case ValueMetaInterface.TYPE_TIMESTAMP:
offset = TZ.getOffset( vm.getDate( row[i] ).getTime() );
value = "" + ( vm.getDate( row[i] ).getTime() + offset );
break;
case ValueMetaInterface.TYPE_BOOLEAN:
value = "" + ( vm.getBoolean( row[i] ) ? "1" : "0" );
break;
// TODO throw an exception for Serializable/Binary
default:
value = quote( vm.getString( row[i] ) );
}
}
builder.append( i > 0 ? "," : "" ).append( value );
}
builder.append( "\n" );
}
return builder;
}
示例8: setFormats
protected void setFormats() {
// What is the selected type?
//
// The index must be set on the combobox after
// calling setItems(), otherwise the zeroth element
// is displayed, but the selectedIndex will be -1.
int formatIndex = wFormat.getSelectionIndex();
String formatString = formatIndex >= 0 ? wFormat.getItem(formatIndex) : "";
int type = ValueMeta.getType(wValueType.getText());
String string = wInputString.getText();
// remove white spaces if not a string field
if ((type != ValueMetaInterface.TYPE_STRING) && (string.startsWith(" ") || string.endsWith(" "))) {
string = Const.trim(string);
wInputString.setText(string);
}
switch (type) {
case ValueMetaInterface.TYPE_INTEGER:
wFormat.setItems(Const.getNumberFormats());
int index = (!Const.isEmpty(formatString)) ? wFormat.indexOf(formatString) : wFormat.indexOf("#"); // default;
// ... then we have a custom format mask
if ((!Const.isEmpty(formatString)) && (index < 0)){
wFormat.add(formatString);
index = wFormat.indexOf(formatString);
}
wFormat.select(index); //default
break;
case ValueMetaInterface.TYPE_NUMBER:
wFormat.setItems(Const.getNumberFormats());
index = (!Const.isEmpty(formatString)) ? wFormat.indexOf(formatString) : wFormat.indexOf("#.#"); // default;
// ... then we have a custom format mask
if ((!Const.isEmpty(formatString)) && (index < 0)){
wFormat.add(formatString);
index = wFormat.indexOf(formatString);
}
wFormat.select(index); //default
break;
case ValueMetaInterface.TYPE_DATE:
wFormat.setItems(Const.getDateFormats());
index = (!Const.isEmpty(formatString)) ? wFormat.indexOf(formatString) : wFormat.indexOf("yyyy/MM/dd HH:mm:ss"); // default;
// ... then we have a custom format mask
if ((!Const.isEmpty(formatString)) && (index < 0)){
wFormat.add(formatString);
index = wFormat.indexOf(formatString);
}
wFormat.select(index); //default
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
wFormat.setItems(new String[] {});
break;
default:
wFormat.setItems(new String[] {});
break;
}
}
示例9: getFieldDefinition
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr)
{
String retval="";
String fieldname = v.getName();
int length = v.getLength();
int precision = v.getPrecision();
if (add_fieldname) retval+=fieldname+" ";
int type = v.getType();
switch(type)
{
case ValueMetaInterface.TYPE_DATE : retval+="DATE"; break;
case ValueMetaInterface.TYPE_BOOLEAN: retval+="CHAR(1)"; break;
case ValueMetaInterface.TYPE_NUMBER :
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
if (fieldname.equalsIgnoreCase(tk) || // Technical key
fieldname.equalsIgnoreCase(pk) // Primary key
)
{
retval+="INTEGER";
}
else
{
if (length>0)
{
if (precision>0 || length>18)
{
retval+="DECIMAL("+length+", "+precision+")";
}
else
{
retval+="INTEGER";
}
}
else
{
retval+="DOUBLE PRECISION";
}
}
break;
case ValueMetaInterface.TYPE_STRING:
if (length>=MAX_VARCHAR_LENGTH || length<=0)
{
retval+="VARCHAR("+MAX_VARCHAR_LENGTH+")";
}
else
{
retval+="VARCHAR("+length+")";
}
break;
default:
retval+=" UNKNOWN";
break;
}
if (add_cr) retval+=Const.CR;
return retval;
}
示例10: getFieldDefinition
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr) {
StringBuffer retval = new StringBuffer(128);
String fieldname = v.getName();
int length = v.getLength();
int precision = v.getPrecision();
if (add_fieldname)
retval.append(fieldname).append(' ');
int type = v.getType();
switch (type) {
case ValueMetaInterface.TYPE_DATE:
retval.append("TIMESTAMP");
break;
case ValueMetaInterface.TYPE_BOOLEAN:
retval.append("BOOLEAN");
break;
case ValueMetaInterface.TYPE_NUMBER:
case ValueMetaInterface.TYPE_BIGNUMBER:
retval.append("DECIMAL");
if (length > 0) {
retval.append('(').append(length);
if (precision > 0) {
retval.append(", ").append(precision);
}
retval.append(')');
}
break;
case ValueMetaInterface.TYPE_INTEGER:
if (fieldname.equalsIgnoreCase(tk) || // Technical key
fieldname.equalsIgnoreCase(pk) // Primary key
) {
// As soon as Exasol supports returning auto inc keys, this would be the correct type
// if (use_autoinc) {
// retval.append("BIGINT IDENTITY NOT NULL PRIMARY KEY");
// } else {
retval.append("BIGINT NOT NULL PRIMARY KEY");
// }
}
else {
retval.append("INTEGER");
}
break;
case ValueMetaInterface.TYPE_STRING:
if (length > 0 && length <= 2000000) {
retval.append("VARCHAR(").append(length).append(')');
} else {
retval.append("VARCHAR(2000000)"); // We don't know, so we just
// use the maximum...
}
break;
default:
retval.append("UNKNOWN");
break;
}
if (add_cr)
retval.append(Const.CR);
return retval.toString();
}
示例11: getValueMetaForColumn
/**
* Get the Kettle ValueMeta that corresponds to the type of the supplied
* cassandra column.
*
* @param colName the name of the column to get a ValueMeta for
* @return the ValueMeta that is appropriate for the type of the supplied
* column.
*/
public ValueMetaInterface getValueMetaForColumn(String colName) {
String type = null;
// check the key first
if (colName.equals(getKeyName())) {
type = m_keyValidator;
} else {
type = m_columnMeta.get(colName);
if (type == null) {
type = m_defaultValidationClass;
}
}
int kettleType = 0;
if (type.indexOf("UTF8Type") > 0 || type.indexOf("AsciiType") > 0
|| type.indexOf("UUIDType") > 0 || type.indexOf("CompositeType") > 0) {
kettleType = ValueMetaInterface.TYPE_STRING;
} else if (type.indexOf("LongType") > 0 || type.indexOf("IntegerType") > 0
|| type.indexOf("Int32Type") > 0) {
kettleType = ValueMetaInterface.TYPE_INTEGER;
} else if (type.indexOf("DoubleType") > 0 || type.indexOf("FloatType") > 0) {
kettleType = ValueMetaInterface.TYPE_NUMBER;
} else if (type.indexOf("DateType") > 0) {
kettleType = ValueMetaInterface.TYPE_DATE;
} else if (type.indexOf("DecimalType") > 0) {
kettleType = ValueMetaInterface.TYPE_BIGNUMBER;
} else if (type.indexOf("BytesType") > 0) {
kettleType = ValueMetaInterface.TYPE_BINARY;
} else if (type.indexOf("BooleanType") > 0) {
kettleType = ValueMetaInterface.TYPE_BOOLEAN;
}
ValueMetaInterface newVM = new ValueMeta(colName, kettleType);
if (m_indexedVals.containsKey(colName)) {
// make it indexed!
newVM.setStorageType(ValueMetaInterface.STORAGE_TYPE_INDEXED);
HashSet<Object> indexedV = m_indexedVals.get(colName);
Object[] iv = indexedV.toArray();
newVM.setIndex(iv);
}
return newVM;
}
示例12: createObjectsForRow
public static Object[] createObjectsForRow(RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException
{
Object[] values = new Object[rowMeta.size()];
for (int i=0;i<rowMeta.size();i++)
{
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
Object valueData = rowData[i];
int length = valueMeta.getLength();
switch(valueMeta.getType())
{
case ValueMetaInterface.TYPE_INTEGER:
if (length<3)
{
values[i] = new Byte( valueMeta.getInteger(valueData).byteValue() );
}
else
{
if (length<5)
{
values[i] = new Short(valueMeta.getInteger(valueData).shortValue());
}
else
{
values[i] = valueMeta.getInteger(valueData);
}
}
break;
case ValueMetaInterface.TYPE_NUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
case ValueMetaInterface.TYPE_DATE:
values[i] = valueMeta.getDate(valueData);
break;
case ValueMetaInterface.TYPE_STRING:
values[i] = valueMeta.getString(valueData);
break;
case ValueMetaInterface.TYPE_BINARY:
values[i] = valueMeta.getBinary(valueData);
break;
case ValueMetaInterface.TYPE_BOOLEAN:
values[i] = valueMeta.getBoolean(valueData);
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
values[i] = valueMeta.getNumber(valueData);
break;
default: break;
}
}
return values;
}
示例13: writeRowToBulk
private void writeRowToBulk(RowMetaInterface rowMeta, Object[] r) throws KettleException {
try {
for (int i=0;i<data.keynrs.length;i++) {
int index = data.keynrs[i];
ValueMetaInterface valueMeta = rowMeta.getValueMeta(index);
Object valueData = r[index];
switch(valueMeta.getType()) {
case ValueMetaInterface.TYPE_STRING :
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertVarchar(valueMeta.getString(valueData)));
break;
case ValueMetaInterface.TYPE_INTEGER:
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertLong(valueMeta.getInteger(valueData)));
break;
case ValueMetaInterface.TYPE_DATE:
Date date = valueMeta.getDate(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertDateTime(date));
break;
case ValueMetaInterface.TYPE_BOOLEAN:
Boolean b= valueMeta.getBoolean(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertBoolean(b));
break;
case ValueMetaInterface.TYPE_NUMBER:
Double d = valueMeta.getNumber(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertFloat(d));
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
BigDecimal bn = valueMeta.getBigNumber(valueData);
data.fifoStream.write(TeraDataBulkLoaderRoutines.convertBignum(bn));
break;
default:
logError("This is seen when a type in the PDI stream is not handleed by the step. Type is "+valueMeta.getType());
throw new KettleException("Unsupported type in stream");
}
}
}
catch(IOException e)
{
// If something went wrong with writing to the fifo, get the underlying error from MySQL
try{
logError("IOException writing to fifo. Waiting up to " + this.threadWaitTimeText + " for the tbuild command thread to return with the error.");
}
catch (Exception loadEx){
logError("Caught Loadex error :"+ loadEx);
throw new KettleException("loadEx Error serializing rows of data to the fifo file 1", loadEx);
}
// throw the generic "Pipe" exception.
logError("Caught IO error (pipe?):"+ e);
throw new KettleException("IO Error serializing rows of data to the fifo file 2", e);
}
catch (Exception e2){
logError("Caught some error :"+ e2);
// Null pointer exceptions etc.
throw new KettleException("Error serializing rows of data to the fifo file", e2);
}
}
示例14: getValueFromResultSet
/**
* This method allows a database dialect to convert database specific data types to Kettle data types.
*
* @param resultSet The result set to use
* @param valueMeta The description of the value to retrieve
* @param index the index on which we need to retrieve the value, 0-based.
* @return The correctly converted Kettle data type corresponding to the valueMeta description.
* @throws KettleDatabaseException
*/
public Object getValueFromResultSet(ResultSet rs, ValueMetaInterface val, int i) throws KettleDatabaseException {
Object data = null;
try {
switch (val.getType()) {
case ValueMetaInterface.TYPE_BOOLEAN:
data = Boolean.valueOf(rs.getBoolean(i + 1));
break;
case ValueMetaInterface.TYPE_NUMBER:
data = new Double(rs.getDouble(i + 1));
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
data = rs.getBigDecimal(i + 1);
break;
case ValueMetaInterface.TYPE_INTEGER:
data = Long.valueOf(rs.getLong(i + 1));
break;
case ValueMetaInterface.TYPE_STRING:
if (val.isStorageBinaryString()) {
data = rs.getBytes(i + 1);
} else {
data = rs.getString(i + 1);
}
break;
case ValueMetaInterface.TYPE_BINARY:
if (supportsGetBlob()) {
Blob blob = rs.getBlob(i + 1);
if (blob != null) {
data = blob.getBytes(1L, (int) blob.length());
} else {
data = null;
}
} else {
data = rs.getBytes(i + 1);
}
break;
case ValueMetaInterface.TYPE_DATE:
if (val.getPrecision() != 1 && supportsTimeStampToDateConversion()) {
data = rs.getTimestamp(i + 1);
break; // Timestamp extends java.util.Date
} else {
data = rs.getDate(i + 1);
break;
}
default:
break;
}
if (rs.wasNull()) {
data = null;
}
} catch(SQLException e) {
throw new KettleDatabaseException("Unable to get value '"+val.toStringMeta()+"' from database resultset, index "+i, e);
}
return data;
}
示例15: getValueFromResultSet
/**
* This method allows a database dialect to convert database specific data types to Kettle data types.
*
* @param resultSet The result set to use
* @param valueMeta The description of the value to retrieve
* @param index the index on which we need to retrieve the value, 0-based.
* @return The correctly converted Kettle data type corresponding to the valueMeta description.
* @throws KettleDatabaseException
*/
public Object getValueFromResultSet(ResultSet rs, ValueMetaInterface val, int i) throws KettleDatabaseException {
Object data = null;
try {
switch (val.getType()) {
case ValueMetaInterface.TYPE_BOOLEAN:
data = Boolean.valueOf(rs.getBoolean(i + 1));
break;
case ValueMetaInterface.TYPE_NUMBER:
data = new Double(rs.getDouble(i + 1));
break;
case ValueMetaInterface.TYPE_BIGNUMBER:
data = rs.getBigDecimal(i + 1);
break;
case ValueMetaInterface.TYPE_INTEGER:
data = Long.valueOf(rs.getLong(i + 1));
break;
case ValueMetaInterface.TYPE_STRING:
if (val.isStorageBinaryString()) {
data = rs.getBytes(i + 1);
} else {
data = rs.getString(i + 1);
}
break;
case ValueMetaInterface.TYPE_BINARY:
if (supportsGetBlob()) {
Blob blob = rs.getBlob(i + 1);
if (blob != null) {
data = blob.getBytes(1L, (int) blob.length());
} else {
data = null;
}
} else {
data = rs.getBytes(i + 1);
}
break;
case ValueMetaInterface.TYPE_DATE:
if (val.getOriginalColumnType() == java.sql.Types.TIME) {
// Neoview can not handle getDate / getTimestamp for a Time column
data = rs.getTime(i + 1);
break; // Time is a subclass of java.util.Date, the default date
// will be 1970-01-01
} else if (val.getPrecision() != 1 && supportsTimeStampToDateConversion()) {
data = rs.getTimestamp(i + 1);
break; // Timestamp extends java.util.Date
} else {
data = rs.getDate(i + 1);
break;
}
default:
break;
}
if (rs.wasNull()) {
data = null;
}
} catch(SQLException e) {
throw new KettleDatabaseException("Unable to get value '"+val.toStringMeta()+"' from database resultset, index "+i, e);
}
return data;
}