在kettle里调用的java组件代码报错。
//导入包
import java.util.regex.*;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
if (first) {
first = false;
/* TODO: Your code here. (Using info fields)
FieldHelper infoField = get(Fields.Info, "info_field_name");
RowSet infoStream = findInfoRowSet("info_stream_tag");
Object[] infoRow = null;
int infoRowCount = 0;
// Read all rows from info step before calling getRow() method, which returns first row from any
// input rowset. As rowMeta for info and input steps varies getRow() can lead to errors.
while((infoRow = getRowFrom(infoStream)) != null){
// do something with info data
infoRowCount++;
}
*/
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
// It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
// enough to handle any new fields you are creating in this step.
r = createOutputRow(r, data.outputRowMeta.size());
/* TODO: Your code here. (See Sample)
// Get the value from an input field
String foobar = get(Fields.In, "a_fieldname").getString(r);
foobar += "bar";
// Set a value in a new output field
get(Fields.Out, "output_fieldname").setValue(r, foobar);
*/
//获取电话集
String phone_set = get(Fields.In, "phone_set").getString(r);
//正则表达式获取手机号
if(phone_set == null || phone_set.length()<=0)
return null;
Pattern pattern = Pattern.compile("(1|861)([0-9])\\d{9}$*");
Matcher matcher = pattern.matcher(phone_set);
StringBuffer bf = new StringBuffer();
while (matcher.find()) {
bf.append(matcher.group()).append(",");
}
int len = bf.length();
if (len > 0) {
bf.deleteCharAt(len - 1);
}
return bf.toString();
//输出
get(Fields.Out, "newphone").setValue(r,phone_set);
// Send the row on to the next step.
putRow(data.outputRowMeta, r);
return true;
}
报错内容为:第54行,第9列 -- if(phone_set == null || phone_set.length()<=0)
assignment conversion not possible from type "void" to type "boolean"
请问这个脚本问题点在哪,正确的提取手机号脚本如何编写?