本文整理汇总了Java中org.pentaho.di.core.row.ValueMetaAndData类的典型用法代码示例。如果您正苦于以下问题:Java ValueMetaAndData类的具体用法?Java ValueMetaAndData怎么用?Java ValueMetaAndData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueMetaAndData类属于org.pentaho.di.core.row包,在下文中一共展示了ValueMetaAndData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValue
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
private ValueMetaAndData getValue(String valuename) throws KettleValueException {
int valtype = ValueMeta.getType(wValueType.getText());
ValueMetaAndData val = new ValueMetaAndData(valuename, wInputString.getText());
ValueMetaInterface valueMeta = val.getValueMeta();
Object valueData = val.getValueData();
valueMeta.setType(valtype);
int formatIndex = wFormat.getSelectionIndex();
valueMeta.setConversionMask(formatIndex >= 0 ? wFormat.getItem(formatIndex) : wFormat.getText());
valueMeta.setLength(Const.toInt(wLength.getText(), -1));
valueMeta.setPrecision(Const.toInt(wPrecision.getText(), -1));
ValueMetaInterface stringValueMeta = new ValueMeta(valuename, ValueMetaInterface.TYPE_STRING);
stringValueMeta.setConversionMetadata(valueMeta);
Object targetData = stringValueMeta.convertDataUsingConversionMetaData(valueData);
val.setValueData(targetData);
return val;
}
示例2: test
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
/**
* Test the entered value
*
*/
public void test() {
try {
ValueMetaAndData v = getValue(valueMeta.getName());
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
StringBuffer result = new StringBuffer();
result.append(Const.CR).append(Const.CR).append(" ").append(v.toString());
result.append(Const.CR).append(" ").append(v.toStringMeta());
mb.setMessage(Messages.getString("EnterValueDialog.TestResult.Message", result.toString()));
mb.setText(Messages.getString("EnterValueDialog.TestResult.Title"));
mb.open();
} catch (KettleValueException e) {
new ErrorDialog(shell, "Error", "There was an error during data type conversion: ", e);
}
}
示例3: test
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
/**
* Test the entered value
*
*/
public void test() {
try {
ValueMetaAndData v = getValue(valueMeta.getName());
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
StringBuffer result = new StringBuffer();
result.append(Const.CR).append(Const.CR).append(" ").append(v.toString());
result.append(Const.CR).append(" ").append(v.toStringMeta());
mb.setMessage(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Message", result.toString()));
mb.setText(BaseMessages.getString(PKG, "EnterValueDialog.TestResult.Title"));
mb.open();
} catch (KettleValueException e) {
new ErrorDialog(shell, "Error", "There was an error during data type conversion: ", e);
}
}
示例4: getValue
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
private ValueMetaAndData getValue(String valuename) throws KettleValueException {
try {
int valtype = ValueMeta.getType(wValueType.getText());
ValueMetaAndData val = new ValueMetaAndData(valuename, wInputString.getText());
ValueMetaInterface valueMeta = ValueMetaFactory.cloneValueMeta(val.getValueMeta(), valtype);
Object valueData = val.getValueData();
int formatIndex = wFormat.getSelectionIndex();
valueMeta.setConversionMask(formatIndex >= 0 ? wFormat.getItem(formatIndex) : wFormat.getText());
valueMeta.setLength(Const.toInt(wLength.getText(), -1));
valueMeta.setPrecision(Const.toInt(wPrecision.getText(), -1));
ValueMetaInterface stringValueMeta = new ValueMeta(valuename, ValueMetaInterface.TYPE_STRING);
stringValueMeta.setConversionMetadata(valueMeta);
Object targetData = stringValueMeta.convertDataUsingConversionMetaData(valueData);
val.setValueData(targetData);
return val;
} catch(Exception e) {
throw new KettleValueException(e);
}
}
示例5: attemptIntegerValueExtraction
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
public static ValueMetaAndData attemptIntegerValueExtraction(String string) {
// Try an Integer
if (!string.contains(".")) {
try {
long l = Long.parseLong(string);
if (Long.toString(l).equals(string)) {
ValueMetaAndData value = new ValueMetaAndData();
ValueMetaInterface valueMeta = new ValueMeta("Constant", ValueMetaInterface.TYPE_INTEGER);
valueMeta.setConversionMask("0");
valueMeta.setGroupingSymbol(null);
value.setValueMeta(valueMeta);
value.setValueData(Long.valueOf(l));
return value;
}
} catch(NumberFormatException e) {
}
}
return null;
}
示例6: attemptNumberValueExtraction
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
public static ValueMetaAndData attemptNumberValueExtraction(String string) {
// Try a Number
try {
double d = Double.parseDouble(string);
if (Double.toString(d).equals(string)) {
ValueMetaAndData value = new ValueMetaAndData();
ValueMetaInterface valueMeta = new ValueMeta("Constant", ValueMetaInterface.TYPE_NUMBER);
valueMeta.setConversionMask("0.#");
valueMeta.setGroupingSymbol(null);
valueMeta.setDecimalSymbol(".");
value.setValueMeta(valueMeta);
value.setValueData(Double.valueOf(d));
return value;
}
} catch(NumberFormatException e) {
}
return null;
}
示例7: getValue
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
private ValueMetaAndData getValue( String valuename ) throws KettleValueException {
try {
int valtype = ValueMetaFactory.getIdForValueMeta( wValueType.getText() );
ValueMetaAndData val = new ValueMetaAndData( valuename, wInputString.getText() );
ValueMetaInterface valueMeta = ValueMetaFactory.cloneValueMeta( val.getValueMeta(), valtype );
Object valueData = val.getValueData();
int formatIndex = wFormat.getSelectionIndex();
valueMeta.setConversionMask( formatIndex >= 0 ? wFormat.getItem( formatIndex ) : wFormat.getText() );
valueMeta.setLength( Const.toInt( wLength.getText(), -1 ) );
valueMeta.setPrecision( Const.toInt( wPrecision.getText(), -1 ) );
val.setValueMeta( valueMeta );
ValueMetaInterface stringValueMeta = new ValueMetaString( valuename );
stringValueMeta.setConversionMetadata( valueMeta );
Object targetData = stringValueMeta.convertDataUsingConversionMetaData( valueData );
val.setValueData( targetData );
return val;
} catch ( Exception e ) {
throw new KettleValueException( e );
}
}
示例8: test
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
/**
* Test the entered value
*
*/
public void test() {
try {
ValueMetaAndData v = getValue( valueMeta.getName() );
MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_INFORMATION );
StringBuilder result = new StringBuilder();
result.append( Const.CR ).append( Const.CR ).append( " " ).append( v.toString() );
result.append( Const.CR ).append( " " ).append( v.toStringMeta() );
mb.setMessage( BaseMessages.getString( PKG, "EnterValueDialog.TestResult.Message", result.toString() ) );
mb.setText( BaseMessages.getString( PKG, "EnterValueDialog.TestResult.Title" ) );
mb.open();
} catch ( KettleValueException e ) {
new ErrorDialog( shell, "Error", "There was an error during data type conversion: ", e );
}
}
示例9: Condition
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
public Condition(String valuename, int function, String valuename2, ValueMetaAndData exact)
{
this();
this.left_valuename = valuename;
this.function = function;
this.right_valuename = valuename2;
this.right_exact = exact;
clearFieldPositions();
}
示例10: clone
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
public Object clone()
{
Condition retval = null;
retval = new Condition();
retval.negate = negate;
retval.operator = operator;
if (isComposite())
{
for (int i=0;i<nrConditions();i++)
{
Condition c = getCondition(i);
Condition cCopy = (Condition)c.clone();
retval.addCondition(cCopy);
}
}
else
{
retval.negate = negate;
retval.left_valuename = left_valuename;
retval.operator = operator;
retval.right_valuename = right_valuename;
retval.function = function;
if (right_exact!=null)
{
retval.right_exact = (ValueMetaAndData) right_exact.clone();
}
else
{
retval.right_exact = null;
}
}
return retval;
}
示例11: convert
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
private Object convert(Object obj, AccessInputField field, int index) throws Exception
{
// Get column
Column c = data.t.getColumn(field.getColumn());
// Find out field type
ValueMetaAndData sourceValueMetaAndData= AccessInputMeta.getValueMetaAndData(c, field.getName(), obj);
// DO CONVERSIONS...
//
ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta(data.totalpreviousfields+index);
return targetValueMeta.convertData(sourceValueMetaAndData.getValueMeta(), sourceValueMetaAndData.getValueData());
}
示例12: getValueMeta
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
/**
* Returns kettle type from Microsoft Access database
* @param : MS Access column
* @return valuemeta
*/
public static ValueMetaInterface getValueMeta(Column c)
{
// get value
ValueMetaAndData vmd=getValueMetaAndData(c, null, null);
if(vmd!=null) {
// returns meta
return vmd.getValueMeta();
}
return null;
}
示例13: getAtomicConditionRightSql
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
private String getAtomicConditionRightSql(Condition atomicCondition) throws KettleValueException {
ValueMetaAndData right = atomicCondition.getRightExact();
if (right==null) {
// right value
//
String rightName = atomicCondition.getRightValuename();
FieldVariableMapping mapping = FieldVariableMapping.findFieldVariableMappingByFieldName(service.getFieldVariableMappings(), atomicCondition.getRightValuename());
if (mapping!=null) {
rightName = mapping.getVariableName();
}
return rightName;
}
if (right.getValueMeta().isNull(right.getValueData())) {
return "NULL";
}
switch(right.getValueMeta().getType()) {
case ValueMetaInterface.TYPE_STRING:
return "'"+right.toString()+"'";
case ValueMetaInterface.TYPE_NUMBER:
case ValueMetaInterface.TYPE_INTEGER:
case ValueMetaInterface.TYPE_BIGNUMBER:
return sqlNumericFormat.format(right.getValueMeta().convertToNormalStorageType(right.getValueData()));
case ValueMetaInterface.TYPE_DATE:
return sqlDateFormat.format(right.getValueMeta().getDate(right.getValueData()));
case ValueMetaInterface.TYPE_BOOLEAN:
return right.getValueMeta().getBoolean(right.getValueData()) ? "TRUE" : "FALSE";
default:
throw new KettleValueException("Unsupported conversion of value from "+right.getValueMeta().toStringMeta()+" to SQL");
}
}
示例14: getJsonString
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
protected String getJsonString(ValueMetaAndData v) throws KettleValueException {
ValueMetaInterface meta = v.getValueMeta();
Object data = v.getValueData();
switch(meta.getType()) {
case ValueMetaInterface.TYPE_STRING: return '"'+meta.getString(data)+'"';
case ValueMetaInterface.TYPE_NUMBER: return sqlNumericFormat.format(meta.getNumber(data));
case ValueMetaInterface.TYPE_INTEGER: return sqlNumericFormat.format(meta.getInteger(data));
case ValueMetaInterface.TYPE_BIGNUMBER: return sqlNumericFormat.format(meta.getBigNumber(data));
case ValueMetaInterface.TYPE_DATE: return "{ $date : \""+jsonDateFormat.format(meta.getBigNumber(data))+"\" }";
default:
throw new KettleValueException("Converting data type "+meta.toStringMeta()+" to a JSON value is not yet supported");
}
}
示例15: attemptDateValueExtraction
import org.pentaho.di.core.row.ValueMetaAndData; //导入依赖的package包/类
public static ValueMetaAndData attemptDateValueExtraction(String string) {
if (string.length()>2 && string.startsWith("[") && string.endsWith("]")) {
String unquoted=string.substring(1, string.length()-1);
if (unquoted.length()>=9 && unquoted.charAt(4)=='/' && unquoted.charAt(7)=='/') {
Date date = XMLHandler.stringToDate(unquoted);
String format = "yyyy/MM/dd HH:mm:ss.SSS";
if (date==null) {
try {
date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(unquoted);
format = "yyyy/MM/dd HH:mm:ss";
} catch(ParseException e1) {
try {
date = new SimpleDateFormat("yyyy/MM/dd").parse(unquoted);
format = "yyyy/MM/dd";
} catch (ParseException e2) {
date=null;
}
}
}
if (date!=null) {
ValueMetaInterface valueMeta = new ValueMeta("iif-date", ValueMetaInterface.TYPE_DATE);
valueMeta.setConversionMask(format);
return new ValueMetaAndData(valueMeta, date);
}
}
}
return null;
}