- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 23 Aug 2012 14:33:40 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css21 In directory hutz:/tmp/cvs-serv27110 Modified Files: CssFont.java CssFontFamily.java CssFontSize.java CssFontStyle.java CssFontWeight.java Log Message: case sensitivity of idents Index: CssFontSize.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/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:06 -0000 1.1 +++ CssFontSize.java 23 Aug 2012 14:33:38 -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/2011/REC-CSS2-20110607/fonts.html#font-size-props */ 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 */ @@ -63,7 +74,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()) { @@ -86,13 +97,13 @@ value = inherit; break; } - value = allowed_values.get(val.toString()); + 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: CssFontWeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/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:06 -0000 1.1 +++ CssFontWeight.java 23 Aug 2012 14:33:38 -0000 1.2 @@ -13,23 +13,31 @@ import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -import java.util.HashMap; - /** * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/fonts.html#propdef-font-weight * @version $Revision$ */ 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 */ @@ -83,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: CssFont.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/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:33:38 -0000 1.3 @@ -119,7 +119,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 +135,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: CssFontStyle.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/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:06 -0000 1.1 +++ CssFontStyle.java 23 Aug 2012 14:33:38 -0000 1.2 @@ -23,7 +23,7 @@ public 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: CssFontFamily.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/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:06 -0000 1.1 +++ CssFontFamily.java 23 Aug 2012 14:33: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:34:19 UTC