2002/css-validator/org/w3c/css/values CssLength.java,1.9,1.10 CssNumber.java,1.12,1.13 CssPercentage.java,1.10,1.11 CssValue.java,1.7,1.8

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

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

Index: CssPercentage.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssPercentage.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CssPercentage.java	9 Feb 2012 17:36:33 -0000	1.10
+++ CssPercentage.java	6 Sep 2012 12:37:58 -0000	1.11
@@ -36,123 +36,126 @@
  */
 public class CssPercentage extends CssValue {
 
-    public static final int type = CssTypes.CSS_PERCENTAGE;
+	public static final int type = CssTypes.CSS_PERCENTAGE;
 
-    public final int getType() {
-        return type;
-    }
+	public final int getType() {
+		return type;
+	}
 
-    private BigDecimal defaultValue = BigDecimal.ZERO;
-    private BigDecimal value;
+	private BigDecimal defaultValue = BigDecimal.ZERO;
+	private BigDecimal value;
 
-    /**
-     * Create a new CssPercentage
-     */
-    public CssPercentage() {
-        this.value = defaultValue;
-    }
+	/**
+	 * Create a new CssPercentage
+	 */
+	public CssPercentage() {
+		this.value = defaultValue;
+	}
 
-    /**
-     * Create a new CssPercentage with a number
-     *
-     * @param value The value.
-     */
-    public CssPercentage(int value) {
-        this(new BigDecimal(value));
-    }
+	/**
+	 * Create a new CssPercentage with a number
+	 *
+	 * @param value The value.
+	 */
+	public CssPercentage(int value) {
+		this(new BigDecimal(value));
+	}
 
-    /**
-     * Create a new CssPercentage with a float
-     *
-     * @param value the float value.
-     */
-    public CssPercentage(float value) {
-        this(new BigDecimal(value));
-    }
+	/**
+	 * Create a new CssPercentage with a float
+	 *
+	 * @param value the float value.
+	 */
+	public CssPercentage(float value) {
+		this(new BigDecimal(value));
+	}
 
-    /**
-     * Create a new CssPercentage with a Float value.
-     *
-     * @param value the Float object.
-     */
-    public CssPercentage(BigDecimal value) {
-        this.value = value;
-    }
+	/**
+	 * Create a new CssPercentage with a Float value.
+	 *
+	 * @param value the Float object.
+	 */
+	public CssPercentage(BigDecimal value) {
+		this.value = value;
+	}
 
-    /**
-     * Set the value of this percentage.
-     *
-     * @param s  the string representation of the percentage.
-     * @param ac For errors and warnings reports.
-     * @throws InvalidParamException The unit is incorrect
-     */
-    public void set(String s, ApplContext ac) throws InvalidParamException {
-        int slength = s.length();
-        if (s.charAt(slength - 1) != '%') {
-            throw new InvalidParamException("percentage", s, ac);
-        }
-        this.value = new BigDecimal(s.substring(0, slength - 1));
-    }
+	/**
+	 * Set the value of this percentage.
+	 *
+	 * @param s  the string representation of the percentage.
+	 * @param ac For errors and warnings reports.
+	 * @throws InvalidParamException The unit is incorrect
+	 */
+	public void set(String s, ApplContext ac) throws InvalidParamException {
+		int slength = s.length();
+		if (s.charAt(slength - 1) != '%') {
+			throw new InvalidParamException("percentage", s, ac);
+		}
+		this.value = new BigDecimal(s.substring(0, slength - 1));
+	}
 
-    /**
-     * Returns the current value
-     */
-    public Object get() {
-        // TODO FIXME
-        return new Float(value.floatValue());
-    }
+	/**
+	 * Returns the current value
+	 */
+	public Object get() {
+		// TODO FIXME
+		return new Float(value.floatValue());
+	}
 
-    /**
-     * Returns true is the value is positive of null
-     *
-     * @return a boolean
-     */
-    public boolean isPositive() {
-        return (value.signum() >= 0);
-    }
+	/**
+	 * Returns true is the value is positive of null
+	 *
+	 * @return a boolean
+	 */
+	public boolean isPositive() {
+		return (value.signum() >= 0);
+	}
 
-    /**
-     * Returns true is the value is positive of null
-     *
-     * @return a boolean
-     */
-    public boolean isStrictlyPositive() {
-        return (value.signum() == 1);
-    }
+	/**
+	 * Returns true is the value is positive of null
+	 *
+	 * @return a boolean
+	 */
+	public boolean isStrictlyPositive() {
+		return (value.signum() == 1);
+	}
 
-    /**
-     * Returns true is the value is zero
-     *
-     * @return a boolean
-     */
-    public boolean isZero() {
-        return BigDecimal.ZERO.equals(value);
-    }
+	/**
+	 * Returns true is the value is zero
+	 *
+	 * @return a boolean
+	 */
+	public boolean isZero() {
+		return BigDecimal.ZERO.equals(value);
+	}
 
-    /**
-     * Returns the value as a float
-     */
-    public float floatValue() {
-        return value.floatValue();
-    }
+	/**
+	 * Returns the value as a float
+	 */
+	public float floatValue() {
+		return value.floatValue();
+	}
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(value.toPlainString()).append('%');
-        return sb.toString();
-    }
+	/**
+	 * Returns a string representation of the object.
+	 */
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(value.toPlainString()).append('%');
+		return sb.toString();
+	}
 
-    /**
-     * Compares two values for equality.
-     *
-     * @param val The other value.
-     */
-    public boolean equals(Object val) {
-        return ((val instanceof CssPercentage)
-                && value.equals(((CssPercentage) val).value));
-    }
+	/**
+	 * Compares two values for equality.
+	 *
+	 * @param val The other value.
+	 */
+	public boolean equals(Object val) {
+		return ((val instanceof CssPercentage)
+				&& value.equals(((CssPercentage) val).value));
+	}
 
+	public CssPercentage getPercentage() throws InvalidParamException {
+		return this;
+	}
 }

Index: CssLength.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssLength.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CssLength.java	9 Feb 2012 17:36:33 -0000	1.9
+++ CssLength.java	6 Sep 2012 12:37:58 -0000	1.10
@@ -91,137 +91,142 @@
  */
 public class CssLength extends CssValue {
 
-    public static final int type = CssTypes.CSS_LENGTH;
+	public static final int type = CssTypes.CSS_LENGTH;
 
-    public final int getType() {
-        return type;
-    }
+	public final int getType() {
+		return type;
+	}
 
 
-    private BigDecimal value;
-    private int unit;
-    private static String[] units = {"mm", "cm", "pt", "pc", "em",
-            "ex", "px", "in", "gd"};
-    private static int[] hash_units;
+	private BigDecimal value;
+	private int unit;
+	private static String[] units = {"mm", "cm", "pt", "pc", "em",
+			"ex", "px", "in", "gd"};
+	private static int[] hash_units;
 
-    static {
-        hash_units = new int[units.length];
-        for (int i = 0; i < units.length; i++)
-            hash_units[i] = units[i].hashCode();
-    }
+	static {
+		hash_units = new int[units.length];
+		for (int i = 0; i < units.length; i++)
+			hash_units[i] = units[i].hashCode();
+	}
 
-    /**
-     * Create a new CssLength
-     */
-    public CssLength() {
-        value = BigDecimal.ZERO;
-    }
+	/**
+	 * Create a new CssLength
+	 */
+	public CssLength() {
+		value = BigDecimal.ZERO;
+	}
 
-    /**
-     * Set the value of this length.
-     *
-     * @param s the string representation of the length.
-     * @throws InvalidParamException The unit is incorrect
-     */
-    public void set(String s, ApplContext ac) throws InvalidParamException {
-        s = s.toLowerCase();
-        int length = s.length();
-        String unit = s.substring(length - 2, length);
-        this.value = new BigDecimal(s.substring(0, length - 2));
+	/**
+	 * Set the value of this length.
+	 *
+	 * @param s the string representation of the length.
+	 * @throws InvalidParamException The unit is incorrect
+	 */
+	public void set(String s, ApplContext ac) throws InvalidParamException {
+		s = s.toLowerCase();
+		int length = s.length();
+		String unit = s.substring(length - 2, length);
+		this.value = new BigDecimal(s.substring(0, length - 2));
 
-        this.unit = 2; // there is no unit by default
+		this.unit = 2; // there is no unit by default
 
-        if (unit.equals("gd") && (cssversion.equals("css2"))) {
-            throw new InvalidParamException("unit", unit, ac);
-        }
+		if (unit.equals("gd") && (cssversion.equals("css2"))) {
+			throw new InvalidParamException("unit", unit, ac);
+		}
 
-        if (value.floatValue() != 0) {
-            int hash = unit.hashCode();
-            int i = 0;
-            while (i < units.length) {
-                if (hash == hash_units[i]) {
-                    this.unit = i;
-                    return;
-                }
-                i++;
-            }
-        } else {
-            return;
-        }
+		if (value.floatValue() != 0) {
+			int hash = unit.hashCode();
+			int i = 0;
+			while (i < units.length) {
+				if (hash == hash_units[i]) {
+					this.unit = i;
+					return;
+				}
+				i++;
+			}
+		} else {
+			return;
+		}
 
-        throw new InvalidParamException("unit", unit, ac);
-    }
+		throw new InvalidParamException("unit", unit, ac);
+	}
 
-    /**
-     * Returns the current value
-     */
-    public Object get() {
-        // TODO this is old ugly crap, needed for not breaking everything
-        // remove as soon as reference to get is removed...
-        return new Float(value.floatValue());
-    }
+	// return self
+	public CssLength getLength() throws InvalidParamException {
+		return this;
+	}
 
-    /**
-     * return the float value
-     */
-    public float floatValue() {
-        return value.floatValue();
-    }
+	/**
+	 * Returns the current value
+	 */
+	public Object get() {
+		// TODO this is old ugly crap, needed for not breaking everything
+		// remove as soon as reference to get is removed...
+		return new Float(value.floatValue());
+	}
 
-    /**
-     * Returns true is the value is positive of null
-     *
-     * @return a boolean
-     */
-    public boolean isPositive() {
-        return (value.signum() >= 0);
-    }
+	/**
+	 * return the float value
+	 */
+	public float floatValue() {
+		return value.floatValue();
+	}
 
-    /**
-     * Returns true is the value is positive of null
-     *
-     * @return a boolean
-     */
-    public boolean isStrictlyPositive() {
-        return (value.signum() == 1);
-    }
+	/**
+	 * Returns true is the value is positive of null
+	 *
+	 * @return a boolean
+	 */
+	public boolean isPositive() {
+		return (value.signum() >= 0);
+	}
 
-    /**
-     * Returns true is the value is zero
-     *
-     * @return a boolean
-     */
-    public boolean isZero() {
-        return BigDecimal.ZERO.equals(value);
-    }
+	/**
+	 * Returns true is the value is positive of null
+	 *
+	 * @return a boolean
+	 */
+	public boolean isStrictlyPositive() {
+		return (value.signum() == 1);
+	}
 
-    /**
-     * Returns the current value
-     */
-    public String getUnit() {
-        return units[unit];
-    }
+	/**
+	 * Returns true is the value is zero
+	 *
+	 * @return a boolean
+	 */
+	public boolean isZero() {
+		return BigDecimal.ZERO.equals(value);
+	}
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-        if (BigDecimal.ZERO.equals(value)) {
-            return value.toPlainString();
-        }
-        return value.toPlainString() + getUnit();
-    }
+	/**
+	 * Returns the current value
+	 */
+	public String getUnit() {
+		return units[unit];
+	}
 
-    /**
-     * Compares two values for equality.
-     *
-     * @param value The other value.
-     */
-    public boolean equals(Object value) {
-        return (value instanceof CssLength &&
-                this.value.equals(((CssLength) value).value) &&
-                unit == ((CssLength) value).unit);
-    }
+	/**
+	 * Returns a string representation of the object.
+	 */
+	public String toString() {
+		if (BigDecimal.ZERO.equals(value)) {
+			return value.toPlainString();
+		}
+		return value.toPlainString() + getUnit();
+	}
+
+	/**
+	 * Compares two values for equality.
+	 *
+	 * @param value The other value.
+	 */
+	public boolean equals(Object value) {
+		return (value instanceof CssLength &&
+				this.value.equals(((CssLength) value).value) &&
+				unit == ((CssLength) value).unit);
+	}
 
 }
 

Index: CssNumber.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssNumber.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- CssNumber.java	9 Feb 2012 17:36:33 -0000	1.12
+++ CssNumber.java	6 Sep 2012 12:37:58 -0000	1.13
@@ -206,6 +206,10 @@
                 value.toString(), "frequency", ac);
     }
 
+	public CssNumber getNumber() throws InvalidParamException {
+		return this;
+	}
+
     /**
      * Returns a string representation of the object.
      */

Index: CssValue.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssValue.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssValue.java	5 Jan 2010 13:50:01 -0000	1.7
+++ CssValue.java	6 Sep 2012 12:37:58 -0000	1.8
@@ -14,44 +14,55 @@
  */
 public abstract class CssValue {
 
-    public static int type = CssTypes.CSS_UNKNOWN;
+	public static int type = CssTypes.CSS_UNKNOWN;
 
-    String cssversion;
+	String cssversion;
 
-    public int getType() {
-        return type;
-    }
+	public int getType() {
+		return type;
+	}
 
-    /**
-     * Set the value of this value.
-     *
-     * @param s  the string representation of the value.
-     * @param ac For errors and warnings reports.
-     * @throws InvalidParamException The unit is incorrect
-     */
-    public abstract void set(String s, ApplContext ac)
-            throws InvalidParamException;
+	/**
+	 * Set the value of this value.
+	 *
+	 * @param s  the string representation of the value.
+	 * @param ac For errors and warnings reports.
+	 * @throws InvalidParamException The unit is incorrect
+	 */
+	public abstract void set(String s, ApplContext ac)
+			throws InvalidParamException;
 
-    /**
-     * @return the internal value
-     */
-    public abstract Object get();
+	/**
+	 * @return the internal value
+	 */
+	public abstract Object get();
 
-    /**
-     * Compares two values for equality.
-     *
-     * @param value The other value.
-     */
-    public boolean equals(Object value) {
-        return super.equals(value);
-    }
+	/**
+	 * Compares two values for equality.
+	 *
+	 * @param value The other value.
+	 */
+	public boolean equals(Object value) {
+		return super.equals(value);
+	}
 
-    public void setCssVersion(String cssversion) {
-        this.cssversion = cssversion;
-    }
+	public void setCssVersion(String cssversion) {
+		this.cssversion = cssversion;
+	}
 
-    public boolean isDefault() {
-        return false;
-    }
+	public boolean isDefault() {
+		return false;
+	}
+
+	public CssLength getLength() throws InvalidParamException {
+		throw new ClassCastException("unknown");
+	}
 
+	public CssPercentage getPercentage() throws InvalidParamException {
+		throw new ClassCastException("unknown");
+	}
+
+	public CssNumber getNumber() throws InvalidParamException {
+		throw new ClassCastException("unknown");
+	}
 }

Received on Thursday, 6 September 2012 12:38:07 UTC