当前位置: 首页>>代码示例>>Java>>正文


Java ValueMetaInterface.getPrecision方法代码示例

本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaInterface.getPrecision方法的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaInterface.getPrecision方法的具体用法?Java ValueMetaInterface.getPrecision怎么用?Java ValueMetaInterface.getPrecision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.row.ValueMetaInterface的用法示例。


在下文中一共展示了ValueMetaInterface.getPrecision方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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 );
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:40,代码来源:DataSetHelper.java

示例2: 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 );
  }

}
 
开发者ID:griddynamics,项目名称:xml-dom-kettle-etl-plugin,代码行数:40,代码来源:DOMConcatFieldsDialog.java

示例3: 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));
		}

	}
}
 
开发者ID:WiednerF,项目名称:ARXPlugin,代码行数:41,代码来源:ARXPluginMeta.java

示例4: 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);
    }
}
 
开发者ID:socrata,项目名称:socrata-kettle,代码行数:58,代码来源:SocrataPluginDialog.java

示例5: getFieldDefinition

import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
@Override
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr) {
    String retval = "";

    int length = v.getLength();
    int precision = v.getPrecision();

    String fieldname = v.getName();
    if (add_fieldname) {
        retval += fieldname + " ";
    }

    int type = v.getType();
    switch (type) {
        case ValueMetaInterface.TYPE_INTEGER:
        case ValueMetaInterface.TYPE_NUMBER:
        case ValueMetaInterface.TYPE_BIGNUMBER:
            if (fieldname.equalsIgnoreCase(tk)) {
                retval += "BIGINT";
                if (use_autoinc) {
                    retval += " GENERATED ALWAYS AS IDENTITY";
                }
                if (fieldname.equalsIgnoreCase(pk)) {
                    retval += " PRIMARY KEY";
                }
            } else {
                if (precision == 0) {
                    if (length > 18) {
                        retval += "DECIMAL(" + length + ",0)";
                    } else {
                        if (length > 9) {
                            retval += "BIGINT";
                        } else {
                            retval += "INTEGER";
                        }
                        if (fieldname.equalsIgnoreCase(pk)) {
                            retval += " PRIMARY KEY";
                        }
                    }
                } else {
                    if (length > 15) {
                        retval += "DECIMAL(" + length;
                        if (precision > 0) {
                            retval += ", " + precision;
                        }
                        retval += ")";
                    } else {
                        retval += "DOUBLE";
                    }
                }
            }
            break;
        case ValueMetaInterface.TYPE_STRING:
            retval += "STRING";
            break;
        case ValueMetaInterface.TYPE_DATE:
            retval += "DATE";
            break;
        case ValueMetaInterface.TYPE_BOOLEAN:
            retval += "BOOLEAN";
            break;
        case ValueMetaInterface.TYPE_BINARY:
            retval += "BLOB";
            break;
        case ValueMetaInterface.TYPE_TIMESTAMP:
            retval += "TIMESTAMP";
            break;
        default:
            retval += "UNKNOWN";
            break;
    }

    if (add_cr) {
        retval += Const.CR;
    }

    return retval;
}
 
开发者ID:nuodb,项目名称:pdi-nuodb-plugin,代码行数:79,代码来源:NuoDBDatabaseMeta.java

示例6: 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+="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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:64,代码来源:UniVerseDatabaseMeta.java

示例7: 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+="date"; break;
	case ValueMetaInterface.TYPE_BOOLEAN: retval+="boolean"; break;
	case ValueMetaInterface.TYPE_NUMBER :
	case ValueMetaInterface.TYPE_INTEGER:
       case ValueMetaInterface.TYPE_BIGNUMBER:
       	if (length > 0) 
           {
       		if (precision == 0) 
               {
       			if (length <= 2)
       				retval += "byteint";
       			else if (length <= 4)
       				retval += "smallint";
       			else if (length <= 9)
       				retval += "integer";
       			else retval += "bigint";
       		} 
               else 
               {
       			if (length < 9)
       				retval += "real";
       			else if (length < 18)
       				retval += "double";
       			else 
                   {
       				retval += "numeric(" + length;
       				if (precision > 0)
       					retval += ", " + precision;
       				retval += ")";
       			}
       		}
       	}
		break;
	case ValueMetaInterface.TYPE_STRING:
		if (length > MAX_CHAR_LEN)
			retval += "varchar(" + MAX_CHAR_LEN + ")";
		else
			retval+="varchar("+length+")"; 
		break;
	default:
		retval+=" UNKNOWN";
		break;
	}
	if (add_cr) retval+=Const.CR;
	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:60,代码来源:NetezzaDatabaseMeta.java

示例8: 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();
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:63,代码来源:OracleRDBDatabaseMeta.java

示例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();
	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+="CHAR(1)"; break;
	case ValueMetaInterface.TYPE_NUMBER : 
	case ValueMetaInterface.TYPE_INTEGER: 
       case ValueMetaInterface.TYPE_BIGNUMBER: 
           if (length<=0 && precision<=0)
           {
               retval+="DOUBLE";
           }
           else
           {
   			retval+="DECIMAL"; 
   			if (length>0)
   			{
   				retval+="("+length;
   				if (precision>0)
   				{
   					retval+=", "+precision;
   				}
   				retval+=")";
   			}
           }
		break;
	case ValueMetaInterface.TYPE_STRING:
		if (length>getMaxVARCHARLength() || 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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:65,代码来源:AS400DatabaseMeta.java

示例10: 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();
	}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:65,代码来源:Exasol4DatabaseMeta.java

示例11: 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_BIGNUMBER: 
		retval.append("NUMBER"); 
		if (length>0)
		{
			retval.append('(').append(length);
			if (precision>0)
			{
				retval.append(", ").append(precision);
			}
			retval.append(')');
		}
		break;
	case ValueMetaInterface.TYPE_INTEGER:  
		retval.append("INTEGER"); 
		break;			
	case ValueMetaInterface.TYPE_STRING:
		if (length>=DatabaseMeta.CLOB_LENGTH)
		{
			retval.append("CLOB");
		}
		else
		{
			if (length==1) {
				retval.append("CHAR(1)");
			} 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;
       case ValueMetaInterface.TYPE_BINARY: // the BLOB can contain binary data.
           {
               retval.append("BLOB");
           }
           break;
	default:
		retval.append(" UNKNOWN");
		break;
	}
	
	if (add_cr) retval.append(Const.CR);
	
	return retval.toString();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:72,代码来源:OracleDatabaseMeta.java

示例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)
{
	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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:58,代码来源:DbaseDatabaseMeta.java

示例13: getValueFromResultSet

import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:71,代码来源:NeoviewDatabaseMeta.java

示例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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:59,代码来源:SQLiteDatabaseMeta.java

示例15: getColumns

import org.pentaho.di.core.row.ValueMetaInterface; //导入方法依赖的package包/类
public static final List<Column> getColumns(RowMetaInterface row)
{
    List<Column> list = new ArrayList<Column>();
    
    for (int i = 0; i < row.size(); i++)
    {
        ValueMetaInterface value = row.getValueMeta(i);
        
        Column column = new Column();
        column.setName(value.getName());
        
        int length = value.getLength();
        
        switch(value.getType())
        {
        case ValueMetaInterface.TYPE_INTEGER:
            if (length<3)
            {
                column.setType(DataType.BYTE);
                length = DataType.BYTE.getFixedSize();
            }
            else
            {
                if (length<5)
                {
                    column.setType(DataType.INT);
                    length = DataType.INT.getFixedSize();
                }
                else
                {
                    column.setType(DataType.LONG);
                    length = DataType.LONG.getFixedSize();
                }
            }
            break;
        case ValueMetaInterface.TYPE_NUMBER:
            column.setType(DataType.DOUBLE);
            length = DataType.DOUBLE.getFixedSize();
            break;
        case ValueMetaInterface.TYPE_DATE:
            column.setType(DataType.SHORT_DATE_TIME);
            length = DataType.SHORT_DATE_TIME.getFixedSize();
            break;
        case ValueMetaInterface.TYPE_STRING:
            if (length<255)
            {
                column.setType(DataType.TEXT);
                length*=DataType.TEXT.getUnitSize();
            }
            else
            {
                column.setType(DataType.MEMO);
                length*=DataType.MEMO.getUnitSize();
            }
            break;
        case ValueMetaInterface.TYPE_BINARY:
            column.setType(DataType.BINARY);
            break;
        case ValueMetaInterface.TYPE_BOOLEAN:
            column.setType(DataType.BOOLEAN);
            length = DataType.BOOLEAN.getFixedSize();
            break;
        case ValueMetaInterface.TYPE_BIGNUMBER:
            column.setType(DataType.NUMERIC);
            length = DataType.NUMERIC.getFixedSize();
            break;
        default: break;
        }
        
        if (length>=0) column.setLength((short)length);
        if (value.getPrecision()>=1 && value.getPrecision()<=28) column.setPrecision((byte)value.getPrecision());
        
        list.add(column);
    }
    
    return list;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:78,代码来源:AccessOutputMeta.java


注:本文中的org.pentaho.di.core.row.ValueMetaInterface.getPrecision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。