本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.getBinary方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.getBinary方法的具体用法?Java ValueMetaInterface.getBinary怎么用?Java ValueMetaInterface.getBinary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.getBinary方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrimitive
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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;
}
}
示例2: messageToBytes
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
protected byte[] messageToBytes( Object message, ValueMetaInterface messageValueMeta ) throws KettleValueException {
if ( message == null || Const.isEmpty( message.toString() ) ) {
return null;
}
byte[] result = null;
try {
ByteBuffer buff = null;
switch ( messageValueMeta.getType() ) {
case ValueMetaInterface.TYPE_STRING:
result = message.toString().getBytes( "UTF-8" );
break;
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_DATE: // send the date as a long (milliseconds) value
buff = ByteBuffer.allocate( 8 );
buff.putLong( messageValueMeta.getInteger( message ) );
result = buff.array();
break;
case ValueMetaInterface.TYPE_NUMBER:
buff = ByteBuffer.allocate( 8 );
buff.putDouble( messageValueMeta.getNumber( message ) );
result = buff.array();
break;
case ValueMetaInterface.TYPE_TIMESTAMP:
buff = ByteBuffer.allocate( 12 );
Timestamp ts = (Timestamp) message;
buff.putLong( ts.getTime() );
buff.putInt( ts.getNanos() );
result = buff.array();
break;
case ValueMetaInterface.TYPE_BINARY:
result = messageValueMeta.getBinary( message );
break;
case ValueMetaInterface.TYPE_BOOLEAN:
result = new byte[1];
if ( messageValueMeta.getBoolean( message ) ) {
result[0] = 1;
}
break;
case ValueMetaInterface.TYPE_SERIALIZABLE:
if ( !( message instanceof Serializable ) ) {
throw new KettleValueException( "Message value is not serializable!" );
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( bos );
oos.writeObject( message );
oos.flush();
result = bos.toByteArray();
break;
}
} catch ( Exception ex ) {
throw new KettleValueException( ex );
}
return result;
}
示例3: createObjectsForRow
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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;
}
示例4: createObjectsForRow
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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];
// Prevent a NullPointerException below
if (valueData == null || valueMeta == null)
{
values[i] = null;
continue;
}
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;
}