@Override public void evaluate(IFunctionHelper functionHelper) throws Exception { list.clear(); JRecord inputRecord = (JRecord) functionHelper.getArgument(0); JString id = (JString) inputRecord.getValueByName("id"); JString text = (JString) inputRecord.getValueByName("text"); String[] tokens = text.getValue().split(" "); for (String tk : tokens) { if (tk.startsWith("#")) { JString newField = (JString) functionHelper.getObject(JTypeTag.STRING); newField.setValue(tk); list.add(newField); } } JRecord result = (JRecord) functionHelper.getResultObject(); result.setField("id", id); result.setField("username", inputRecord.getValueByName("username")); result.setField("location", inputRecord.getValueByName("location")); result.setField("text", text); result.setField("timestamp", inputRecord.getValueByName("timestamp")); result.setField("topics", list); functionHelper.setResult(result); }
@Override public void initialize(IFunctionHelper functionHelper) { list = new JUnorderedList(functionHelper.getObject(JTypeTag.STRING)); }