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

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

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

Index: CssBreakBefore.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBreakBefore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBreakBefore.java	4 Oct 2011 14:33:38 -0000	1.3
+++ CssBreakBefore.java	24 Aug 2012 07:33:32 -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,135 +15,91 @@
 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-before
- * 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 CssBreakBefore extends org.w3c.css.properties.css.CssBreakBefore {
 
-    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 CssBreakBefore() {
-        value = auto;
-    }
-
-    /**
-     * Create a new CssBreakBefore
-     *
-     * @param ac         the context
-     * @param expression The expression for this property
-     * @param check      if checking is needed
-     * @throws org.w3c.css.util.InvalidParamException Incorrect value
-     */
-    public CssBreakBefore(ApplContext ac, CssExpression expression,
-                          boolean check) throws InvalidParamException {
-        setByUser();
-        CssValue val = expression.getValue();
+	static CssIdent auto;
+	private static CssIdent[] allowed_values;
 
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
+	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 (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();
-    }
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
+	}
 
-    public CssBreakBefore(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	/**
+	 * Create a new CssBreakBefore
+	 */
+	public CssBreakBefore() {
+		value = initial;
+	}
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param property The other property.
-     */
-    public boolean equals(CssProperty property) {
-        return (property instanceof CssBreakBefore &&
-                value.equals(((CssBreakBefore) property).value));
-    }
+	/**
+	 * Create a new CssBreakBefore
+	 *
+	 * @param ac         the context
+	 * @param expression The expression for this property
+	 * @param check      if checking is needed
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Incorrect value
+	 */
+	public CssBreakBefore(ApplContext ac, CssExpression expression,
+						  boolean check) throws InvalidParamException {
+		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 CssBreakBefore(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:42 UTC