W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2012

2002/css-validator/org/w3c/css/properties/css3 CssBreakAfter.java,1.3,1.4

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 24 Aug 2012 07:33:42 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T4oOk-0004rk-SW@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv18638/css3

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

Index: CssBreakAfter.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBreakAfter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBreakAfter.java	4 Oct 2011 14:33:38 -0000	1.3
+++ CssBreakAfter.java	24 Aug 2012 07:33:40 -0000	1.4
@@ -8,7 +8,6 @@
 
 package org.w3c.css.properties.css3;
 
-import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
@@ -16,134 +15,90 @@
 import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
-import java.util.HashMap;
-
 /**
- * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks
- * <p/>
- * When content is laid out in multiple columns, the user agent must determine
- * where column breaks are placed. The problem of breaking content into columns
- * is similar to breaking content into pages.
- * <p/>
- * Three new properties are introduced to allow column breaks to be described
- * in the same properties as page breaks: ‘break-before’, ‘break-after’, and
- * ‘break-inside’. These properties take the same values as
- * ‘page-break-before’, ‘page-break-after’, and ‘page-break-inside’ [CSS21].
- * In addition, some new keyword values are added.
- * <p/>
- * Name:  	break-after
- * Value: 	auto | always | avoid | left | right | page | column |
- * avoid-page | avoid-column
- * Initial: 	auto
- * Applies to: 	block-level elements
- * Inherited: 	no
- * Percentages: 	N/A
- * Media: 	paged
- * Computed value: 	specified value
+ * @spec http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks
  */
 
 public class CssBreakAfter extends org.w3c.css.properties.css.CssBreakAfter {
 
-    static CssIdent auto;
-    private static HashMap<String, CssIdent> allowed_values;
-
-    CssIdent value;
-
-    static {
-        allowed_values = new HashMap<String, CssIdent>();
-        auto = CssIdent.getIdent("auto");
-        String id_values[] = {"auto", "always", "avoid", "left", "right",
-                "page", "column", "avoid-page", "avoid-column"};
-        for (String s : id_values) {
-            allowed_values.put(s, CssIdent.getIdent(s));
-        }
-    }
-
-    /**
-     * Create a new CssColumnWidth
-     */
-    public CssBreakAfter() {
-        value = auto;
-    }
-
-    /**
-     * Create a new CssBreakAfter
-     *
-     * @param expression The expression for this property
-     * @throws org.w3c.css.util.InvalidParamException Incorrect value
-     */
-    public CssBreakAfter(ApplContext ac, CssExpression expression,
-                         boolean check) throws InvalidParamException {
+	static CssIdent auto;
+	private static CssIdent[] allowed_values;
 
-        setByUser();
-        CssValue val = expression.getValue();
+	static {
+		auto = CssIdent.getIdent("auto");
+		String id_values[] = {"auto", "always", "avoid", "left", "right",
+				"page", "column", "avoid-page", "avoid-column"};
+		allowed_values = new CssIdent[id_values.length];
+		int i = 0;
+		for (String s : id_values) {
+			allowed_values[i++] = CssIdent.getIdent(s);
+		}
+	}
 
-        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;
+	}
 
-        if (val.getType() != CssTypes.CSS_IDENT) {
-            throw new InvalidParamException("value",
-                    expression.getValue(),
-                    getPropertyName(), ac);
-        }
-        // ident, so inherit, or allowed value
-        if (inherit.equals(val)) {
-            value = inherit;
-        } else {
-            val = allowed_values.get(val.toString());
-            if (val == null) {
-                throw new InvalidParamException("value",
-                        expression.getValue(),
-                        getPropertyName(), ac);
-            }
-            value = (CssIdent) val;
-        }
-        expression.next();
-    }
+	/**
+	 * Create a new CssBreakAfter
+	 */
+	public CssBreakAfter() {
+		value = initial;
+	}
 
-    public CssBreakAfter(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	/**
+	 * Create a new CssBreakAfter
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Incorrect value
+	 */
+	public CssBreakAfter(ApplContext ac, CssExpression expression,
+						 boolean check) throws InvalidParamException {
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param property The other property.
-     */
-    public boolean equals(CssProperty property) {
-        return (property instanceof CssBreakAfter &&
-                value.equals(((CssBreakAfter) property).value));
-    }
+		setByUser();
+		CssValue val = expression.getValue();
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-        return value;
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    /**
-     * Returns true if this property is "softly" inherited
-     */
-    public boolean isSoftlyInherited() {
-        return (inherit == value);
-    }
+		if (val.getType() != CssTypes.CSS_IDENT) {
+			throw new InvalidParamException("value",
+					expression.getValue(),
+					getPropertyName(), ac);
+		}
+		// ident, so inherit, or allowed value
+		if (inherit.equals(val)) {
+			value = inherit;
+		} else {
+			val = getMatchingIdent((CssIdent) val);
+			if (val == null) {
+				throw new InvalidParamException("value",
+						expression.getValue(),
+						getPropertyName(), ac);
+			}
+			value = val;
+		}
+		expression.next();
+	}
 
-    /**
-     * Returns a string representation of the object
-     */
-    public String toString() {
-        return value.toString();
-    }
+	public CssBreakAfter(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
-    /**
-     * Is the value of this property a default value
-     * It is used by all macro for the function <code>print</code>
-     */
-    public boolean isDefault() {
-        return (auto == value);
-    }
+	/**
+	 * Is the value of this property a default value
+	 * It is used by all macro for the function <code>print</code>
+	 */
+	public boolean isDefault() {
+		return (auto == value);
+	}
 
 }
Received on Friday, 24 August 2012 07:33:51 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:51 UTC