Ensure uid3 is lowercase in templates.
authorEd Swartz <ed.swartz@nokia.com>
Wed, 02 Dec 2009 14:33:28 -0600
changeset 606 f8c3b14b4f6b
parent 605 b428e782ad22
child 607 5d59ce9f9035
Ensure uid3 is lowercase in templates. Also fix some bugs related to validating UID3. If the user enters a non-0x prefixed string, this is not always detected, and a UID3 range check warning indicates a different string was parsed (dropping the first two chars as if 0x was there).
core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/TemplateWizardPage.java
core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/UIDComposite.java
--- a/core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/TemplateWizardPage.java	Wed Dec 02 13:49:43 2009 -0600
+++ b/core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/TemplateWizardPage.java	Wed Dec 02 14:33:28 2009 -0600
@@ -117,9 +117,10 @@
 			values.put(type.getId(), value);
 			
 			if (type instanceof UidFieldType) {
+				values.put(type.getId(), value.toLowerCase());
 				// least hacky way to support this without creating a language out of templates
 				values.put(type.getId() + UIDComposite.WITHOUT_0X_PREFIX, 
-						UIDComposite.getWithout0x(value));
+						UIDComposite.getWithout0x(value).toLowerCase());
 			}
 
 		}
@@ -284,7 +285,10 @@
 		
 		@Override
 		public String getValue() {
-			return UIDComposite.makeCanonicalHexString(super.getValue().trim());
+			String value = super.getValue().trim();
+			if (!UIDComposite.isValidHexString(value))
+				return value;
+			return UIDComposite.makeCanonicalHexString(value);
 		}
 		
 		@Override
--- a/core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/UIDComposite.java	Wed Dec 02 13:49:43 2009 -0600
+++ b/core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/internal/api/templatewizard/ui/UIDComposite.java	Wed Dec 02 14:33:28 2009 -0600
@@ -163,7 +163,9 @@
 	}
 	
 	public static String getWithout0x(String with0x) {
-		Check.checkContract(with0x.startsWith(HEX_PREFIX));
+		// may not be valid...
+		if (!with0x.startsWith(HEX_PREFIX))
+			return with0x;
 		return with0x.substring(HEX_PREFIX.length());
 	}