[ http://nagoya.apache.org/jira/browse/IBATIS-30?page=history ]
Clinton Begin closed IBATIS-30:
-------------------------------
Resolution: Invalid
Sorry, but this is the way it's supposed to work, as per the JavaBeans
Specification.
Java Bean specification:
-------------
8.8 Capitalization of inferred names.
When we use design patterns to infer a property or event name, we need to
decide what rules
to follow for capitalizing the inferred name. If we extract the name from the
middle of a normal
mixedCase style Java name then the name will, by default, begin with a capital
letter.
Java programmers are accustomed to having normal identifiers start with lower
case letters.
Vigorous reviewer input has convinced us that we should follow this same
conventional rule
for property and event names.?JavaBeans Introspection
Thus when we extract a property or event name from the middle of an existing
Java name, we
normally convert the first character to lower case. However to support the
occasional use of all
upper-case names, we check if the first two characters of the name are both
upper case and if
so leave it alone. So for example,
?FooBah? becomes ?fooBah?
?Z? becomes ?z?
?URL? becomes ?URL?
We provide a method Introspector.decapitalize which implements this conversion
rule.
-------------
> A bug in the dropCase method of Classinfo.java causes problem for property
> that has an uppercase letter on the 2nd character
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: IBATIS-30
> URL: http://nagoya.apache.org/jira/browse/IBATIS-30
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.0.8
> Reporter: leo chan
> Assignee: Clinton Begin
>
> There is a bug in the following dropCase method of the Classinfo.java in
> com.ibatis.common.beans package. The line that conatins:
> !Character.isUpperCase(name.charAt(1)
> should be
> !Character.isUpperCase(name.charAt(0) instead.
> The code is trying to change the first character of the name to toLowerCase
> (not the second letter). Therefore, it should check the first character of
> the name which is indexed by 0 (not 1) and to see if it is lowerCase.
> Here is the section of the Classinfo.java that contains the bug:
> private static String dropCase(String name) {
> if (name.startsWith("is")) {
> name = name.substring(2);
> } else if (name.startsWith("get") || name.startsWith("set")) {
> name = name.substring(3);
> } else {
> throw new ProbeException("Error parsing property name '" + name + "'.
> Didn't start with 'is', 'get' or 'set'.");
> }
>
> if (name.length() == 1 || (name.length() > 1 &&
> !Character.isUpperCase(name.charAt(1)))) {
> name = name.substring(0, 1).toLowerCase(Locale.US) + name.substring(1);
> }
>
> return name;
> }
> This will cause a problem for property that has second letter as upper case
> letter. For example, if you have a property called "aRank". The getter and
> setter for that property will be getARank and setARank. The code will first
> extract the name as "ARank". Then it will check the second character instead
> of the first character and see if it is lowercase. If it is, it will not
> change the first character to lower case. So it will still be "ARank". So
> the problem will complain the if can't find the writable property called
> "aRank".
> This bug only found in 2.0. In 1.0, Classinfo.java doesn't contain the
> method called dropCase.
> Submitted by
> Leo Chan
> SRA International
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira