X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fsrc%2Forg%2Fwamblee%2Fconditions%2FPropertyRegexCondition.java;h=60726dcc540b205f012e7baf79c3410bfbda1c63;hb=45954ad938187b0c16d18c763ccfd43a349cb862;hp=48df7995cd0222547b7a52a8c6dbb4acb6f843d0;hpb=5abc820d10495d559cac9aede0a62521659bced4;p=utils diff --git a/support/src/org/wamblee/conditions/PropertyRegexCondition.java b/support/src/org/wamblee/conditions/PropertyRegexCondition.java index 48df7995..60726dcc 100644 --- a/support/src/org/wamblee/conditions/PropertyRegexCondition.java +++ b/support/src/org/wamblee/conditions/PropertyRegexCondition.java @@ -38,14 +38,21 @@ public class PropertyRegexCondition implements Condition { */ private Pattern _regex; + /** + * Whether or not to convert the value to lowercase before matching. + */ + private boolean _tolower; + /** * Constructs the condition. * @param aProperty Name of the property to examine. * @param aRegex Regular expression to use. + * @param aTolower Whether or not to convert the value to lowercase before matching. */ - public PropertyRegexCondition(String aProperty, String aRegex) { + public PropertyRegexCondition(String aProperty, String aRegex, boolean aTolower) { _property = aProperty; _regex = Pattern.compile(aRegex); + _tolower = aTolower; } /* (non-Javadoc) @@ -54,6 +61,9 @@ public class PropertyRegexCondition implements Condition { public boolean matches(T aObject) { try { String value = PropertyUtils.getProperty(aObject, _property) + ""; + if ( _tolower ) { + value = value.toLowerCase(); + } Matcher matcher = _regex.matcher(value); return matcher.matches(); } catch (IllegalAccessException e) {