- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 23 Aug 2012 13:55:36 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv4412 Modified Files: CssFont.java CssFontStretch.java CssFontVariantCaps.java CssFontVariantEastAsian.java CssFontVariantPosition.java CssFontWeight.java Log Message: case sensitivity of idents Index: CssFontStretch.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontStretch.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssFontStretch.java 19 Aug 2012 17:28:25 -0000 1.2 +++ CssFontStretch.java 23 Aug 2012 13:55:34 -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; /** * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-stretch-prop @@ -22,13 +22,22 @@ static final String[] _allowed_values = {"normal", "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>(_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]); } + 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; } /** @@ -63,7 +72,7 @@ if (inherit.equals(ident)) { value = inherit; } else { - value = allowed_values.get(val.toString().toLowerCase()); + value = getAllowedValue(ident); if (value == null) { throw new InvalidParamException("value", val.toString(), Index: CssFontVariantCaps.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontVariantCaps.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssFontVariantCaps.java 19 Aug 2012 17:28:25 -0000 1.2 +++ CssFontVariantCaps.java 23 Aug 2012 13:55:34 -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; /** * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-variant-caps-prop @@ -20,33 +20,44 @@ public class CssFontVariantCaps extends org.w3c.css.properties.css.CssFontVariantCaps { public static final CssIdent normal; - public static final HashMap<String, CssIdent> capsValues; + public static final CssIdent[] capsValues; public static final String _capsValues[] = {"small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "titling-caps", "unicase"}; static { normal = CssIdent.getIdent("normal"); - capsValues = new HashMap<String, CssIdent>(_capsValues.length); - for (String s: _capsValues) { - capsValues.put(s, CssIdent.getIdent(s)); + capsValues = new CssIdent[_capsValues.length]; + int i = 0; + for (String s : _capsValues) { + capsValues[i++] = CssIdent.getIdent(s); } + Arrays.sort(capsValues); } - /** - * Create a new CssFontVariantCaps - */ - public CssFontVariantCaps() { + + public static final CssIdent getCapsValue(CssIdent ident) { + int idx = Arrays.binarySearch(capsValues, ident); + if (idx >= 0) { + return capsValues[idx]; + } + return null; + } + + /** + * Create a new CssFontVariantCaps + */ + public CssFontVariantCaps() { value = initial; - } + } - /** - * Creates a new CssFontVariantCaps - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssFontVariantCaps(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssFontVariantCaps + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssFontVariantCaps(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } @@ -65,7 +76,7 @@ } else if (normal.equals(ident)) { value = normal; } else { - value = capsValues.get(ident.toString().toLowerCase()); + value = getCapsValue(ident); if (value == null) { throw new InvalidParamException("value", val.toString(), @@ -78,12 +89,12 @@ getPropertyName(), ac); } expression.next(); - } + } - public CssFontVariantCaps(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssFontVariantCaps(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssFont.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFont.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssFont.java 23 Aug 2012 13:24:19 -0000 1.4 +++ CssFont.java 23 Aug 2012 13:55:34 -0000 1.5 @@ -120,7 +120,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", Index: CssFontVariantPosition.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontVariantPosition.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssFontVariantPosition.java 19 Aug 2012 17:28:25 -0000 1.2 +++ CssFontVariantPosition.java 23 Aug 2012 13:55:34 -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; /** * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#propdef-font-variant-position @@ -22,13 +22,23 @@ public static final String[] _allowedValues = {"normal", "sub", "super", "ordinal"}; - public static final HashMap<String, CssIdent> allowedValues; + public static final CssIdent[] allowedValues; static { - allowedValues = new HashMap<String, CssIdent>(_allowedValues.length); - for (String s : _allowedValues) { - allowedValues.put(s, CssIdent.getIdent(s)); + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } } + return null; } /** @@ -63,7 +73,7 @@ if (inherit.equals(ident)) { value = inherit; } else { - value = allowedValues.get(ident.toString().toLowerCase()); + value = getAllowedValue(ident); if (value == null) { throw new InvalidParamException("value", val.toString(), Index: CssFontWeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontWeight.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssFontWeight.java 19 Aug 2012 17:28:25 -0000 1.2 +++ CssFontWeight.java 23 Aug 2012 13:55:34 -0000 1.3 @@ -13,38 +13,46 @@ import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -import java.util.HashMap; - /** * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-weight-prop */ 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]); } } - /** - * Create a new CssFontWeight - */ - public CssFontWeight() { + + 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() { value = initial; - } + } - /** - * Creates a new CssFontWeight - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssFontWeight(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssFontWeight + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssFontWeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } @@ -59,7 +67,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: CssNumber num = (CssNumber) val; - switch(num.getInt()) { + switch (num.getInt()) { case 100: case 200: case 300: @@ -69,7 +77,7 @@ case 700: case 800: case 900: - value = num; + value = num; break; default: throw new InvalidParamException("value", @@ -83,7 +91,7 @@ value = inherit; break; } - value = allowed_values.get(ident.toString().toLowerCase()); + value = getAllowedValue(ident); if (value == null) { throw new InvalidParamException("value", val.toString(), @@ -96,12 +104,12 @@ getPropertyName(), ac); } expression.next(); - } + } - public CssFontWeight(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssFontWeight(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssFontVariantEastAsian.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontVariantEastAsian.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssFontVariantEastAsian.java 19 Aug 2012 17:28:25 -0000 1.2 +++ CssFontVariantEastAsian.java 23 Aug 2012 13:55:34 -0000 1.3 @@ -15,50 +15,78 @@ import org.w3c.css.values.CssValueList; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Arrays; /** * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#propdef-font-variant-east-asian */ public class CssFontVariantEastAsian extends org.w3c.css.properties.css.CssFontVariantEastAsian { - public static final String[] _eastAsianVariantValues = { "jis78", "jis83", "jis90", "jis04", + public static final String[] _eastAsianVariantValues = {"jis78", "jis83", "jis90", "jis04", "simplified", "traditional"}; - public static final String[] _eastAsianWidthValues = { "full-width", "proportional-width"}; + public static final String[] _eastAsianWidthValues = {"full-width", "proportional-width"}; - public static final HashMap<String,CssIdent> eastAsianVariantValues; - public static final HashMap<String,CssIdent> eastAsianWidthValues; + public static final CssIdent[] eastAsianVariantValues; + public static final CssIdent[] eastAsianWidthValues; public static final CssIdent normal; static { normal = CssIdent.getIdent("normal"); - eastAsianVariantValues = new HashMap<String, CssIdent>(_eastAsianVariantValues.length); - for (String s: _eastAsianVariantValues) { - eastAsianVariantValues.put(s, CssIdent.getIdent(s)); + eastAsianVariantValues = new CssIdent[_eastAsianVariantValues.length]; + for (int i = 0; i < eastAsianVariantValues.length; i++) { + eastAsianVariantValues[i] = CssIdent.getIdent(_eastAsianVariantValues[i]); } - eastAsianWidthValues = new HashMap<String, CssIdent>(_eastAsianWidthValues.length); - for (String s: _eastAsianWidthValues) { - eastAsianWidthValues.put(s, CssIdent.getIdent(s)); + Arrays.sort(eastAsianVariantValues); + eastAsianWidthValues = new CssIdent[_eastAsianWidthValues.length]; + for (int i = 0; i < eastAsianWidthValues.length; i++) { + eastAsianWidthValues[i] = CssIdent.getIdent(_eastAsianWidthValues[i]); } + Arrays.sort(eastAsianWidthValues); } - /** - * Create a new CssFontVariantEastAsian - */ - public CssFontVariantEastAsian() { + + public static final CssIdent getEastAsianVariantValue(CssIdent ident) { + int idx = Arrays.binarySearch(eastAsianVariantValues, ident); + if (idx >= 0) { + return eastAsianVariantValues[idx]; + } + return null; + } + + public static final CssIdent getEastAsianWidthValue(CssIdent ident) { + for (CssIdent id : eastAsianWidthValues) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static final CssIdent getEastAsianValue(CssIdent ident) { + CssIdent id = getEastAsianWidthValue(ident); + if (id == null) { + id = getEastAsianVariantValue(ident); + } + return id; + } + + /** + * Create a new CssFontVariantEastAsian + */ + public CssFontVariantEastAsian() { value = initial; - } + } - /** - * Creates a new CssFontVariantEastAsian - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssFontVariantEastAsian(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssFontVariantEastAsian + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssFontVariantEastAsian(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } @@ -80,8 +108,7 @@ } else if (normal.equals(ident)) { value = normal; } else { - String idStr = ident.toString().toLowerCase(); - value = eastAsianVariantValues.get(idStr); + value = getEastAsianVariantValue(ident); if (value != null) { if (expression.getCount() > 1) { if (op != CssOperator.SPACE) { @@ -92,7 +119,7 @@ val = expression.getValue(); CssIdent value2 = null; if (val.getType() == CssTypes.CSS_IDENT) { - value2 = eastAsianWidthValues.get(val.toString().toLowerCase()); + value2 = getEastAsianWidthValue((CssIdent) val); } if (value2 == null) { throw new InvalidParamException("value", @@ -105,7 +132,7 @@ value = new CssValueList(v); } } else { - value = eastAsianWidthValues.get(idStr); + value = getEastAsianWidthValue(ident); if (value != null) { if (expression.getCount() > 1) { if (op != CssOperator.SPACE) { @@ -116,7 +143,7 @@ val = expression.getValue(); CssIdent value2 = null; if (val.getType() == CssTypes.CSS_IDENT) { - value2 = eastAsianVariantValues.get(val.toString().toLowerCase()); + value2 = getEastAsianVariantValue((CssIdent) val); } if (value2 == null) { throw new InvalidParamException("value", @@ -141,12 +168,12 @@ getPropertyName(), ac); } expression.next(); - } + } - public CssFontVariantEastAsian(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssFontVariantEastAsian(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } }
Received on Thursday, 23 August 2012 13:55:43 UTC