2002/css-validator/org/w3c/css/properties/css3 CssDisplay.java,1.2,1.3

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

Modified Files:
	CssDisplay.java 
Log Message:
ident case sensitivity

Index: CssDisplay.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssDisplay.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssDisplay.java	5 Oct 2011 11:46:43 -0000	1.2
+++ CssDisplay.java	24 Aug 2012 07:24:39 -0000	1.3
@@ -13,133 +13,98 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
-
 /**
- * Validity: 2007/08/09
- * From http://www.w3.org/TR/2007/WD-css3-box-20070809/#the-lsquo
+ * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#the-lsquo
  * <p/>
- * 4.1. The ?display? property
- * Name: 	display
- * Value: 	inline | block | inline-block | list-item | run-in | compact | table |
- * inline-table | table-row-group | table-header-group |
- * table-footer-group | table-row | table-column-group | table-column |
- * table-cell | table-caption | ruby | ruby-base | ruby-text |
- * ruby-base-group | ruby-text-group | <template>| none
- * Initial: 	inline
- * Applies to: 	all elements
- * Inherited: 	no
- * Percentages: 	N/A
- * Media: 	visual (?none? applies to all media)
- * Computed value: 	specified value, except for floats, root elements and positioned elements; see text
- *
- *
  * TODO do &lt;template&gt; from http://www.w3.org/TR/2010/WD-css3-layout-20100429/#declaring-templates-the-display-property
- *
  */
 public class CssDisplay extends org.w3c.css.properties.css.CssDisplay {
 
-    public CssIdent value;
-    private static HashMap<String, CssIdent> allowed_values;
-
-    static {
-        allowed_values = new HashMap<String, CssIdent>();
-
-        String[] DISPLAY = {
-                "inline", "block", "inline-block", "list-item", "run-in",
-                "compact", "table", "inline-table", "table-row-group",
-                "table-header-group", "table-footer-group", "table-row",
-                "table-column-group", "table-column", "table-cell",
-                "table-caption", "ruby", "ruby-base", "ruby-text",
-                "ruby-base-group", "ruby-text-group", "none"
-        };
-
-        for (String aDISPLAY : DISPLAY) {
-            allowed_values.put(aDISPLAY, CssIdent.getIdent(aDISPLAY));
-        }
-    }
-
-    /**
-     * Create a new CssDisplay
-     */
-    public CssDisplay() {
-        // nothing to do
-    }
+	public static CssIdent[] allowed_values;
 
-    /**
-     * Create a new CssDisplay
-     *
-     * @param ac         The context
-     * @param expression The expression for this property
-     * @param check      true if explicit check is needed
-     * @throws org.w3c.css.util.InvalidParamException
-     *          Values are incorect
-     */
-    public CssDisplay(ApplContext ac, CssExpression expression,
-                      boolean check) throws InvalidParamException {
+	static {
+		String[] DISPLAY = {
+				"inline", "block", "inline-block", "list-item", "run-in",
+				"compact", "table", "inline-table", "table-row-group",
+				"table-header-group", "table-footer-group", "table-row",
+				"table-column-group", "table-column", "table-cell",
+				"table-caption", "ruby", "ruby-base", "ruby-text",
+				"ruby-base-group", "ruby-text-group", "none"
+		};
+		allowed_values = new CssIdent[DISPLAY.length];
+		int i = 0;
+		for (String aDISPLAY : DISPLAY) {
+			allowed_values[i++] = CssIdent.getIdent(aDISPLAY);
+		}
+	}
 
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
+	}
 
-        CssValue val = expression.getValue();
+	/**
+	 * Create a new CssDisplay
+	 */
+	public CssDisplay() {
+		// nothing to do
+	}
 
-        setByUser();
+	/**
+	 * Create a new CssDisplay
+	 *
+	 * @param ac         The context
+	 * @param expression The expression for this property
+	 * @param check      true if explicit check is needed
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Values are incorect
+	 */
+	public CssDisplay(ApplContext ac, CssExpression expression,
+					  boolean check) throws InvalidParamException {
 
-        if (val.getType() == CssTypes.CSS_IDENT) {
-            CssIdent id_val = (CssIdent) val;
-            String id_value = id_val.toString();
-            if (inherit.equals(id_val)) {
-                value = inherit;
-            } else {
-                value = allowed_values.get(id_value);
-            }
-            if (value == null) {
-                // do templates...
-            }
-            if (value != null) {
-                expression.next();
-                return;
-            }
-        }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-        throw new InvalidParamException("value", expression.getValue(),
-                getPropertyName(), ac);
-    }
+		CssValue val = expression.getValue();
 
-    public CssDisplay(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+		setByUser();
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-        return value;
-    }
+		if (val.getType() == CssTypes.CSS_IDENT) {
+			CssIdent id_val = (CssIdent) val;
+			if (inherit.equals(id_val)) {
+				value = inherit;
+			} else {
+				value = getMatchingIdent(id_val);
+			}
+			if (value == null) {
+				// do templates...
+			}
+			if (value != null) {
+				expression.next();
+				return;
+			}
+		}
 
-    /**
-     * Returns true if this property is "softly" inherited
-     * e.g. his value equals inherit
-     */
-    public boolean isSoftlyInherited() {
-        return (value == inherit);
-    }
+		throw new InvalidParamException("value", expression.getValue(),
+				getPropertyName(), ac);
+	}
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        return value.toString();
-    }
+	public CssDisplay(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
-    /**
-     * Is the value of this property is a default value.
-     * It is used by all macro for the function <code>print</code>
-     */
-    public boolean isDefault() {
-        return (value == inline);
-    }
+	/**
+	 * Is the value of this property is a default value.
+	 * It is used by all macro for the function <code>print</code>
+	 */
+	public boolean isDefault() {
+		return (value == inline);
+	}
 
 }

Received on Friday, 24 August 2012 07:24:43 UTC