Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.net.URLEncoder;
- import java.nio.charset.StandardCharsets;
- import java.io.*;
- String encodedValue;
- 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;
- }
- // 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.
- //
- Object[] outputRow = createOutputRow(r, data.outputRowMeta.size());
- String newFileName = get(Fields.In,"to_be_encoded_path").getString(r);
- try{
- encodedValue = URLEncoder.encode(newFileName, "UTF-8");
- }
- catch (UnsupportedEncodingException e) {
- throw new AssertionError("UTF-8 is unknown");
- }
- // Set the value in the output field
- //
- get(Fields.Out, "encodedFileName").setValue(outputRow, encodedValue);
- // putRow will send the row on to the default output hop.
- //
- putRow(data.outputRowMeta, outputRow);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement