本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.getLength方法的具体用法?Java ValueMetaInterface.getLength怎么用?Java ValueMetaInterface.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.row.ValueMetaInterface
的用法示例。
在下文中一共展示了ValueMetaInterface.getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatField
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* Takes an input field and converts it to bytes to be stored in the temp file.
* @param v The metadata about the column
* @param valueData The column data
* @return The bytes for the value
* @throws KettleValueException
*/
private byte[] formatField( ValueMetaInterface v, Object valueData ) throws KettleValueException {
if ( v.isString() ) {
if ( v.isStorageBinaryString() && v.getTrimType() == ValueMetaInterface.TRIM_TYPE_NONE && v.getLength() < 0
&& Const.isEmpty( v.getStringEncoding() ) ) {
return (byte[]) valueData;
} else {
String svalue = ( valueData instanceof String ) ? (String) valueData : v.getString( valueData );
// trim or cut to size if needed.
//
return convertStringToBinaryString( v, Const.trimToType( svalue, v.getTrimType() ) );
}
} else {
return v.getBinaryString( valueData );
}
}
示例2: formatField
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private byte[] formatField(ValueMetaInterface v, Object valueData) throws KettleValueException
{
if( v.isString() )
{
if (v.isStorageBinaryString()
&& v.getTrimType()==ValueMetaInterface.TRIM_TYPE_NONE
&& v.getLength()<0
&& Const.isEmpty(v.getStringEncoding())
) {
return (byte[])valueData;
} else {
String svalue = (valueData instanceof String)?(String)valueData:v.getString(valueData);
// trim or cut to size if needed.
//
return convertStringToBinaryString(v,Const.trimToType(svalue, v.getTrimType()));
}
}
else
{
return v.getBinaryString(valueData);
}
}
示例3: define
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* @param targetTableFields
* ...
* @param dataFile
* ...
* @return this
*/
public FastloadControlBuilder define(final RowMetaInterface targetTableFields, final String dataFile) {
Assert.assertNotNull(targetTableFields, "fields cannot be null");
Assert.assertNotNull(dataFile, "dataFile cannot be null");
this.builder.append("DEFINE ");
for (int i = 0; i < targetTableFields.size(); i++) {
ValueMetaInterface value = targetTableFields.getValueMeta(i);
this.builder.append(value.getName());
// all fields of type VARCHAR. converted by fastload if necessary
int length = 0;
if (value.getType() == ValueMetaInterface.TYPE_DATE) {
length = DEFAULT_DATE_FORMAT.length();
} else {
length = value.getLength();
}
this.builder.append("(" + "VARCHAR(" + length + "), nullif = '" + String.format("%1$#" + length + "s", DEFAULT_NULL_VALUE) + "'), ");
this.builder.append(SystemUtils.LINE_SEPARATOR);
}
this.builder.append(" NEWLINECHAR(VARCHAR(" + SystemUtils.LINE_SEPARATOR.length() + "))");
this.builder.append(" FILE=" + dataFile);
return this.newline();
}
示例4: formatField
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private byte[] formatField(ValueMetaInterface v, Object valueData) throws KettleValueException {
if (v.isString()) {
if (v.isStorageBinaryString() && v.getTrimType() == ValueMetaInterface.TRIM_TYPE_NONE && v.getLength() < 0
&& Const.isEmpty( v.getStringEncoding())) {
return (byte[]) valueData;
} else {
String svalue = (valueData instanceof String) ? (String) valueData : v.getString(valueData);
// trim or cut to size if needed.
return convertStringToBinaryString(v, Const.trimToType(svalue, v.getTrimType()));
}
} else {
return v.getBinaryString(valueData);
}
}
示例5: createDataSetFromStep
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
* Create a new data set with the output from
*/
public void createDataSetFromStep() {
Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
TransGraph transGraph = spoon.getActiveTransGraph();
IMetaStore metaStore = spoon.getMetaStore();
if ( transGraph == null ) {
return;
}
StepMeta stepMeta = transGraph.getCurrentStep();
TransMeta transMeta = spoon.getActiveTransformation();
if ( stepMeta == null || transMeta == null ) {
return;
}
try {
MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
List<DataSetGroup> groups = groupFactory.getElements();
MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE );
setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups );
DataSet dataSet = new DataSet();
RowMetaInterface rowMeta = transMeta.getStepFields( stepMeta );
for ( int i = 0; i < rowMeta.size(); i++ ) {
ValueMetaInterface valueMeta = rowMeta.getValueMeta( i );
DataSetField field = new DataSetField( valueMeta.getName(), "field" + i, valueMeta.getType(), valueMeta.getLength(), valueMeta.getPrecision(), valueMeta.getComments() );
dataSet.getFields().add( field );
}
editDataSet( spoon, dataSet, groups, setFactory, null );
} catch ( Exception e ) {
new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set", e );
}
}
示例6: get
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields( stepname );
if ( r != null ) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
if ( v.isNumber() ) {
if ( v.getLength() > 0 ) {
int le = v.getLength();
int pr = v.getPrecision();
if ( v.getPrecision() <= 0 ) {
pr = 0;
}
String mask = "";
for ( int m = 0; m < le - pr; m++ ) {
mask += "0";
}
if ( pr > 0 ) {
mask += ".";
}
for ( int m = 0; m < pr; m++ ) {
mask += "0";
}
tableItem.setText( 3, mask );
}
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] { 2 }, 4, 5, listener );
}
} catch ( KettleException ke ) {
new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Title" ), BaseMessages
.getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), ke );
}
}
示例7: get
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.isNumber()) {
if (v.getLength() > 0) {
int le = v.getLength();
int pr = v.getPrecision();
if (v.getPrecision() <= 0) {
pr = 0;
}
String mask = "";
for (int m = 0; m < le - pr; m++) {
mask += "0";
}
if (pr > 0)
mask += ".";
for (int m = 0; m < pr; m++) {
mask += "0";
}
tableItem.setText(3, mask);
}
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1, 5 }, new int[] { 2 }, 0, 0, listener);
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), ke);
}
}
示例8: isClob
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public boolean isClob(ValueMetaInterface v)
{
boolean retval=true;
if (v==null || v.getLength()<DatabaseMeta.CLOB_LENGTH)
{
retval=false;
}
else
{
return true;
}
return retval;
}
示例9: getFieldDefinition
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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;
}
示例10: getFields
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/***
* This Method overwrittes the fields and makes all field outputs as String
* <br>
* <i>The Params are defined from the parent class, but not all
* used</i></br>
* <b>Only for internal Use from the Pentaho Project</b> {@inheritDoc}
*
* @author Florian Wiedner
* @category Storage
* @since 1.5
* @param r
* RowMetaInterface The RowMetaInterface generated for this step
* @param origin
* String The origin (Not used)
* @param info
* RowMetaInterface[] The MetaInterfaces of the previous Steps
* @param nextStep
* StepMeta (Not used)
* @param space
* VariableSpace (not used)
* @see org.pentaho.di.trans.step.BaseStepMeta#getFields()
*/
public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep,
VariableSpace space) {
String[] fieldNames = r.getFieldNames();
for (int i = 0; i < fieldNames.length; i++) {
ValueMetaInterface temp = r.getValueMeta(i);
temp.getLength();
ValueMeta temp2 = new ValueMeta(fieldNames[i], ValueMeta.getType("String"), temp.getLength(),
temp.getPrecision());
try {
r.removeValueMeta(fieldNames[i]);
r.addValueMeta(i, temp2);
} catch (KettleValueException e) {
logError("Unexpected error : " + e.toString());
logError(Const.getStackTracker(e));
}
}
}
示例11: get
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
private void get() {
try {
RowMetaInterface r = transMeta.getPrevStepFields(stepname);
if (r != null) {
TableItemInsertListener listener = new TableItemInsertListener() {
@Override
public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
if (v.isNumeric()) {
// currency symbol
tableItem.setText(6, Const.NVL(v.getCurrencySymbol(), ""));
// decimal and grouping
tableItem.setText(7, Const.NVL(v.getDecimalSymbol(), ""));
tableItem.setText(8, Const.NVL(v.getGroupingSymbol(), ""));
}
// trim type
tableItem.setText(9, Const.NVL(ValueMeta.getTrimTypeDesc(v.getTrimType()), ""));
// conversion mask
if (!Const.isEmpty(v.getConversionMask())) {
tableItem.setText(3, v.getConversionMask());
} else {
if (v.isNumber()) {
if (v.getLength() > 0) {
int le = v.getLength();
int pr = v.getPrecision();
if (v.getPrecision() <= 0) {
pr = 0;
}
String mask = "";
for (int m = 0; m < le - pr; m++) {
mask += "0";
}
if (pr > 0) {
mask += ".";
}
for (int m = 0; m < pr; m++) {
mask += "0";
}
tableItem.setText(3, mask);
}
}
}
return true;
}
};
BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] {1}, new int[] {2}, 4, 5, listener);
}
} catch(KettleException e) {
new ErrorDialog(shell, Messages.getString("System.Dialog.GetFieldsFailed.Title"),
Messages.getString("System.Dialog.GetFieldsFailed.Message"), e);
}
}
示例12: getFieldDefinition
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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();
}
示例13: getFieldDefinition
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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("DATE"); break;
case ValueMetaInterface.TYPE_BOOLEAN: retval.append("CHAR(1)"); break;
case ValueMetaInterface.TYPE_NUMBER :
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
retval.append("NUMBER");
if (length>0)
{
retval.append('(').append(length);
if (precision>0)
{
retval.append(", ").append(precision);
}
retval.append(')');
}
break;
case ValueMetaInterface.TYPE_STRING:
if (length>=DatabaseMeta.CLOB_LENGTH)
{
retval.append("CLOB");
}
else
{
if (length>0 && length<=2000)
{
retval.append("VARCHAR2(").append(length).append(')');
}
else
{
if (length<=0)
{
retval.append("VARCHAR2(2000)"); // We don't know, so we just use the maximum...
}
else
{
retval.append("CLOB");
}
}
}
break;
default:
retval.append(" UNKNOWN");
break;
}
if (add_cr) retval.append(Const.CR);
return retval.toString();
}
示例14: getFieldDefinition
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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+="DATETIME"; break; // There is no Date or Timestamp data type in SQLite!!!
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 PRIMARY KEY AUTOINCREMENT";
}
else
{
if (precision!=0 || length<0 || length>18 )
{
retval+="NUMERIC";
}
else
{
retval+="INTEGER";
}
}
break;
case ValueMetaInterface.TYPE_STRING:
if (length>=DatabaseMeta.CLOB_LENGTH)
{
retval+="BLOB";
}
else
{
retval+="TEXT";
}
break;
case ValueMetaInterface.TYPE_BINARY:
retval+="BLOB";
break;
default:
retval+="UNKNOWN";
break;
}
if (add_cr) retval+=Const.CR;
return retval;
}
示例15: getFieldDefinition
import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
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+="DATETIME"; break;
case ValueMetaInterface.TYPE_BOOLEAN: retval+="CHAR(1)"; break;
case ValueMetaInterface.TYPE_NUMBER :
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
retval+="DECIMAL";
if (length>0)
{
retval+="("+length;
if (precision>0)
{
retval+=", "+precision;
}
retval+=")";
}
break;
case ValueMetaInterface.TYPE_STRING:
if (length>=DatabaseMeta.CLOB_LENGTH)
{
retval+="CLOB";
}
else
{
retval+="VARCHAR";
if (length>0)
{
retval+="("+length;
}
else
{
retval+="("; // Maybe use some default DB String length?
}
retval+=")";
}
break;
default:
retval+=" UNKNOWN";
break;
}
if (add_cr) retval+=Const.CR;
return retval;
}