生活随笔
收集整理的這篇文章主要介紹了
Kettle调用Java类
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.新建Java測試類,導(dǎo)出Jar包,放在kettle目錄中的libext文件中
package?test;?public?class?Test{?????public?static?final?String?getMyName(String?name){?????????return?name+"12345";?????}?}
2.抽數(shù)據(jù)--經(jīng)過java處理--輸出文件到桌面
import?test.Test;??public?boolean?proce***ow(StepMetaInterface?smi,?StepDataInterface?sdi)?throws?KettleException?{?????Object[]?r?=?getRow();?????if?(r?==?null)?{?????????setOutputDone();?????????return?false;?????}??????if?(first)?????{?????????first?=?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,?outputRowSize);??????????/*?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);??????*/??????//調(diào)用jar?????String?foobar?=?get(Fields.In,?"ENAME").getString(r);?//輸入?yún)?shù)?????foobar?+=?Test.getMyName("我是誰的水");?????get(Fields.Out,?"ENAME").setValue(r,?foobar);???????????//獲取參數(shù)??????String?AGEField?=?getParameter("AGE");??????get(Fields.Out,?"AGE").setValue(r,?AGEField);?//輸出參數(shù)???????????//?Send?the?row?on?to?the?next?step.?????putRow(data.outputRowMeta,?r);??????return?true;?}? ?
轉(zhuǎn)載于:https://blog.51cto.com/programmer/1164002
總結(jié)
以上是生活随笔為你收集整理的Kettle调用Java类的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。