Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.net.URLEncoder;
  2. import java.nio.charset.StandardCharsets;
  3. import java.io.*;
  4.  
  5. String encodedValue;
  6. public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  7. {
  8. // First, get a row from the default input hop
  9. //
  10. Object[] r = getRow();
  11.  
  12. // If the row object is null, we are done processing.
  13. //
  14. if (r == null) {
  15. setOutputDone();
  16. return false;
  17. }
  18.  
  19. // It is always safest to call createOutputRow() to ensure that your output row's Object[] is large
  20. // enough to handle any new fields you are creating in this step.
  21. //
  22. Object[] outputRow = createOutputRow(r, data.outputRowMeta.size());
  23.  
  24. String newFileName = get(Fields.In,"to_be_encoded_path").getString(r);
  25.  
  26. try{
  27. encodedValue = URLEncoder.encode(newFileName, "UTF-8");
  28. }
  29. catch (UnsupportedEncodingException e) {
  30. throw new AssertionError("UTF-8 is unknown");
  31. }
  32. // Set the value in the output field
  33. //
  34. get(Fields.Out, "encodedFileName").setValue(outputRow, encodedValue);
  35.  
  36. // putRow will send the row on to the default output hop.
  37. //
  38. putRow(data.outputRowMeta, outputRow);
  39.  
  40. return true;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement