Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Creating a List object in a Java script step

$
0
0
I'm modifying an example posted by Matt Casters on his blog here: http://www.ibridge.be/?p=273

In one of the transformations (Metadeta detector - Parser) there is a Java script step that includes the following code:

Code:

if (evaluators==null) {
  evaluators = new java.util.ArrayList();
  for (i=0;i<getInputRowMeta().size();i++) {
    var evaluator = new org.pentaho.di.core.util.StringEvaluator(true);
    evaluators.add(evaluator);   
  }
}

The line declaring
Code:

new org.pentaho.di.core.util.StringEvaluator(true)
is what I'm concerned with. As you can see from the docs (http://javadoc.pentaho.com/kettle/or...ava.util.List) there are two ways to instantiate a StringEvaluator. This code uses the first way but I'd like to use the second way where I can specify additional parameters for the number formats and date formats. Those additional parameters are both supposed to be of type List<String>.

I have very little experience with Java and I cannot for the life of me figure out how to create a List<String>, which I assume should be pretty easy to do! I've looked on the web for the way you're supposed to do this and everything I've tried has either prevented the script from compiling or caused a runtime error. Just trying to figure out the correct way to essentially do the following:

var numberFormats = liststring("#","#.#"); //psuedocode
var dateFormats =liststring("mm/dd/yyyy","yyyy-mm-dd"); //psuedocode
var evaluator = new org.pentaho.di.core.util.StringEvaluator(true, numberFormats, dateFormats);

Thanks!

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>