2002/css-validator/org/w3c/css/properties/css2 CssBackgroundRepeat.java,1.2,1.3

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

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

Index: CssBackgroundRepeat.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssBackgroundRepeat.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssBackgroundRepeat.java	13 Feb 2012 15:48:13 -0000	1.2
+++ CssBackgroundRepeat.java	23 Aug 2012 21:09:08 -0000	1.3
@@ -6,9 +6,6 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css2;
 
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
-import org.w3c.css.properties.css1.Css1Style;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
@@ -16,134 +13,89 @@
 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/colors.html#propdef-background-repeat
  * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/colors.html#propdef-background-repeat
  */
 public class CssBackgroundRepeat extends org.w3c.css.properties.css.CssBackgroundRepeat {
-    // FIXME TODO is that the best way ?
-
-    public static boolean checkMatchingIdent(CssIdent ident) {
-        return allowed_values.containsValue(ident);
-    }
-    
-    private static HashMap<String, CssIdent> allowed_values;
-
-    static {
-        allowed_values = new HashMap<String, CssIdent>();
-        String[] REPEAT = {"repeat", "repeat-x", "repeat-y", "no-repeat"};
-
-        for (String aREPEAT : REPEAT) {
-            allowed_values.put(aREPEAT, CssIdent.getIdent(aREPEAT));
-        }
-    }
 
-    public CssValue value;
+	private static CssIdent[] allowed_values;
 
-    /**
-     * Create a new CssBackgroundRepeat
-     */
-    public CssBackgroundRepeat() {
-        value = repeat;
-    }
+	static {
+		String[] REPEAT = {"repeat", "repeat-x", "repeat-y", "no-repeat"};
 
-    /**
-     * Set the value of the property
-     *
-     * @param expression The expression for this property
-     * @throws InvalidParamException The expression is incorrect
-     */
-    public CssBackgroundRepeat(ApplContext ac, CssExpression expression,
-                               boolean check) throws InvalidParamException {
+		allowed_values = new CssIdent[REPEAT.length];
+		int i = 0;
+		for (String aREPEAT : REPEAT) {
+			allowed_values[i++] = CssIdent.getIdent(aREPEAT);
+		}
+	}
 
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
+	protected static boolean checkMatchingIdent(CssIdent ident) {
+		return (getMatchingIdent(ident) != null);
+	}
 
-        CssValue val = expression.getValue();
-        setByUser();
+	protected static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
+	}
 
-        if (val.getType() != CssTypes.CSS_IDENT) {
-            throw new InvalidParamException("value", expression.getValue(),
-                    getPropertyName(), ac);
-        }
-        if (inherit.equals(val)) {
-            value = inherit;
-        } else {
-            value = allowed_values.get(val.toString());
-            if (value == null) {
-                throw new InvalidParamException("value", expression.getValue(),
-                        getPropertyName(), ac);
-            }
-        }
-        expression.next();
-    }
 
-    public CssBackgroundRepeat(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	/**
+	 * Create a new CssBackgroundRepeat
+	 */
+	public CssBackgroundRepeat() {
+		value = repeat;
+	}
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-        return value;
-    }
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @throws InvalidParamException The expression is incorrect
+	 */
+	public CssBackgroundRepeat(ApplContext ac, CssExpression expression,
+							   boolean check) throws InvalidParamException {
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        return value.toString();
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    // TODO FIXME get rid of this when Css1Style gets only one background
-    /**
-     * Add this property to the CssStyle.
-     *
-     * @param style The CssStyle
-     */
-    public void addToStyle(ApplContext ac, CssStyle style) {
-        org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
-        if (cssBackground.repeat != null)
-            style.addRedefinitionWarning(ac, this);
-        cssBackground.repeat = this;
-    }
+		CssValue val = expression.getValue();
+		setByUser();
 
-    /**
-     * Get this property in the style.
-     *
-     * @param style   The style where the property is
-     * @param resolve if true, resolve the style to find this property
-     */
-    public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
-        if (resolve) {
-            return ((Css1Style) style).getBackgroundRepeat();
-        } else {
-            return ((Css1Style) style).cssBackground.repeat;
-        }
-    }
+		if (val.getType() != CssTypes.CSS_IDENT) {
+			throw new InvalidParamException("value", expression.getValue(),
+					getPropertyName(), ac);
+		}
+		if (inherit.equals(val)) {
+			value = inherit;
+		} else {
+			value = getMatchingIdent((CssIdent) val);
+			if (value == null) {
+				throw new InvalidParamException("value", expression.getValue(),
+						getPropertyName(), ac);
+			}
+		}
+		expression.next();
+	}
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param property The other property.
-     */
-    public boolean equals(CssProperty property) {
-        return (property instanceof CssBackgroundRepeat &&
-                value == ((CssBackgroundRepeat) property).value);
-    }
+	public CssBackgroundRepeat(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 (repeat == value);
-    }
+	/**
+	 * 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 (repeat == value);
+	}
 }
 
 

Received on Thursday, 23 August 2012 21:09:18 UTC