| Summary: | Two differents ways of normalization for propertyName | ||
|---|---|---|---|
| Product: | [Technology] XWT | Reporter: | GILLES Hélios <helios.gilles> |
| Component: | Core | Assignee: | Project Inbox <e4.xwt-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
(In reply to comment #0) > Build Identifier: M20110210-1200 > > Normalization method in java.beans.Introspector : > > /** > * Utility method to take a string and convert it to normal Java variable > * name capitalization. This normally means converting the first > * character from upper case to lower case, but in the (unusual) special > * case when there is more than one character and both the first and > * second characters are upper case, we leave it alone. > * <p> > * Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays > * as "URL". > * > * @param name The string to be decapitalized. > * @return The decapitalized version of the string. > */ > public static String decapitalize(String name) { > if (name == null || name.length() == 0) { > return name; > } > if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) && > Character.isUpperCase(name.charAt(0))){ > return name; > } > char chars[] = name.toCharArray(); > chars[0] = Character.toLowerCase(chars[0]); > return new String(chars); > } > > Normalization method in ModelUtils in XWT : > > public class ModelUtils { > public static String normalizeEventName(String name) { > return name.toLowerCase(); > } > > public static String normalizePropertyName(String name) { > if (name == null || name.length() == 0) { > return name; > } > char c = name.charAt(0); > if (Character.isLowerCase(c)) { > return name; > } > return Character.toLowerCase(name.charAt(0)) + name.substring(1); > } > } > > For instance if one of the method in my objects is called getTOTO(), the > java.beans.Introspector will return a propertyName "TOTO" when the XWT > ModelUtils will return "tOTO" and as it's an "equal" who does the comparaison > ,we've got a problem here. > > > Reproducible: Always Sorry guys but could i get only a little acknowledgment because i posted a topic on the forum and i have no answers like here and i starting to think that i'm the only man left in the world ;) |
Build Identifier: M20110210-1200 Normalization method in java.beans.Introspector : /** * Utility method to take a string and convert it to normal Java variable * name capitalization. This normally means converting the first * character from upper case to lower case, but in the (unusual) special * case when there is more than one character and both the first and * second characters are upper case, we leave it alone. * <p> * Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays * as "URL". * * @param name The string to be decapitalized. * @return The decapitalized version of the string. */ public static String decapitalize(String name) { if (name == null || name.length() == 0) { return name; } if (name.length() > 1 && Character.isUpperCase(name.charAt(1)) && Character.isUpperCase(name.charAt(0))){ return name; } char chars[] = name.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); } Normalization method in ModelUtils in XWT : public class ModelUtils { public static String normalizeEventName(String name) { return name.toLowerCase(); } public static String normalizePropertyName(String name) { if (name == null || name.length() == 0) { return name; } char c = name.charAt(0); if (Character.isLowerCase(c)) { return name; } return Character.toLowerCase(name.charAt(0)) + name.substring(1); } } For instance if one of the method in my objects is called getTOTO(), the java.beans.Introspector will return a propertyName "TOTO" when the XWT ModelUtils will return "tOTO" and as it's an "equal" who does the comparaison ,we've got a problem here. Reproducible: Always