W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2012

2002/css-validator/org/w3c/css/properties/css2 CssFont.java,1.2,1.3 CssFontFamily.java,1.1,1.2 CssFontSize.java,1.1,1.2 CssFontStretch.java,1.1,1.2 CssFontStyle.java,1.1,1.2 CssFontWeight.java,1.1,1.2

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 23 Aug 2012 14:53:41 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T4Ymz-0007L4-79@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2
In directory hutz:/tmp/cvs-serv28128

Modified Files:
	CssFont.java CssFontFamily.java CssFontSize.java 
	CssFontStretch.java CssFontStyle.java CssFontWeight.java 
Log Message:
case sensitivity of idents

Index: CssFontStretch.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFontStretch.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFontStretch.java	4 Aug 2012 21:17:05 -0000	1.1
+++ CssFontStretch.java	23 Aug 2012 14:53:39 -0000	1.2
@@ -12,7 +12,7 @@
 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/2008/REC-CSS2-20080411/fonts.html#propdef-font-stretch
@@ -22,13 +22,22 @@
 	static final String[] _allowed_values = {"normal", "wider", "narrower",
 			"ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
 			"semi-expanded", "expanded", "extra-expanded", "ultra-expanded"};
-	static final HashMap<String,CssIdent> allowed_values;
+	static final CssIdent[] allowed_values;
 
 	static {
-		allowed_values = new HashMap<String,CssIdent>();
-		for (String s : _allowed_values) {
-			allowed_values.put(s, CssIdent.getIdent(s));
+		allowed_values = new CssIdent[_allowed_values.length];
+		for (int i = 0; i < allowed_values.length; i++) {
+			allowed_values[i] = CssIdent.getIdent(_allowed_values[i]);
 		}
+		Arrays.sort(allowed_values);
+	}
+
+	public static final CssIdent getAllowedValue(CssIdent ident) {
+		int idx = Arrays.binarySearch(allowed_values, ident);
+		if (idx >= 0) {
+			return allowed_values[idx];
+		}
+		return null;
 	}
 
 	/**
@@ -62,7 +71,7 @@
 			if (inherit.equals(ident)) {
 				value = inherit;
 			} else {
-				value = allowed_values.get(val.toString());
+				value = getAllowedValue(ident);
 				if (value == null) {
 					throw new InvalidParamException("value",
 							val.toString(),

Index: CssFontStyle.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFontStyle.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFontStyle.java	4 Aug 2012 21:17:05 -0000	1.1
+++ CssFontStyle.java	23 Aug 2012 14:53:39 -0000	1.2
@@ -23,7 +23,7 @@
 	static final ArrayList<CssIdent> allowed_values;
 
 	static {
-		allowed_values = new ArrayList<CssIdent>(3);
+		allowed_values = new ArrayList<CssIdent>(_allowed_values.length);
 		for (String s : _allowed_values) {
 			allowed_values.add(CssIdent.getIdent(s));
 		}

Index: CssFont.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFont.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssFont.java	5 Aug 2012 06:22:55 -0000	1.2
+++ CssFont.java	23 Aug 2012 14:53:38 -0000	1.3
@@ -12,7 +12,7 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
+import java.util.Arrays;
 
 import static org.w3c.css.values.CssOperator.SPACE;
 
@@ -22,18 +22,27 @@
 public class CssFont extends org.w3c.css.properties.css.CssFont {
 
 	public static final CssIdent normal;
-	public static final HashMap<String, CssIdent> systemFonts;
+	public static final CssIdent[] systemFonts;
 	static final String[] _systemFonts = {"caption", "icon", "menu",
 			"message-box", "small-caption", "status-bar"};
 
 	static {
 		normal = CssIdent.getIdent("normal");
-		systemFonts = new HashMap<String, CssIdent>();
+		systemFonts = new CssIdent[_systemFonts.length];
+		int i = 0;
 		for (String s : _systemFonts) {
-			systemFonts.put(s, CssIdent.getIdent(s));
+			systemFonts[i++] = CssIdent.getIdent(s);
 		}
+		Arrays.sort(systemFonts);
 	}
 
+	public static final CssIdent getSystemFont(CssIdent ident) {
+		int idx = Arrays.binarySearch(systemFonts, ident);
+		if (idx >= 0) {
+			return systemFonts[idx];
+		}
+		return null;
+	}
 	/**
 	 * Create a new CssFontSize
 	 */
@@ -73,7 +82,7 @@
 						break;
 					}
 					CssIdent ident;
-					ident = systemFonts.get(val.toString());
+					ident = getSystemFont((CssIdent)val);
 					if (ident != null) {
 						if (expression.getCount() != 1) {
 							throw new InvalidParamException("value",
@@ -119,7 +128,7 @@
 							break;
 						}
 						// font-weight
-						v = CssFontWeight.allowed_values.get(ident.toString());
+						v = CssFontWeight.getAllowedValue(ident);
 						if (v != null) {
 							if (fontWeight != null) {
 								throw new InvalidParamException("value",
@@ -135,7 +144,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;

Index: CssFontSize.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFontSize.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFontSize.java	4 Aug 2012 21:17:05 -0000	1.1
+++ CssFontSize.java	23 Aug 2012 14:53:39 -0000	1.2
@@ -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/2008/REC-CSS2-20080411/fonts.html#propdef-font-size
  */
 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
 	 */
@@ -86,7 +97,7 @@
 					value = inherit;
 					break;
 				}
-				value = allowed_values.get(val.toString());
+				value = getAllowedValue(ident);
 				if (value == null) {
 					throw new InvalidParamException("value",
 							expression.getValue().toString(),

Index: CssFontWeight.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFontWeight.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFontWeight.java	4 Aug 2012 21:17:05 -0000	1.1
+++ CssFontWeight.java	23 Aug 2012 14:53:39 -0000	1.2
@@ -13,23 +13,32 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
-
 /**
  * @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#propdef-font-weight
  */
 public class CssFontWeight extends org.w3c.css.properties.css.CssFontWeight {
 
-	public static final HashMap<String,CssIdent> allowed_values;
+	public static final CssIdent[] allowed_values;
 	static final String[] _allowed_values = {"normal", "bold", "bolder", "lighter"};
 
 	static {
-		allowed_values = new HashMap<String, CssIdent>(_allowed_values.length);
-		for (String s : _allowed_values) {
-			allowed_values.put(s, CssIdent.getIdent(s));
+		allowed_values = new CssIdent[_allowed_values.length];
+		for (int i = 0; i < allowed_values.length; i++) {
+			allowed_values[i] = CssIdent.getIdent(_allowed_values[i]);
 		}
 	}
-    /**
+
+	public static final CssIdent getAllowedValue(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
+	}
+
+
+	/**
      * Create a new CssFontWeight
      */
     public CssFontWeight() {
@@ -82,7 +91,7 @@
 					value = inherit;
 					break;
 				}
-				value = allowed_values.get(val.toString());
+				value = getAllowedValue(ident);
 				if (value == null) {
 					throw new InvalidParamException("value",
 							val.toString(),

Index: CssFontFamily.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssFontFamily.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssFontFamily.java	4 Aug 2012 21:17:05 -0000	1.1
+++ CssFontFamily.java	23 Aug 2012 14:53:38 -0000	1.2
@@ -37,11 +37,11 @@
 	};
 
 	static {
-		genericNames = new ArrayList<CssIdent>();
+		genericNames = new ArrayList<CssIdent>(_genericNames.length);
 		for (String s : _genericNames) {
 			genericNames.add(CssIdent.getIdent(s));
 		}
-		reservedNames = new ArrayList<CssIdent>();
+		reservedNames = new ArrayList<CssIdent>(_reservedNames.length);
 		for (String s : _reservedNames) {
 			reservedNames.add(CssIdent.getIdent(s));
 		}
Received on Thursday, 23 August 2012 14:53:46 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:51 UTC