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

2002/css-validator/org/w3c/css/properties/css1 CssHeight.java,1.6,1.7 CssWidth.java,1.6,1.7

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 06 Sep 2012 12:37:58 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T9bLo-00073C-Hw@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv26889/properties/css1

Modified Files:
	CssHeight.java CssWidth.java 
Log Message:
preparation of new css3 types support, parser already modified to accept them, some alignment of coding std for old properties

Index: CssHeight.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssHeight.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssHeight.java	9 Feb 2012 17:36:29 -0000	1.6
+++ CssHeight.java	6 Sep 2012 12:37:56 -0000	1.7
@@ -4,7 +4,6 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css1;
 
-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;
@@ -21,132 +20,73 @@
  */
 public class CssHeight extends org.w3c.css.properties.css.CssHeight {
 
-    CssLength lenVal;
-    CssPercentage perVal;
-    CssIdent identVal;
-
-    /**
-     * Create a new CssHeight
-     */
-    public CssHeight() {
-    }
-
-    /**
-     * Create a new CssHeight.
-     *
-     * @param expression The expression for this property
-     * @throws InvalidParamException Values are incorrect
-     */
-    public CssHeight(ApplContext ac, CssExpression expression, boolean check)
-            throws InvalidParamException {
-
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
-
-        CssValue val = expression.getValue();
-
-        setByUser();
-
-        switch (val.getType()) {
-            case CssTypes.CSS_IDENT:
-                CssIdent ident = (CssIdent) val;
-                if (auto.equals(val)) {
-                    identVal = auto;
-                } else {
-                    throw new InvalidParamException("unrecognize", ac);
-                }
-                break;
-            case CssTypes.CSS_NUMBER:
-                val = ((CssNumber) val).getLength();
-            case CssTypes.CSS_LENGTH:
-                lenVal = (CssLength) val;
-                if (!lenVal.isPositive()) {
-                    throw new InvalidParamException("negative-value",
-                            val.toString(), ac);
-                }
-                break;
-            case CssTypes.CSS_PERCENTAGE:
-                perVal = (CssPercentage) val;
-                if (perVal.floatValue() < 0.) {
-                    throw new InvalidParamException("negative-value",
-                            val.toString(), ac);
-                }
-                break;
-            default:
-                throw new InvalidParamException("value", val, getPropertyName(), ac);
-        }
-        expression.next();
-    }
+	/**
+	 * Create a new CssHeight
+	 */
+	public CssHeight() {
+	}
 
-    public CssHeight(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	/**
+	 * Create a new CssHeight.
+	 *
+	 * @param expression The expression for this property
+	 * @throws InvalidParamException Values are incorrect
+	 */
+	public CssHeight(ApplContext ac, CssExpression expression, boolean check)
+			throws InvalidParamException {
 
-    /**
-     * Returns the value of this property.
-     */
-    public Object get() {
-        if (identVal != null) {
-            return identVal;
-        }
-        if (perVal != null) {
-            return perVal;
-        }
-        return lenVal;
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    /**
-     * Returns true if this property is "softly" inherited
-     * e.g. his value equals inherit
-     */
-    public boolean isSoftlyInherited() {
-        return identVal == inherit;
-    }
+		CssValue val = expression.getValue();
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        if (identVal != null) {
-            return identVal.toString();
-        }
-        if (perVal != null) {
-            return perVal.toString();
-        }
-        if (lenVal != null) {
-            return lenVal.toString();
-        }
-        // the default
-        return auto.toString();
-    }
+		setByUser();
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param property The other property.
-     */
-    public boolean equals(CssProperty property) {
-        try {
-            CssHeight h = (CssHeight) property;
-            return (identVal == h.identVal) &&
-                    ((perVal == null && h.perVal == null) ||
-                            (perVal != null && perVal.equals(h.perVal))) &&
-                    ((lenVal == null && h.lenVal == null) ||
-                            (lenVal != null && lenVal.equals(h.lenVal)));
+		switch (val.getType()) {
+			case CssTypes.CSS_IDENT:
+				CssIdent ident = (CssIdent) val;
+				if (auto.equals(val)) {
+					value = auto;
+				} else {
+					throw new InvalidParamException("unrecognize", ac);
+				}
+				break;
+			case CssTypes.CSS_NUMBER:
+				val = ((CssNumber) val).getLength();
+			case CssTypes.CSS_LENGTH:
+				CssLength l = (CssLength) val;
+				if (!l.isPositive()) {
+					throw new InvalidParamException("negative-value",
+							val.toString(), ac);
+				}
+				value = l;
+				break;
+			case CssTypes.CSS_PERCENTAGE:
+				CssPercentage p = (CssPercentage) val;
+				if (!p.isPositive()) {
+					throw new InvalidParamException("negative-value",
+							val.toString(), ac);
+				}
+				value = p;
+				break;
+			default:
+				throw new InvalidParamException("value", val, getPropertyName(), ac);
+		}
+		expression.next();
+	}
 
-        } catch (ClassCastException ex) {
-            return false;
-        }
-    }
+	public CssHeight(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 identVal == auto;
-    }
+	/**
+	 * 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 value == auto;
+	}
 
 }

Index: CssWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssWidth.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssWidth.java	9 Feb 2012 17:36:29 -0000	1.6
+++ CssWidth.java	6 Sep 2012 12:37:56 -0000	1.7
@@ -4,7 +4,6 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css1;
 
-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,137 +15,77 @@
 import org.w3c.css.values.CssValue;
 
 /**
- * @version $Revision$
  * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#width
  */
 public class CssWidth extends org.w3c.css.properties.css.CssWidth {
 
-    CssLength lenVal;
-    CssPercentage perVal;
-    CssIdent identVal;
-
-    /**
-     * Create a new CssWidth
-     */
-    public CssWidth() {
-    }
-
-    /**
-     * Create a new CssWidth.
-     *
-     * @param expression The expression for this property
-     * @throws InvalidParamException Values are incorrect
-     */
-    public CssWidth(ApplContext ac, CssExpression expression, boolean check)
-            throws InvalidParamException {
-
-        if (check && expression.getCount() > 1) {
-            throw new InvalidParamException("unrecognize", ac);
-        }
-
-        CssValue val = expression.getValue();
-
-        setByUser();
-
-        switch (val.getType()) {
-            case CssTypes.CSS_IDENT:
-                CssIdent ident = (CssIdent) val;
-                if (auto.equals(val)) {
-                    identVal = auto;
-                } else {
-                    throw new InvalidParamException("unrecognize", ac);
-                }
-                break;
-            case CssTypes.CSS_NUMBER:
-                val = ((CssNumber) val).getLength();
-            case CssTypes.CSS_LENGTH:
-                lenVal = (CssLength) val;
-                if (!lenVal.isPositive()) {
-                    throw new InvalidParamException("negative-value",
-                            val.toString(), ac);
-                }
-                break;
-            case CssTypes.CSS_PERCENTAGE:
-                perVal = (CssPercentage) val;
-                if (perVal.floatValue() < 0.) {
-                    throw new InvalidParamException("negative-value",
-                            val.toString(), ac);
-                }
-                break;
-            default:
-                throw new InvalidParamException("value", val, getPropertyName(), ac);
-        }
-        expression.next();
-    }
+	/**
+	 * Create a new CssWidth
+	 */
+	public CssWidth() {
+	}
 
-    public CssWidth(ApplContext ac, CssExpression expression)
-            throws InvalidParamException {
-        this(ac, expression, false);
-    }
+	/**
+	 * Create a new CssWidth.
+	 *
+	 * @param expression The expression for this property
+	 * @throws InvalidParamException Values are incorrect
+	 */
+	public CssWidth(ApplContext ac, CssExpression expression, boolean check)
+			throws InvalidParamException {
 
-    /**
-     * Returns the value of this property.
-     */
-    public Object get() {
-        if (identVal != null) {
-            return identVal;
-        }
-        if (perVal != null) {
-            return perVal;
-        }
-        return lenVal;
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    /**
-     * Returns true if this property is "softly" inherited
-     * e.g. his value equals inherit
-     */
-    public boolean isSoftlyInherited() {
-        return identVal == inherit;
-    }
+		CssValue val = expression.getValue();
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        if (identVal != null) {
-            return identVal.toString();
-        }
-        if (perVal != null) {
-            return perVal.toString();
-        }
-        if (lenVal != null) {
-            return lenVal.toString();
-        }
-        // the default
-        return auto.toString();
-    }
+		setByUser();
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param property The other property.
-     */
-    public boolean equals(CssProperty property) {
-        try {
-            CssWidth w = (CssWidth) property;
-            return (identVal == w.identVal) &&
-                    ((perVal == null && w.perVal == null) ||
-                            (perVal != null && perVal.equals(w.perVal))) &&
-                    ((lenVal == null && w.lenVal == null) ||
-                            (lenVal != null && lenVal.equals(w.lenVal)));
+		switch (val.getType()) {
+			case CssTypes.CSS_IDENT:
+				CssIdent ident = (CssIdent) val;
+				if (auto.equals(val)) {
+					value = auto;
+				} else {
+					throw new InvalidParamException("unrecognize", ac);
+				}
+				break;
+			case CssTypes.CSS_NUMBER:
+				val = ((CssNumber) val).getLength();
+			case CssTypes.CSS_LENGTH:
+				CssLength l = (CssLength) val;
+				if (!l.isPositive()) {
+					throw new InvalidParamException("negative-value",
+							val.toString(), ac);
+				}
+				value = l;
+				break;
+			case CssTypes.CSS_PERCENTAGE:
+				CssPercentage p = (CssPercentage) val;
+				if (!p.isPositive()) {
+					throw new InvalidParamException("negative-value",
+							val.toString(), ac);
+				}
+				value = p;
+				break;
+			default:
+				throw new InvalidParamException("value", val, getPropertyName(), ac);
+		}
+		expression.next();
+	}
 
-        } catch (ClassCastException ex) {
-            return false;
-        }
-    }
+	public CssWidth(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 identVal == auto;
-    }
+	/**
+	 * 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 value == auto;
+	}
 
 }
Received on Thursday, 6 September 2012 12:38:33 UTC

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