@Test public void testCompare() throws UnknownHostException, KettleValueException { ValueMetaInternetAddress vm = new ValueMetaInternetAddress(); InetAddress smaller = InetAddress.getByName( "127.0.0.1" ); InetAddress larger = InetAddress.getByName( "127.0.1.1" ); assertTrue( vm.isSortedAscending() ); assertFalse( vm.isSortedDescending() ); assertEquals( 0, vm.compare( null, null ) ); assertEquals( -1, vm.compare( null, smaller ) ); assertEquals( 1, vm.compare( smaller, null ) ); assertEquals( 0, vm.compare( smaller, smaller ) ); assertEquals( -1, vm.compare( smaller, larger ) ); assertEquals( 1, vm.compare( larger, smaller ) ); vm.setSortedDescending( true ); assertFalse( vm.isSortedAscending() ); assertTrue( vm.isSortedDescending() ); assertEquals( 0, vm.compare( null, null ) ); assertEquals( 1, vm.compare( null, smaller ) ); assertEquals( -1, vm.compare( smaller, null ) ); assertEquals( 0, vm.compare( smaller, smaller ) ); assertEquals( 1, vm.compare( smaller, larger ) ); assertEquals( -1, vm.compare( larger, smaller ) ); }
@Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( inet2 == null ) { cmp = 1; } else { BigInteger bigint1 = new BigInteger( inet1.getAddress() ); BigInteger bigint2 = new BigInteger( inet2.getAddress() ); cmp = bigint1.compareTo( bigint2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } }
ValueMetaInternetAddress extends ValueMetaDate { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( inet2 == null ) { cmp = 1; } else { BigInteger bigint1 = new BigInteger( inet1.getAddress() ); BigInteger bigint2 = new BigInteger( inet2.getAddress() ); cmp = bigint1.compareTo( bigint2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } }
ValueMetaInternetAddress extends ValueMetaDate { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( inet2 == null ) { cmp = 1; } else { BigInteger bigint1 = new BigInteger( inet1.getAddress() ); BigInteger bigint2 = new BigInteger( inet2.getAddress() ); cmp = bigint1.compareTo( bigint2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); }
ValueMetaInternetAddress extends ValueMetaDate { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( inet2 == null ) { cmp = 1; } else { BigInteger bigint1 = new BigInteger( inet1.getAddress() ); BigInteger bigint2 = new BigInteger( inet2.getAddress() ); cmp = bigint1.compareTo( bigint2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); @Override int compare( Object data1, Object data2 ); InetAddress getInternetAddress( Object object ); @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 ); @Override byte[] getBinaryString( Object object ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
    int trim_type ); @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 String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
    boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass(); }
ValueMetaInternetAddress extends ValueMetaDate { @Override public int compare( Object data1, Object data2 ) throws KettleValueException { InetAddress inet1 = getInternetAddress( data1 ); InetAddress inet2 = getInternetAddress( data2 ); int cmp = 0; if ( inet1 == null ) { if ( inet2 == null ) { cmp = 0; } else { cmp = -1; } } else if ( inet2 == null ) { cmp = 1; } else { BigInteger bigint1 = new BigInteger( inet1.getAddress() ); BigInteger bigint2 = new BigInteger( inet2.getAddress() ); cmp = bigint1.compareTo( bigint2 ); } if ( isSortedDescending() ) { return -cmp; } else { return cmp; } } ValueMetaInternetAddress();  ValueMetaInternetAddress( String name ); @Override int compare( Object data1, Object data2 ); InetAddress getInternetAddress( Object object ); @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 ); @Override byte[] getBinaryString( Object object ); @Override Object convertDataFromString( String pol, ValueMetaInterface convertMeta, String nullIf, String ifNull,
    int trim_type ); @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 String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
    boolean use_autoinc, boolean add_fieldname, boolean add_cr ); @Override Class<?> getNativeDataTypeClass();  }