public static int dimensionFromConstraint ( String constraint , String columnName ) { Matcher matcher = Z_CONSTRAINT_PATTERN . matcher ( constraint ) ; if ( matcher . find ( ) ) { String extractedColumnName = matcher . group ( 1 ) . replace ( "\"" , "" ) . replace ( "`" , "" ) ; if ( extractedColumnName . equalsIgnoreCase ( columnName ) ) { int constraint_value = Integer . valueOf ( matcher . group ( 8 ) ) ; String sign = matcher . group ( 5 ) ; if ( "<>" . equals ( sign ) || "!=" . equals ( sign ) ) { constraint_value = constraint_value == 3 ? 2 : 3 ; } if ( "<" . equals ( sign ) ) { constraint_value = 2 ; } if ( ">" . equals ( sign ) ) { constraint_value = constraint_value == 2 ? 3 : 2 ; } return constraint_value ; } } return 2 ; }
Public for Unit test