2002/css-validator/org/w3c/css/values CssCheckableValue.java,1.1,1.2 CssLength.java,1.13,1.14 CssNumber.java,1.14,1.15

Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv13364/values

Modified Files:
	CssCheckableValue.java CssLength.java CssNumber.java 
Log Message:
tarting the use of range checking in values (useful for CSS3 and onward only)

Index: CssLength.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssLength.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- CssLength.java	7 Sep 2012 20:41:11 -0000	1.13
+++ CssLength.java	10 Sep 2012 11:58:31 -0000	1.14
@@ -7,6 +7,7 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.values;
 
+import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 
@@ -89,7 +90,7 @@
  * @version $Revision$
  * @see CssPercentage
  */
-public class CssLength extends CssValue {
+public class CssLength extends CssCheckableValue {
 
 	public static final int type = CssTypes.CSS_LENGTH;
 
@@ -248,5 +249,47 @@
 				unit.equals(((CssLength) value).unit));
 	}
 
+
+	/**
+	 * check if the value is positive or null
+	 * @param ac the validation context
+	 * @param property the property the value is defined in
+	 * @throws InvalidParamException
+	 */
+	public void checkPositiveness(ApplContext ac, CssProperty property)
+			throws InvalidParamException {
+		if (!isPositive()) {
+			throw new InvalidParamException("negative-value",
+					toString(), property.getPropertyName(), ac);
+		}
+	}
+
+	/**
+	 * check if the value is strictly positive
+	 * @param ac the validation context
+	 * @param property the property the value is defined in
+	 * @throws InvalidParamException
+	 */
+	public void checkStrictPositiveness(ApplContext ac, CssProperty property)
+			throws InvalidParamException {
+		if (!isStrictlyPositive()) {
+			throw new InvalidParamException("negative-value",
+					toString(), property.getPropertyName(), ac);
+		}
+	}
+
+	/**
+	 * check if the value is an integer
+	 * @param ac the validation context
+	 * @param property the property the value is defined in
+	 * @throws InvalidParamException
+	 */
+	public void checkInteger(ApplContext ac, CssProperty property)
+			throws InvalidParamException {
+	}
+
+	public boolean isInteger() {
+		return false;
+	}
 }
 

Index: CssCheckableValue.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssCheckableValue.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssCheckableValue.java	10 Sep 2012 11:47:18 -0000	1.1
+++ CssCheckableValue.java	10 Sep 2012 11:58:31 -0000	1.2
@@ -12,13 +12,18 @@
 
 public abstract class CssCheckableValue extends CssValue {
 
+	abstract boolean isPositive();
+
 	abstract void checkPositiveness(ApplContext ac, CssProperty property)
 			throws InvalidParamException;
 
+	abstract boolean isStrictlyPositive();
+
 	abstract void checkStrictPositiveness(ApplContext ac, CssProperty property)
 			throws InvalidParamException;
 
-	abstract boolean isPositive();
+	abstract boolean isInteger();
 
-	abstract boolean isStrictlyPositive();
+	abstract void checkInteger(ApplContext ac, CssProperty property)
+			throws InvalidParamException;
 }

Index: CssNumber.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssNumber.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- CssNumber.java	10 Sep 2012 11:47:18 -0000	1.14
+++ CssNumber.java	10 Sep 2012 11:58:31 -0000	1.15
@@ -255,4 +255,18 @@
 					toString(), property.getPropertyName(), ac);
 		}
 	}
+
+	/**
+	 * check if the value is an integer
+	 * @param ac the validation context
+	 * @param property the property the value is defined in
+	 * @throws InvalidParamException
+	 */
+	public void checkInteger(ApplContext ac, CssProperty property)
+			throws InvalidParamException {
+		if (!isInteger()) {
+			throw new InvalidParamException("integer",
+					toString(), property.getPropertyName(), ac);
+		}
+	}
 }

Received on Monday, 10 September 2012 11:58:38 UTC