@Override public boolean equals( Object v ) { if ( compare( (Value) v ) == 0 ) { return true; } else { return false; } }
/** * Compare 2 values of the same or different type! The comparison of Strings is case insensitive * * @param v * the value to compare with. * @return -1 if The value was smaller, 1 bigger and 0 if both values are equal. */ public int compare( Value v ) { return compare( v, true ); }
public Value smaller( Value v ) { if ( compare( v ) < 0 ) { setValue( true ); } else { setValue( false ); } return this; }
public Value different( Value v ) { if ( compare( v ) != 0 ) { setValue( true ); } else { setValue( false ); } return this; }
public Value equal( Value v ) { if ( compare( v ) == 0 ) { setValue( true ); } else { setValue( false ); } return this; }
public Value greater_equal( Value v ) { if ( compare( v ) >= 0 ) { setValue( true ); } else { setValue( false ); } return this; }
public Value smaller_equal( Value v ) { if ( compare( v ) <= 0 ) { setValue( true ); } else { setValue( false ); } return this; }
public Value greater( Value v ) { if ( compare( v ) > 0 ) { setValue( true ); } else { setValue( false ); } return this; }
/** * Compare 2 rows with each other using one value in the rows and also considering an ascending clause. * * @param r * The row to compare with * @param fieldnr * The indexe of the values to compare * @param sort_desc * true means and normal compare, false the reverse. * @return -1 if the row is smaller, 0 if they are equal and 1 if the row is larger. */ public int compare( Row r, int fieldnr, boolean sort_desc ) { int retval = 0; Value v1, v2; v1 = getValue( fieldnr ); v2 = r.getValue( fieldnr ); retval = v1.compare( v2 ); if ( sort_desc ) { retval = -retval; } return retval; }
/** * Compare 2 complete rows of values with each other * * @param r * the row to compare with * @return -1 if the row is smaller, 0 if both rows are equal, 1 if the row is larger. */ public int compare( Row r, boolean caseInsensitive ) { int retval = 0; int i; int len = r.size(); Value v1, v2; for ( i = 0; i < len; i++ ) { v1 = getValue( i ); v2 = r.getValue( i ); retval = v1.compare( v2, caseInsensitive ); if ( retval != 0 ) { return retval; } } return 0; }