Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348620 - Two differents ways of normalization for propertyName
Summary: Two differents ways of normalization for propertyName
Status: NEW
Alias: None
Product: XWT
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-07 14:24 EDT by GILLES Hélios CLA
Modified: 2013-01-24 15:31 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description GILLES Hélios CLA 2011-06-07 14:24:37 EDT
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
Comment 1 GILLES Hélios CLA 2011-06-16 02:07:40 EDT
(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 ;)