@Test public void testCompare() throws Exception { ValueMetaTimestamp vm = new ValueMetaTimestamp(); Timestamp earlier = Timestamp.valueOf( "2012-12-12 12:12:12.121212" ); Timestamp later = Timestamp.valueOf( "2013-12-12 12:12:12.121212" ); assertTrue( vm.isSortedAscending() ); assertFalse( vm.isSortedDescending() ); assertEquals( vm.compare( null, null ), 0 ); assertEquals( vm.compare( null, earlier ), -1 ); assertEquals( vm.compare( earlier, null ), 1 ); assertEquals( vm.compare( earlier, earlier ), 0 ); assertEquals( vm.compare( earlier, later ), -1 ); assertEquals( vm.compare( later, earlier ), 1 ); vm.setSortedDescending( true ); assertFalse( vm.isSortedAscending() ); assertTrue( vm.isSortedDescending() ); assertEquals( vm.compare( null, null ), 0 ); assertEquals( vm.compare( null, earlier ), 1 ); assertEquals( vm.compare( earlier, null ), -1 ); assertEquals( vm.compare( earlier, earlier ), 0 ); assertEquals( vm.compare( earlier, later ), 1 ); assertEquals( vm.compare( later, earlier ), -1 ); }
public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( timestamp2 == null ) { cmp = 1; } else { cmp = timestamp1.compareTo( timestamp2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } }
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( timestamp2 == null ) { cmp = 1; } else { cmp = timestamp1.compareTo( timestamp2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } }
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( timestamp2 == null ) { cmp = 1; } else { cmp = timestamp1.compareTo( timestamp2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); }
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( timestamp2 == null ) { cmp = 1; } else { cmp = timestamp1.compareTo( timestamp2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); @Override boolean isDate(); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); Timestamp getTimestamp( Object object ); int compare( Object data1, Object data2 ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); Timestamp convertDateToTimestamp( Date date ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object convertDataUsingConversionMetaData( Object data2 ); @Override byte[] getBinaryString( Object object ); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override synchronized SimpleDateFormat getDateFormat(); @Override String getFormatMask(); @Override Class<?> getNativeDataTypeClass(); }
ValueMetaTimestamp extends ValueMetaDate { public int compare( Object data1, Object data2 ) throws KettleValueException { Timestamp timestamp1 = getTimestamp( data1 ); Timestamp timestamp2 = getTimestamp( data2 ); int cmp = 0; if ( timestamp1 == null ) { if ( timestamp2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( timestamp2 == null ) { cmp = 1; } else { cmp = timestamp1.compareTo( timestamp2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaTimestamp();  ValueMetaTimestamp( String name ); @Override boolean isDate(); @Override Date getDate( Object object ); @Override Long getInteger( Object object ); @Override Double getNumber( Object object ); @Override BigDecimal getBigNumber( Object object ); @Override Boolean getBoolean( Object object ); @Override String getString( Object object ); Timestamp getTimestamp( Object object ); int compare( Object data1, Object data2 ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
      int trim_type ); Timestamp convertDateToTimestamp( Date date ); @Override Object convertData( ValueMetaInterface meta2, Object data2 ); @Override Object cloneValueData( Object object ); @Override ValueMetaInterface getValueFromSQLType( DatabaseMeta databaseMeta, String name, ResultSetMetaData rm,
      int index, boolean ignoreLength, boolean lazyConversion ); @Override Object getValueFromResultSet( DatabaseInterface databaseInterface, ResultSet resultSet, int index ); @Override void setPreparedStatementValue( DatabaseMeta databaseMeta, PreparedStatement preparedStatement, int index,
      Object data ); @Override Object convertDataUsingConversionMetaData( Object data2 ); @Override byte[] getBinaryString( Object object ); @Override void writeData( DataOutputStream outputStream, Object object ); @Override Object readData( DataInputStream inputStream ); @Override synchronized SimpleDateFormat getDateFormat(); @Override String getFormatMask(); @Override Class<?> getNativeDataTypeClass();  }