2002/css-validator/org/w3c/css/properties/css3 CssFont.java,1.3,1.4 CssFontSize.java,1.2,1.3

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv28967

Modified Files:
	CssFont.java CssFontSize.java 
Log Message:
case sensitivity of idents

Index: CssFontSize.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontSize.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssFontSize.java	19 Aug 2012 17:28:25 -0000	1.2
+++ CssFontSize.java	23 Aug 2012 13:24:19 -0000	1.3
@@ -15,26 +15,37 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
+import java.util.Arrays;
 
 /**
  * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-size-prop
  */
 public class CssFontSize extends org.w3c.css.properties.css.CssFontSize {
 
-	public static final HashMap<String,CssIdent> allowed_values;
+	public static final CssIdent[] allowed_values;
 	static final String[] absolute_values = {"xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"};
 	static final String[] relative_values = {"smaller", "larger"};
 
 	static {
-		allowed_values = new HashMap<String, CssIdent>();
+		allowed_values = new CssIdent[absolute_values.length + relative_values.length];
+		int i = 0;
 		for (String s : absolute_values) {
-			allowed_values.put(s, CssIdent.getIdent(s));
+			allowed_values[i++] = CssIdent.getIdent(s);
 		}
 		for (String s : relative_values) {
-			allowed_values.put(s, CssIdent.getIdent(s));
+			allowed_values[i++] = CssIdent.getIdent(s);
 		}
+		Arrays.sort(allowed_values);
 	}
+
+	public static CssIdent getAllowedValue(CssIdent ident) {
+		int idx = Arrays.binarySearch(allowed_values, ident);
+		if (idx >= 0) {
+			return allowed_values[idx];
+		}
+		return null;
+	}
+
 	/**
 	 * Create a new CssFontSize
 	 */
@@ -64,7 +75,7 @@
 
 		switch (val.getType()) {
 			case CssTypes.CSS_NUMBER:
-				val = ((CssNumber)val).getLength();
+				val = ((CssNumber) val).getLength();
 			case CssTypes.CSS_LENGTH:
 				CssLength l = (CssLength) val;
 				if (!l.isPositive()) {
@@ -87,13 +98,13 @@
 					value = inherit;
 					break;
 				}
-				value = allowed_values.get(val.toString().toLowerCase());
+				value = getAllowedValue(ident);
 				if (value == null) {
 					throw new InvalidParamException("value",
 							expression.getValue().toString(),
 							getPropertyName(), ac);
 				}
-				 break;
+				break;
 			default:
 				throw new InvalidParamException("value",
 						expression.getValue().toString(),

Index: CssFont.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFont.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssFont.java	19 Aug 2012 11:52:57 -0000	1.3
+++ CssFont.java	23 Aug 2012 13:24:19 -0000	1.4
@@ -136,7 +136,7 @@
 					// check if we moved past and we now got
 					// a font-size
 					if (state == 0) {
-						CssIdent v = CssFontSize.allowed_values.get(ident.toString());
+						CssIdent v = CssFontSize.getAllowedValue(ident);
 						if (v != null) {
 							// we got a FontSize, so no more style/variant/weight
 							state = 1;

Received on Thursday, 23 August 2012 13:24:31 UTC