kettle for java class

private String firstnameField ; //参数  还可以使用getPreamter来获得参数

private FieldHelper resultField = null;  //结果 需要在field里配置

public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException{    

// First, get a row from the default input hop

Object[] r = getRow();    

// If the row object is null, we are done processing.//

if (r == null) {

setOutputDone();

return false;

}

//从上一个步骤获得一行数据。

//Object[] r =null;

//r = getRow();

//获得一行数据里,某一个字段的值

//String fieldname =“MyOldField”;

//indexOfValue速度很慢,可以在param中定死列名,到时候取一次就可以了。见例子STAX TEST2中

//int fieldIndex = this.getInputRowMeta().indexOfValue(fieldName);

//Object value = r[fieldIndex];

//可以使用 firstnameField = getParameter("FIRSTNAME_FIELD"); 来获取FIELD的名字,并使用firstnameField = get(Fields.In, firstnameField).getString(r); 来获取上一个节点传来的FIELD的值

firstnameField = get(Fields.In, "responseXml").getString(r); // 获得上一个节点传来的FIELD的值

r = createOutputRow(r, data.outputRowMeta.size());

StringBuilder sb = new StringBuilder();       

   char[] chs = firstnameField.toCharArray();     

     //System.out.println("filter before=" +chs.length);  

        for (int i=0;i= 0x00 && chs[i] <= 0x08) {

//eat...

} else {

sb.append(chs[i]);

}

}

//把结果封装 

resultField = get(Fields.Out, "tojsprocess");

resultField.setValue(r, sb.toString());

putRow(data.outputRowMeta, r);

return true;

}

你可能感兴趣的:(kettle for java class)