2002/css-validator/org/w3c/css/properties/css1 CssDisplay.java,1.6,1.7

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

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

Index: CssDisplay.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssDisplay.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssDisplay.java	31 Aug 2011 18:34:50 -0000	1.6
+++ CssDisplay.java	24 Aug 2012 07:24:39 -0000	1.7
@@ -13,123 +13,87 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
-
 /**
- * http://www.w3.org/TR/2008/REC-CSS1-20080411/#display
- * <p/>
- * <H4>
- * &nbsp;&nbsp; 'display'
- * </H4>
- * <p/>
- * <EM>Value:</EM> block | inline | list-item | none<BR>
- * <EM>Initial:</EM> block<BR>
- * <EM>Applies to:</EM> all elements<BR>
- * <EM>Inherited:</EM> no<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <p/>
- * This property describes how/if an element is displayed on the canvas (which
- * may be on a printed page, a computer display etc.).
- * <P> An element with a 'display' value of 'block' opens a new box. The box
- * is positioned relative to adjacent boxes according to the CSS <A
- * HREF="#formatting-model">formatting model</A>. Typically, elements like
- * 'H1' and 'P' are of type 'block'. A value of 'list-item' is similar to
- * 'block' except that a list-item marker is added. In HTML, 'LI' will
- * typically have this value.
- * <p/>
- * An element with a 'display' value of 'inline' results in a new inline box
- * on the same line as the previous content. The box is dimensioned according
- * to the formatted size of the content. If the content is text, it may span
- * several lines, and there will be a box on each line. The margin, border and
- * padding properties apply to 'inline' elements, but will not have any effect
- * at the line breaks.
- * <p/>
- * A value of 'none' turns off the display of the element, including children
- * elements and the surrounding box.
- * <PRE>
- * P { display: block }
- * EM { display: inline }
- * LI { display: list-item }
- * IMG { display: none }
- * </PRE>
- * <p/>
- * The last rule turns off the display of images.
- * <P> The initial value of 'display' is 'block', but a UA will typically have
- * default values for all HTML elements according to the suggested rendering
- * of elements in the HTML specification.
- *
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#display
  */
 public class CssDisplay extends org.w3c.css.properties.css.CssDisplay {
 
-    CssIdent value;
-    public static CssIdent block;
-    public static HashMap<String, CssIdent> allowed_values;
+	public static CssIdent block;
+	public static CssIdent[] allowed_values;
 
-    static {
-        allowed_values = new HashMap<String, CssIdent>();
-        String[] DISPLAY = {
-                "block", "inline", "list-item", "none"};
-        for (String aDISPLAY : DISPLAY) {
-            allowed_values.put(aDISPLAY, CssIdent.getIdent(aDISPLAY));
-        }
-        block = CssIdent.getIdent("block");
-    }
+	static {
+		String[] DISPLAY = {
+				"block", "inline", "list-item", "none"};
+		allowed_values = new CssIdent[DISPLAY.length];
+		int i = 0;
+		for (String aDISPLAY : DISPLAY) {
+			allowed_values[i++] = CssIdent.getIdent(aDISPLAY);
+		}
+		block = CssIdent.getIdent("block");
+	}
 
-    /**
-     * Create a new CssDisplay
-     */
-    public CssDisplay() {
-        // nothing to do
-    }
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
+	}
 
-    /**
-     * Create a new CssDisplay
-     *
-     * @param ac         The context
-     * @param expression The expression for this property
-     * @param check      boolean, if check has to be enforced
-     * @throws InvalidParamException Values are incorect
-     */
-    public CssDisplay(ApplContext ac, CssExpression expression,
-                      boolean check) throws InvalidParamException {
+	/**
+	 * Create a new CssDisplay
+	 */
+	public CssDisplay() {
+		// nothing to do
+	}
 
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
+	/**
+	 * Create a new CssDisplay
+	 *
+	 * @param ac         The context
+	 * @param expression The expression for this property
+	 * @param check      boolean, if check has to be enforced
+	 * @throws InvalidParamException Values are incorect
+	 */
+	public CssDisplay(ApplContext ac, CssExpression expression,
+					  boolean check) throws InvalidParamException {
 
-        CssValue val = expression.getValue();
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-        setByUser();
+		CssValue val = expression.getValue();
 
-        if (val.getType() == CssTypes.CSS_IDENT) {
-            CssIdent id_val = (CssIdent) val;
-            String id_value = id_val.toString();
+		setByUser();
 
-            value = allowed_values.get(id_value);
-            if (value != null) {
-                expression.next();
-                return;
-            }
-        }
+		if (val.getType() == CssTypes.CSS_IDENT) {
+			CssIdent id_val = (CssIdent) val;
 
-        throw new InvalidParamException("value", expression.getValue(),
-                getPropertyName(), ac);
+			value = getMatchingIdent(id_val);
+			if (value != null) {
+				expression.next();
+				return;
+			}
+		}
 
-    }
+		throw new InvalidParamException("value", expression.getValue(),
+				getPropertyName(), ac);
 
-    public CssDisplay(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	}
 
+	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 == block);
-    }
+
+	/**
+	 * 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 == block);
+	}
 
 }

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