W3C home > Mailing lists > Public > www-validator-cvs@w3.org > March 2008

2002/css-validator/org/w3c/css/properties/css21 CssBorderCSS21.java,1.2,1.3 CssBorderTopCSS21.java,1.2,1.3

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 25 Mar 2008 18:43:32 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1JeE7Q-0001y9-Tq@lionel-hutz.w3.org>

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

Modified Files:
	CssBorderCSS21.java CssBorderTopCSS21.java 
Log Message:
various code clarification/updates

Index: CssBorderTopCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBorderTopCSS21.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssBorderTopCSS21.java	14 Sep 2005 15:14:58 -0000	1.2
+++ CssBorderTopCSS21.java	25 Mar 2008 18:43:30 -0000	1.3
@@ -10,6 +10,7 @@
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
+import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
 /**
@@ -34,7 +35,7 @@
     public CssBorderTopCSS21(ApplContext ac, CssExpression expression,
 	    boolean check) throws InvalidParamException {
 	CssValue val = null;
-	char op = SPACE;
+	char op;
 	boolean find = true;
 
 	if(check && expression.getCount() > 3) {
@@ -46,42 +47,60 @@
 	setByUser();
 
 	while (find) {
-	    find = false;
 	    val = expression.getValue();
-	    op = expression.getOperator();
 	    if (val == null)
 		break;
-
-	    // if there are many values, we can't have inherit as one of them
-	    if(manyValues && val.equals(inherit)) {
-		throw new InvalidParamException("unrecognize", null, null, ac);
-	    }
-
+	    op = expression.getOperator();
 	    if (op != SPACE)
 		throw new InvalidParamException("operator",
-						((new Character(op)).toString()),
-						ac);
-	    if (getWidth() == null) {
-		try {
+						Character.toString(op),
+						ac);	 
+	    switch (val.getType()) {
+	    case CssTypes.CSS_COLOR:
+		if (getColor() == null) {
+		    // throws an exception if the value is not valid
+		    setColor(new CssBorderTopColorCSS21(ac, expression));
+		    continue;
+		}
+		break;
+	    case CssTypes.CSS_NUMBER:
+	    case CssTypes.CSS_LENGTH:
+		if (getWidth() == null) {
 		    setWidth(new CssBorderTopWidthCSS2(ac, expression));
-		    find = true;
-		} catch(InvalidParamException e){
-		    // nothing to do, style will test this value
+		    continue;
 		}
-	    }
-	    if (!find && getStyle() == null) {
-		try {
-		    setStyle(new CssBorderTopStyleCSS2(ac, expression));
-		    find = true;
-		} catch(InvalidParamException e){
-		    // nothing to do, color will test this value
+		break;
+	    case CssTypes.CSS_IDENT:
+		if(manyValues && inherit.equals(val)) {
+		    throw new InvalidParamException("unrecognize", null, 
+						    null, ac);
 		}
+		if (getWidth() == null) {
+		    try {
+			setWidth(new CssBorderTopWidthCSS2(ac, expression));
+			continue;
+		    } catch(InvalidParamException e){
+			// nothing to do, color will test this value
+		    }
+		}
+		if (getStyle() == null) {
+		    try {
+			setStyle(new CssBorderTopStyleCSS2(ac, expression));
+			continue;
+		    } catch(InvalidParamException e){
+			// nothing to do, color will test this value
+		    }
+		}
+		if (getColor() == null) {
+		    // throws an exception if the value is not valid
+		    setColor(new CssBorderTopColorCSS21(ac, expression));
+		    continue;
+		}
+	    default:
+		find = false;
 	    }
-	    if (!find && getColor() == null) {
-		// throws an exception if the value is not valid
-		setColor(new CssBorderTopColorCSS21(ac, expression));
-		find = true;
-	    }
+	    throw new InvalidParamException("unrecognize", null, 
+					    null, ac);
 	}
     }
 

Index: CssBorderCSS21.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBorderCSS21.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssBorderCSS21.java	14 Sep 2005 15:14:58 -0000	1.2
+++ CssBorderCSS21.java	25 Mar 2008 18:43:30 -0000	1.3
@@ -62,33 +62,32 @@
 	setBottom(new CssBorderBottomCSS21());
 	setLeft(new CssBorderLeftCSS21());
 
-	CssBorderTopWidthCSS2 w = getTop().getWidth2();
-	CssBorderTopStyleCSS2 s = getTop().getStyle2();
-	CssBorderTopColorCSS2 c = getTop().getColor2();
+	CssBorderTopCSS21 top = (CssBorderTopCSS21) getTop();
+	CssBorderRightCSS21 right = (CssBorderRightCSS21) getRight();
+	CssBorderLeftCSS21 left = (CssBorderLeftCSS21) getLeft();
+	CssBorderBottomCSS21 bottom = (CssBorderBottomCSS21) getBottom();
+	
+	CssBorderTopWidthCSS2 w = top.getWidth2();
+	CssBorderTopStyleCSS2 s = top.getStyle2();
+	CssBorderTopColorCSS2 c = top.getColor2();
 
 	if(w != null) {
-	    getRight().setWidth(
-		new CssBorderRightWidthCSS2((CssBorderFaceWidthCSS2) w.get()));
-	    getLeft().setWidth(
-		new CssBorderLeftWidthCSS2((CssBorderFaceWidthCSS2) w.get()));
-	    getBottom().setWidth(
-		new CssBorderBottomWidthCSS2((CssBorderFaceWidthCSS2) w.get()));
+	    CssBorderFaceWidthCSS2 bfw = (CssBorderFaceWidthCSS2) w.get();
+	    right.setWidth(new CssBorderRightWidthCSS2(bfw));
+	    left.setWidth(new CssBorderLeftWidthCSS2(bfw));
+	    bottom.setWidth(new CssBorderBottomWidthCSS2(bfw));
 	}
 	if(s != null) {
-	    getRight().setStyle(
-		new CssBorderRightStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
-	    getLeft().setStyle(
-		new CssBorderLeftStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
-	    getBottom().setStyle(
-		new CssBorderBottomStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
+	    CssBorderFaceStyleCSS2 bfs = (CssBorderFaceStyleCSS2) s.get();
+	    right.setStyle(new CssBorderRightStyleCSS2(bfs));
+	    left.setStyle(new CssBorderLeftStyleCSS2(bfs));
+	    bottom.setStyle(new CssBorderBottomStyleCSS2(bfs));
 	}
 	if(c != null) {
-	    getRight().setColor(
-		new CssBorderRightColorCSS21((CssBorderFaceColorCSS21) c.get()));
-	    getLeft().setColor(
-		new CssBorderLeftColorCSS21((CssBorderFaceColorCSS21) c.get()));
-	    getBottom().setColor(
-		new CssBorderBottomColorCSS21((CssBorderFaceColorCSS21) c.get()));
+	    CssBorderFaceColorCSS21 bfc = (CssBorderFaceColorCSS21) c.get();
+	    right.setColor(new CssBorderRightColorCSS21(bfc));
+	    left.setColor(new CssBorderLeftColorCSS21(bfc));
+	    bottom.setColor(new CssBorderBottomColorCSS21(bfc));
 	}
     }
 
Received on Tuesday, 25 March 2008 18:44:04 GMT

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