ValueMetaResolver { public Object[] inListToTypedObjectArray( String fieldName, String value ) throws PushDownOptimizationException { String[] inList = Const.splitString( value, ';', true ); unescapeList( inList ); ValueMetaInterface valueMeta = getValueMeta( fieldName ); if ( valueMeta.isString() ) { return inList; } return convertArrayToType( inList, valueMeta ); } ValueMetaResolver( RowMetaInterface rowMeta ); RowMetaInterface getRowMeta(); ValueMetaInterface getValueMeta( String fieldName ); Object getTypedValue( String fieldName, int originalType, Object value ); Object[] inListToTypedObjectArray( String fieldName, String value );  }
@Test public void inListOfStringsResolveToStringArray() throws KettleException { ValueMetaResolver resolver = new ValueMetaResolver( getTestRowMeta( ValueMetaInterface.TYPE_STRING ) ); Object[] values = resolver.inListToTypedObjectArray( "field", "f\\;oo;bar;baz" ); assertThat( values, equalTo( new Object[]{"f;oo", "bar", "baz"} ) ); }
@Test public void inListOfStringsResolveToDateArray() throws KettleException { ValueMetaResolver resolver = new ValueMetaResolver( getTestRowMeta( ValueMetaInterface.TYPE_DATE ) ); Object[] values = resolver.inListToTypedObjectArray( "field", "1997-04-12;2001-01-01;2008-9-04" ); String[] expected = new String[]{"1997-04-12", "2001-01-01", "2008-09-04"}; for ( int i = 0; i < values.length; i++ ) { assertEquals( expected[ i ], new SimpleDateFormat( "yyyy-MM-dd" ).format( values[i] ) ); } }