W3C home > Mailing lists > Public > www-validator-cvs@w3.org > December 2009

2002/css-validator/org/w3c/css/properties/css3 CssColumnRule.java,1.2,1.3 CssColumnRuleStyle.java,1.4,1.5

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 17 Dec 2009 22:08:32 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1NLOWO-0000Vo-4p@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv1954

Modified Files:
	CssColumnRule.java CssColumnRuleStyle.java 
Log Message:
operator check for rule

Index: CssColumnRuleStyle.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnRuleStyle.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssColumnRuleStyle.java	17 Dec 2009 16:39:45 -0000	1.4
+++ CssColumnRuleStyle.java	17 Dec 2009 22:08:30 -0000	1.5
@@ -57,7 +57,6 @@
 	if(check && expression.getCount() > 1) {
 	    throw new InvalidParamException("unrecognize", ac);
 	}
-
 	// we only use Css Ident part of the CssBorderStyle acceptable values
 	if ((val.getType() != CssTypes.CSS_IDENT) ||
 	    !(((CssIdent)val).equals(inherit) || 

Index: CssColumnRule.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnRule.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssColumnRule.java	14 Sep 2005 15:15:04 -0000	1.2
+++ CssColumnRule.java	17 Dec 2009 22:08:30 -0000	1.3
@@ -9,51 +9,32 @@
 package org.w3c.css.properties.css3;
 
 import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css1.CssBorderBottomStyle;
-import org.w3c.css.properties.css1.CssBorderBottomWidth;
-import org.w3c.css.properties.css1.CssBorderLeftStyle;
-import org.w3c.css.properties.css1.CssBorderLeftWidth;
-import org.w3c.css.properties.css1.CssBorderRightStyle;
-import org.w3c.css.properties.css1.CssBorderRightWidth;
-import org.w3c.css.properties.css1.CssBorderTopStyle;
-import org.w3c.css.properties.css1.CssBorderTopWidth;
-import org.w3c.css.properties.css1.CssColor;
 import org.w3c.css.properties.css1.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
 import org.w3c.css.values.CssOperator;
+import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
 /**
+ * multicol
  *  <P>
- *  <EM>Value:</EM> &lt;border-style&gt; || &lt;color&gt; || &lt;border-width&gt; ||
- *  inherit<BR>
- *  <EM>Initial:</EM>the value of the color property<BR>
- *  <EM>Applies to:</EM>block-level elements<BR>
+ *  <EM>Value:</EM> &lt;column-rule-width&gt; || &lt;border-style&gt; ||
+ *  &lt;color&gt; <BR>
+ *  <EM>Initial:</EM>See individual properties<BR>
+ *  <EM>Applies to:</EM>multicol elements<BR>
  *  <EM>Inherited:</EM>no<BR>
- *  <EM>Percentages:</EM>no<BR>
+ *  <EM>Percentages:</EM>N/A<BR>
  *  <EM>Media:</EM>:visual
  */
 
-public class CssColumnRule extends CssProperty
-implements CssOperator {
-
-    CssValue value;
-    /* I should use border-width and border-style here, but I don't
-     * see how to implement a
-     * shorthand property for shorthand properties ... So I splitted it up
-     */
-    CssBorderTopWidth btw;
-    CssBorderRightWidth brw;
-    CssBorderLeftWidth blw;
-    CssBorderBottomWidth bbw;
-    CssBorderTopStyle bts;
-    CssBorderRightStyle brs;
-    CssBorderLeftStyle bls;
-    CssBorderBottomStyle bbs;
-    CssColor color;
-
+public class CssColumnRule extends CssProperty implements CssOperator {
+    CssIdent value = null;
+    CssColumnRuleWidth rule_width = null;
+    CssColumnRuleStyle rule_style = null;
+    CssColumnRuleColor rule_color = null;
 
     /**
      * Create a new CssColumnRule
@@ -71,102 +52,71 @@
 	    boolean check) throws InvalidParamException {
 
 	CssValue val = expression.getValue();
-	int maxvalues = 9;
-	boolean correct = true;
 	char op = SPACE;
-
-	if (val.equals(inherit)) {
-	    value = inherit;
-	    expression.next();
-	} else {
-
-	    while (correct && (val != null) && (maxvalues -- > 0)) {
-
-		correct = false;
-
-		if (btw == null) {
-		    try {
-			btw = new CssBorderTopWidth(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
-		    }
-		}
-		if (!correct && bbw == null) {
-		    try {
-			bbw = new CssBorderBottomWidth(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
-		    }
-		}
-		if (!correct && blw == null) {
-		    try {
-			blw = new CssBorderLeftWidth(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
-		    }
-		}
-		if (!correct && brw == null) {
-		    try {
-			brw = new CssBorderRightWidth(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
-		    }
+	int nb_val = expression.getCount();
+	
+	if (check && nb_val > 3) {
+	    throw new InvalidParamException("unrecognize", ac);
+	}
+	setByUser();
+	
+	while (!expression.end()) {
+	    boolean ok = true;
+	    val = expression.getValue();
+	    op = expression.getOperator();
+	    if (op != SPACE) {
+		throw new InvalidParamException("operator",
+					      ((new Character(op)).toString()),
+						ac);
+	    }
+	    switch (val.getType()) {
+	    case CssTypes.CSS_FUNCTION:
+	    case CssTypes.CSS_COLOR:
+		if (rule_color != null) {
+		    throw new InvalidParamException("unrecognize", ac);
 		}
-		if (!correct && color == null) {
-		    try {
-			color = new CssColor(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
-		    }
+		rule_color = new CssColumnRuleColor(ac, expression);
+		break;
+	    case CssTypes.CSS_NUMBER:
+	    case CssTypes.CSS_LENGTH:
+		if (rule_width != null) {
+		    throw new InvalidParamException("unrecognize", ac);
 		}
-
-		if (!correct && bts == null) {
-		    try {
-			bts = new CssBorderTopStyle(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
+		rule_width = new CssColumnRuleWidth(ac, expression);
+		break;
+	    case CssTypes.CSS_IDENT:
+		if (inherit.equals(val)) {
+		    if (nb_val > 1) {
+			throw new InvalidParamException("unrecognize", ac);
 		    }
+		    value = inherit;
+		    break;
 		}
-		if (!correct && bbw == null) {
+		if (rule_color == null) {
 		    try {
-			bbs = new CssBorderBottomStyle(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
+			rule_color = new CssColumnRuleColor(ac, expression);
+			break;
+		    } catch (Exception ex) {
 		    }
 		}
-		if (!correct && bls == null) {
+		if (rule_width == null) {
 		    try {
-			bls = new CssBorderLeftStyle(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
+			rule_width = new CssColumnRuleWidth(ac, expression);
+			break;
+		    } catch (Exception ex) {
 		    }
 		}
-		if (!correct && brs == null) {
+		if (rule_style == null) {
 		    try {
-			brs = new CssBorderRightStyle(ac, expression);
-			correct = true;
-		    }
-		    catch (InvalidParamException e) {
+			rule_style = new CssColumnRuleStyle(ac, expression);
+			break;
+		    } catch (Exception ex) {
 		    }
 		}
-
-		if (!correct) {
-		    throw new InvalidParamException("value",
-						    expression.getValue(),
-						    getPropertyName(), ac);
-		}
-
-		val = expression.getValue();
-		op = expression.getOperator();
-
+	    default:
+		throw new InvalidParamException("value",
+						expression.getValue(),
+						getPropertyName(), ac);
 	    }
 	}
     }
@@ -215,7 +165,7 @@
      * Returns the name of this property
      */
     public String getPropertyName() {
-	return "column-border";
+	return "column-rule";
     }
 
     /**
@@ -229,38 +179,27 @@
      * Returns a string representation of the object
      */
     public String toString() {
-
-	String ret = "";
-
-	if (btw != null) {
-		ret += " " + btw.toString();
+	StringBuilder sb = new StringBuilder();
+	boolean first = true;
+	if (value != null) {
+	    return value.toString();
 	}
-	if (brw != null) {
-		ret += " " + brw.toString();
+	if (rule_color != null) {
+	    sb.append(rule_color);
+	    first = false;
 	}
-	if (blw != null) {
-		ret += " " + blw.toString();
-    }
-	if (bbw != null) {
-		ret += " " + bbw.toString();
-    }
-	if (bts != null) {
-		ret += " " + bts.toString();
-    }
-	if (brs != null) {
-		ret += " " + brs.toString();
-    }
-	if (bls != null) {
-		ret += " " + bls.toString();
-    }
-    if (bbs != null) {
-		ret += " " + bbs.toString();
-    }
-    if (color != null) {
-		ret += " " + color.toString();
-    }
-
-	return ret.substring(1);
-
+	if (rule_width != null) {
+	    if (!first) {
+		sb.append(' ');
+	    }
+	    sb.append(rule_width);
+	}
+	if (rule_style != null) {
+	    if (!first) {
+		sb.append(' ');
+	    }
+	    sb.append(rule_style);
+	}
+	return sb.toString();
     }
 }
Received on Thursday, 17 December 2009 22:08:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:16 GMT