private String firstnameField ; //參數(shù) ?還可以使用getPreamter來獲得參數(shù)
private FieldHelper resultField = null;? //結(jié)果 需要在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;
}
//從上一個步驟獲得一行數(shù)據(jù)股缸。
//Object[] r =null;
//r = getRow();
//獲得一行數(shù)據(jù)里,某一個字段的值
//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); 來獲取上一個節(jié)點(diǎn)傳來的FIELD的值
firstnameField = get(Fields.In, "responseXml").getString(r); // 獲得上一個節(jié)點(diǎn)傳來的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]);
}
}
//把結(jié)果封裝?
resultField = get(Fields.Out, "tojsprocess");
resultField.setValue(r, sb.toString());
putRow(data.outputRowMeta, r);
return true;
}