commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 18942] - [beanutils] Add "t/f" to BooleanConverter
Date Fri, 04 Mar 2005 08:05:57 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=18942>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=18942





------- Additional Comments From mattias@expertsystem.se  2005-03-04 09:05 -------
(In reply to comment #16)
> Alternative implementation
> Here's an alternative patch for consideration. It doesn't have the flexibility
> of the original, but is much simpler and is very obviously thread-safe.

I think this is a good alternative. The uppercase mismatch problem could be 
prevented using something like this:

     public BooleanConverter(String[] trueStrings, String[] falseStrings) { 

        for(int i=0; i<trueStrings.length; ++i) {
          String trueString = trueStrings[i];
            if (! trueString.equals(trueString.toLowerCase())) // If not lower 
case
                throw new IllegalValueException(trueString);
        }

        for(int i=0; i<falseStrings.length; ++i) {
          String falseString = falseStrings[i];
            if (! falseString.equals(falseString.toLowerCase())) // If not 
lower case
                throw new IllegalValueException(falseString);
        }

        this.trueStrings = trueStrings;
        this.falseStrings = falseStrings;
        this.useDefault = false;

    }

    public BooleanConverter(String[] trueStrings, String[] falseStrings, 
                Object defaultValue) {

        this(trueStrings, falseStrings);
        this.defaultValue = defaultValue;
        this.useDefault = true;

    }


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message