@Test public void testNegatedTrueFuncEvaluatesAsFalse() throws Exception { String left = "test_filed"; String right = "test_value"; int func = Condition.FUNC_TRUE; boolean negate = true; Condition condition = new Condition( negate, left, func, right, null ); assertFalse( condition.evaluate( new RowMeta(), new Object[]{ "test" } ) ); }
public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_valuename ); } if ( right_valuename != null && right_valuename.length() > 0 ) { right_fieldnr = rowMeta.indexOfValue( right_valuename ); } ValueMetaInterface fieldMeta = null; Object field = null; if ( left_fieldnr >= 0 ) { fieldMeta = rowMeta.getValueMeta( left_fieldnr ); field = r[left_fieldnr]; } else { return false; } ValueMetaInterface fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) { fieldMeta2 = rowMeta.getValueMeta( right_fieldnr ); field2 = r[right_fieldnr]; } switch ( function ) { case FUNC_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) == 0 ); break; case FUNC_NOT_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) != 0 ); break; case FUNC_SMALLER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) < 0 ); break; case FUNC_SMALLER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) <= 0 ); break; case FUNC_LARGER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) > 0 ); break; case FUNC_LARGER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) >= 0 ); break; case FUNC_REGEXP: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { retval = Pattern .matches( fieldMeta2.getCompatibleString( field2 ), fieldMeta.getCompatibleString( field ) ); } break; case FUNC_NULL: retval = ( fieldMeta.isNull( field ) ); break; case FUNC_NOT_NULL: retval = ( !fieldMeta.isNull( field ) ); break; case FUNC_IN_LIST: if ( inList == null || right_fieldnr >= 0 ) { inList = Const.splitString( fieldMeta2.getString( field2 ), ';', true ); for ( int i = 0; i < inList.length; i++ ) { inList[i] = inList[i] == null ? null : inList[i].replace( "\\", "" ); } Arrays.sort( inList ); } String searchString = fieldMeta.getCompatibleString( field ); int inIndex = -1; if ( searchString != null ) { inIndex = Arrays.binarySearch( inList, searchString ); } retval = Boolean.valueOf( inIndex >= 0 ); break; case FUNC_CONTAINS: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta.getCompatibleString( field ).indexOf( fieldMeta2.getCompatibleString( field2 ) ) >= 0 : false; break; case FUNC_STARTS_WITH: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta .getCompatibleString( field ).startsWith( fieldMeta2.getCompatibleString( field2 ) ) : false; break; case FUNC_ENDS_WITH: String string = fieldMeta.getCompatibleString( field ); if ( !Utils.isEmpty( string ) ) { if ( right_string == null && field2 != null ) { right_string = fieldMeta2.getCompatibleString( field2 ); } if ( right_string != null ) { retval = string.endsWith( fieldMeta2.getCompatibleString( field2 ) ); } else { retval = false; } } else { retval = false; } break; case FUNC_LIKE: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { String regex = fieldMeta2.getCompatibleString( field2 ); regex = regex.replace( "%", ".*" ); regex = regex.replace( "?", "." ); retval = Pattern.matches( regex, fieldMeta.getCompatibleString( field ) ); } break; default: break; } if ( isNegated() ) { retval = !retval; } } else { Condition cb0 = list.get( 0 ); retval = cb0.evaluate( rowMeta, r ); for ( int i = 1; i < list.size(); i++ ) { Condition cb = list.get( i ); switch ( cb.getOperator() ) { case Condition.OPERATOR_OR: retval = retval || cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_AND: retval = retval && cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_OR_NOT: retval = retval || ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_AND_NOT: retval = retval && ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_XOR: retval = retval ^ cb.evaluate( rowMeta, r ); break; default: break; } } if ( isNegated() ) { retval = !retval; } } } catch ( Exception e ) { throw new RuntimeException( "Unexpected error evaluation condition [" + toString() + "]", e ); } return retval; }
Condition implements Cloneable, XMLInterface { public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_valuename ); } if ( right_valuename != null && right_valuename.length() > 0 ) { right_fieldnr = rowMeta.indexOfValue( right_valuename ); } ValueMetaInterface fieldMeta = null; Object field = null; if ( left_fieldnr >= 0 ) { fieldMeta = rowMeta.getValueMeta( left_fieldnr ); field = r[left_fieldnr]; } else { return false; } ValueMetaInterface fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) { fieldMeta2 = rowMeta.getValueMeta( right_fieldnr ); field2 = r[right_fieldnr]; } switch ( function ) { case FUNC_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) == 0 ); break; case FUNC_NOT_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) != 0 ); break; case FUNC_SMALLER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) < 0 ); break; case FUNC_SMALLER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) <= 0 ); break; case FUNC_LARGER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) > 0 ); break; case FUNC_LARGER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) >= 0 ); break; case FUNC_REGEXP: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { retval = Pattern .matches( fieldMeta2.getCompatibleString( field2 ), fieldMeta.getCompatibleString( field ) ); } break; case FUNC_NULL: retval = ( fieldMeta.isNull( field ) ); break; case FUNC_NOT_NULL: retval = ( !fieldMeta.isNull( field ) ); break; case FUNC_IN_LIST: if ( inList == null || right_fieldnr >= 0 ) { inList = Const.splitString( fieldMeta2.getString( field2 ), ';', true ); for ( int i = 0; i < inList.length; i++ ) { inList[i] = inList[i] == null ? null : inList[i].replace( "\\", "" ); } Arrays.sort( inList ); } String searchString = fieldMeta.getCompatibleString( field ); int inIndex = -1; if ( searchString != null ) { inIndex = Arrays.binarySearch( inList, searchString ); } retval = Boolean.valueOf( inIndex >= 0 ); break; case FUNC_CONTAINS: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta.getCompatibleString( field ).indexOf( fieldMeta2.getCompatibleString( field2 ) ) >= 0 : false; break; case FUNC_STARTS_WITH: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta .getCompatibleString( field ).startsWith( fieldMeta2.getCompatibleString( field2 ) ) : false; break; case FUNC_ENDS_WITH: String string = fieldMeta.getCompatibleString( field ); if ( !Utils.isEmpty( string ) ) { if ( right_string == null && field2 != null ) { right_string = fieldMeta2.getCompatibleString( field2 ); } if ( right_string != null ) { retval = string.endsWith( fieldMeta2.getCompatibleString( field2 ) ); } else { retval = false; } } else { retval = false; } break; case FUNC_LIKE: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { String regex = fieldMeta2.getCompatibleString( field2 ); regex = regex.replace( "%", ".*" ); regex = regex.replace( "?", "." ); retval = Pattern.matches( regex, fieldMeta.getCompatibleString( field ) ); } break; default: break; } if ( isNegated() ) { retval = !retval; } } else { Condition cb0 = list.get( 0 ); retval = cb0.evaluate( rowMeta, r ); for ( int i = 1; i < list.size(); i++ ) { Condition cb = list.get( i ); switch ( cb.getOperator() ) { case Condition.OPERATOR_OR: retval = retval || cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_AND: retval = retval && cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_OR_NOT: retval = retval || ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_AND_NOT: retval = retval && ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_XOR: retval = retval ^ cb.evaluate( rowMeta, r ); break; default: break; } } if ( isNegated() ) { retval = !retval; } } } catch ( Exception e ) { throw new RuntimeException( "Unexpected error evaluation condition [" + toString() + "]", e ); } return retval; } }
Condition implements Cloneable, XMLInterface { public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_valuename ); } if ( right_valuename != null && right_valuename.length() > 0 ) { right_fieldnr = rowMeta.indexOfValue( right_valuename ); } ValueMetaInterface fieldMeta = null; Object field = null; if ( left_fieldnr >= 0 ) { fieldMeta = rowMeta.getValueMeta( left_fieldnr ); field = r[left_fieldnr]; } else { return false; } ValueMetaInterface fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) { fieldMeta2 = rowMeta.getValueMeta( right_fieldnr ); field2 = r[right_fieldnr]; } switch ( function ) { case FUNC_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) == 0 ); break; case FUNC_NOT_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) != 0 ); break; case FUNC_SMALLER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) < 0 ); break; case FUNC_SMALLER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) <= 0 ); break; case FUNC_LARGER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) > 0 ); break; case FUNC_LARGER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) >= 0 ); break; case FUNC_REGEXP: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { retval = Pattern .matches( fieldMeta2.getCompatibleString( field2 ), fieldMeta.getCompatibleString( field ) ); } break; case FUNC_NULL: retval = ( fieldMeta.isNull( field ) ); break; case FUNC_NOT_NULL: retval = ( !fieldMeta.isNull( field ) ); break; case FUNC_IN_LIST: if ( inList == null || right_fieldnr >= 0 ) { inList = Const.splitString( fieldMeta2.getString( field2 ), ';', true ); for ( int i = 0; i < inList.length; i++ ) { inList[i] = inList[i] == null ? null : inList[i].replace( "\\", "" ); } Arrays.sort( inList ); } String searchString = fieldMeta.getCompatibleString( field ); int inIndex = -1; if ( searchString != null ) { inIndex = Arrays.binarySearch( inList, searchString ); } retval = Boolean.valueOf( inIndex >= 0 ); break; case FUNC_CONTAINS: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta.getCompatibleString( field ).indexOf( fieldMeta2.getCompatibleString( field2 ) ) >= 0 : false; break; case FUNC_STARTS_WITH: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta .getCompatibleString( field ).startsWith( fieldMeta2.getCompatibleString( field2 ) ) : false; break; case FUNC_ENDS_WITH: String string = fieldMeta.getCompatibleString( field ); if ( !Utils.isEmpty( string ) ) { if ( right_string == null && field2 != null ) { right_string = fieldMeta2.getCompatibleString( field2 ); } if ( right_string != null ) { retval = string.endsWith( fieldMeta2.getCompatibleString( field2 ) ); } else { retval = false; } } else { retval = false; } break; case FUNC_LIKE: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { String regex = fieldMeta2.getCompatibleString( field2 ); regex = regex.replace( "%", ".*" ); regex = regex.replace( "?", "." ); retval = Pattern.matches( regex, fieldMeta.getCompatibleString( field ) ); } break; default: break; } if ( isNegated() ) { retval = !retval; } } else { Condition cb0 = list.get( 0 ); retval = cb0.evaluate( rowMeta, r ); for ( int i = 1; i < list.size(); i++ ) { Condition cb = list.get( i ); switch ( cb.getOperator() ) { case Condition.OPERATOR_OR: retval = retval || cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_AND: retval = retval && cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_OR_NOT: retval = retval || ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_AND_NOT: retval = retval && ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_XOR: retval = retval ^ cb.evaluate( rowMeta, r ); break; default: break; } } if ( isNegated() ) { retval = !retval; } } } catch ( Exception e ) { throw new RuntimeException( "Unexpected error evaluation condition [" + toString() + "]", e ); } return retval; } Condition();  Condition( String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( int operator, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( String xml );  Condition( Node condnode ); }
Condition implements Cloneable, XMLInterface { public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_valuename ); } if ( right_valuename != null && right_valuename.length() > 0 ) { right_fieldnr = rowMeta.indexOfValue( right_valuename ); } ValueMetaInterface fieldMeta = null; Object field = null; if ( left_fieldnr >= 0 ) { fieldMeta = rowMeta.getValueMeta( left_fieldnr ); field = r[left_fieldnr]; } else { return false; } ValueMetaInterface fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) { fieldMeta2 = rowMeta.getValueMeta( right_fieldnr ); field2 = r[right_fieldnr]; } switch ( function ) { case FUNC_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) == 0 ); break; case FUNC_NOT_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) != 0 ); break; case FUNC_SMALLER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) < 0 ); break; case FUNC_SMALLER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) <= 0 ); break; case FUNC_LARGER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) > 0 ); break; case FUNC_LARGER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) >= 0 ); break; case FUNC_REGEXP: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { retval = Pattern .matches( fieldMeta2.getCompatibleString( field2 ), fieldMeta.getCompatibleString( field ) ); } break; case FUNC_NULL: retval = ( fieldMeta.isNull( field ) ); break; case FUNC_NOT_NULL: retval = ( !fieldMeta.isNull( field ) ); break; case FUNC_IN_LIST: if ( inList == null || right_fieldnr >= 0 ) { inList = Const.splitString( fieldMeta2.getString( field2 ), ';', true ); for ( int i = 0; i < inList.length; i++ ) { inList[i] = inList[i] == null ? null : inList[i].replace( "\\", "" ); } Arrays.sort( inList ); } String searchString = fieldMeta.getCompatibleString( field ); int inIndex = -1; if ( searchString != null ) { inIndex = Arrays.binarySearch( inList, searchString ); } retval = Boolean.valueOf( inIndex >= 0 ); break; case FUNC_CONTAINS: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta.getCompatibleString( field ).indexOf( fieldMeta2.getCompatibleString( field2 ) ) >= 0 : false; break; case FUNC_STARTS_WITH: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta .getCompatibleString( field ).startsWith( fieldMeta2.getCompatibleString( field2 ) ) : false; break; case FUNC_ENDS_WITH: String string = fieldMeta.getCompatibleString( field ); if ( !Utils.isEmpty( string ) ) { if ( right_string == null && field2 != null ) { right_string = fieldMeta2.getCompatibleString( field2 ); } if ( right_string != null ) { retval = string.endsWith( fieldMeta2.getCompatibleString( field2 ) ); } else { retval = false; } } else { retval = false; } break; case FUNC_LIKE: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { String regex = fieldMeta2.getCompatibleString( field2 ); regex = regex.replace( "%", ".*" ); regex = regex.replace( "?", "." ); retval = Pattern.matches( regex, fieldMeta.getCompatibleString( field ) ); } break; default: break; } if ( isNegated() ) { retval = !retval; } } else { Condition cb0 = list.get( 0 ); retval = cb0.evaluate( rowMeta, r ); for ( int i = 1; i < list.size(); i++ ) { Condition cb = list.get( i ); switch ( cb.getOperator() ) { case Condition.OPERATOR_OR: retval = retval || cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_AND: retval = retval && cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_OR_NOT: retval = retval || ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_AND_NOT: retval = retval && ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_XOR: retval = retval ^ cb.evaluate( rowMeta, r ); break; default: break; } } if ( isNegated() ) { retval = !retval; } } } catch ( Exception e ) { throw new RuntimeException( "Unexpected error evaluation condition [" + toString() + "]", e ); } return retval; } Condition();  Condition( String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( int operator, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( String xml );  Condition( Node condnode ); ObjectId getObjectId(); void setObjectId( ObjectId id ); @Override Object clone(); void setOperator( int operator ); int getOperator(); String getOperatorDesc(); static final int getOperator( String description ); static final String[] getOperators(); static final String[] getRealOperators(); void setLeftValuename( String left_valuename ); String getLeftValuename(); int getFunction(); void setFunction( int function ); String getFunctionDesc(); static final int getFunction( String description ); void setRightValuename( String right_valuename ); String getRightValuename(); void setRightExact( ValueMetaAndData right_exact ); ValueMetaAndData getRightExact(); String getRightExactString(); ObjectId getRightExactID(); void setRightExactID( ObjectId id_right_exact ); boolean isAtomic(); boolean isComposite(); boolean isNegated(); void setNegated( boolean negate ); void negate(); boolean isEmpty(); void clearFieldPositions(); boolean evaluate( RowMetaInterface rowMeta, Object[] r ); void addCondition( Condition cb ); void addCondition( int idx, Condition cb ); void removeCondition( int nr ); boolean simplify(); int nrConditions(); Condition getCondition( int i ); void setCondition( int i, Condition subCondition ); @Override String toString(); String toString( int level, boolean show_negate, boolean show_operator ); @Override String getXML(); String getXML( int level ); String[] getUsedFields(); void getUsedFields( Hashtable<String, String> fields ); List<Condition> getChildren(); }
Condition implements Cloneable, XMLInterface { public boolean evaluate( RowMetaInterface rowMeta, Object[] r ) { boolean retval = false; try { if ( isAtomic() ) { if ( function == FUNC_TRUE ) { return !negate; } if ( left_valuename != null && left_valuename.length() > 0 ) { left_fieldnr = rowMeta.indexOfValue( left_valuename ); } if ( right_valuename != null && right_valuename.length() > 0 ) { right_fieldnr = rowMeta.indexOfValue( right_valuename ); } ValueMetaInterface fieldMeta = null; Object field = null; if ( left_fieldnr >= 0 ) { fieldMeta = rowMeta.getValueMeta( left_fieldnr ); field = r[left_fieldnr]; } else { return false; } ValueMetaInterface fieldMeta2 = right_exact != null ? right_exact.getValueMeta() : null; Object field2 = right_exact != null ? right_exact.getValueData() : null; if ( field2 == null && right_fieldnr >= 0 ) { fieldMeta2 = rowMeta.getValueMeta( right_fieldnr ); field2 = r[right_fieldnr]; } switch ( function ) { case FUNC_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) == 0 ); break; case FUNC_NOT_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) != 0 ); break; case FUNC_SMALLER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) < 0 ); break; case FUNC_SMALLER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) <= 0 ); break; case FUNC_LARGER: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) > 0 ); break; case FUNC_LARGER_EQUAL: retval = ( fieldMeta.compare( field, fieldMeta2, field2 ) >= 0 ); break; case FUNC_REGEXP: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { retval = Pattern .matches( fieldMeta2.getCompatibleString( field2 ), fieldMeta.getCompatibleString( field ) ); } break; case FUNC_NULL: retval = ( fieldMeta.isNull( field ) ); break; case FUNC_NOT_NULL: retval = ( !fieldMeta.isNull( field ) ); break; case FUNC_IN_LIST: if ( inList == null || right_fieldnr >= 0 ) { inList = Const.splitString( fieldMeta2.getString( field2 ), ';', true ); for ( int i = 0; i < inList.length; i++ ) { inList[i] = inList[i] == null ? null : inList[i].replace( "\\", "" ); } Arrays.sort( inList ); } String searchString = fieldMeta.getCompatibleString( field ); int inIndex = -1; if ( searchString != null ) { inIndex = Arrays.binarySearch( inList, searchString ); } retval = Boolean.valueOf( inIndex >= 0 ); break; case FUNC_CONTAINS: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta.getCompatibleString( field ).indexOf( fieldMeta2.getCompatibleString( field2 ) ) >= 0 : false; break; case FUNC_STARTS_WITH: retval = fieldMeta.getCompatibleString( field ) != null ? fieldMeta .getCompatibleString( field ).startsWith( fieldMeta2.getCompatibleString( field2 ) ) : false; break; case FUNC_ENDS_WITH: String string = fieldMeta.getCompatibleString( field ); if ( !Utils.isEmpty( string ) ) { if ( right_string == null && field2 != null ) { right_string = fieldMeta2.getCompatibleString( field2 ); } if ( right_string != null ) { retval = string.endsWith( fieldMeta2.getCompatibleString( field2 ) ); } else { retval = false; } } else { retval = false; } break; case FUNC_LIKE: if ( fieldMeta.isNull( field ) || field2 == null ) { retval = false; } else { String regex = fieldMeta2.getCompatibleString( field2 ); regex = regex.replace( "%", ".*" ); regex = regex.replace( "?", "." ); retval = Pattern.matches( regex, fieldMeta.getCompatibleString( field ) ); } break; default: break; } if ( isNegated() ) { retval = !retval; } } else { Condition cb0 = list.get( 0 ); retval = cb0.evaluate( rowMeta, r ); for ( int i = 1; i < list.size(); i++ ) { Condition cb = list.get( i ); switch ( cb.getOperator() ) { case Condition.OPERATOR_OR: retval = retval || cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_AND: retval = retval && cb.evaluate( rowMeta, r ); break; case Condition.OPERATOR_OR_NOT: retval = retval || ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_AND_NOT: retval = retval && ( !cb.evaluate( rowMeta, r ) ); break; case Condition.OPERATOR_XOR: retval = retval ^ cb.evaluate( rowMeta, r ); break; default: break; } } if ( isNegated() ) { retval = !retval; } } } catch ( Exception e ) { throw new RuntimeException( "Unexpected error evaluation condition [" + toString() + "]", e ); } return retval; } Condition();  Condition( String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( int operator, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact );  Condition( String xml );  Condition( Node condnode ); ObjectId getObjectId(); void setObjectId( ObjectId id ); @Override Object clone(); void setOperator( int operator ); int getOperator(); String getOperatorDesc(); static final int getOperator( String description ); static final String[] getOperators(); static final String[] getRealOperators(); void setLeftValuename( String left_valuename ); String getLeftValuename(); int getFunction(); void setFunction( int function ); String getFunctionDesc(); static final int getFunction( String description ); void setRightValuename( String right_valuename ); String getRightValuename(); void setRightExact( ValueMetaAndData right_exact ); ValueMetaAndData getRightExact(); String getRightExactString(); ObjectId getRightExactID(); void setRightExactID( ObjectId id_right_exact ); boolean isAtomic(); boolean isComposite(); boolean isNegated(); void setNegated( boolean negate ); void negate(); boolean isEmpty(); void clearFieldPositions(); boolean evaluate( RowMetaInterface rowMeta, Object[] r ); void addCondition( Condition cb ); void addCondition( int idx, Condition cb ); void removeCondition( int nr ); boolean simplify(); int nrConditions(); Condition getCondition( int i ); void setCondition( int i, Condition subCondition ); @Override String toString(); String toString( int level, boolean show_negate, boolean show_operator ); @Override String getXML(); String getXML( int level ); String[] getUsedFields(); void getUsedFields( Hashtable<String, String> fields ); List<Condition> getChildren(); static final String XML_TAG; static final String[] operators; static final int OPERATOR_NONE; static final int OPERATOR_OR; static final int OPERATOR_AND; static final int OPERATOR_NOT; static final int OPERATOR_OR_NOT; static final int OPERATOR_AND_NOT; static final int OPERATOR_XOR; static final String[] functions; static final int FUNC_EQUAL; static final int FUNC_NOT_EQUAL; static final int FUNC_SMALLER; static final int FUNC_SMALLER_EQUAL; static final int FUNC_LARGER; static final int FUNC_LARGER_EQUAL; static final int FUNC_REGEXP; static final int FUNC_NULL; static final int FUNC_NOT_NULL; static final int FUNC_IN_LIST; static final int FUNC_CONTAINS; static final int FUNC_STARTS_WITH; static final int FUNC_ENDS_WITH; static final int FUNC_LIKE; static final int FUNC_TRUE; }