- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 28 Sep 2012 18:37:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv13504 Modified Files: CssAngle.java CssFrequency.java CssLength.java CssNumber.java CssPercentage.java CssResolution.java CssTime.java Log Message: patch from Hannes Erven, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=19011 Index: CssResolution.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssResolution.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CssResolution.java 7 Sep 2012 20:41:11 -0000 1.10 +++ CssResolution.java 28 Sep 2012 18:37:56 -0000 1.11 @@ -109,7 +109,7 @@ * Returns a string representation of the object. */ public String toString() { - return value.toPlainString() + ((BigDecimal.ZERO.equals(value)) ? "dpi" : unit); + return value.toPlainString() + ((BigDecimal.ZERO.compareTo(value) == 0) ? "dpi" : unit); } /** Index: CssTime.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssTime.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CssTime.java 21 Sep 2012 14:16:26 -0000 1.10 +++ CssTime.java 28 Sep 2012 18:37:56 -0000 1.11 @@ -30,40 +30,40 @@ */ public class CssTime extends CssCheckableValue { - public static final int type = CssTypes.CSS_TIME; + public static final int type = CssTypes.CSS_TIME; - public final int getType() { - return type; - } + public final int getType() { + return type; + } private BigDecimal value; protected String unit; protected BigDecimal factor = BigDecimal.ONE; - /** - * Create a new CssTime. - */ - public CssTime() { - value = BigDecimal.ZERO; - } + /** + * Create a new CssTime. + */ + public CssTime() { + value = BigDecimal.ZERO; + } - /** - * Create a new CssTime with a Float object. - * - * @param value the Float object - */ - public CssTime(Float value) { - this.value = new BigDecimal(value); - } + /** + * Create a new CssTime with a Float object. + * + * @param value the Float object + */ + public CssTime(Float value) { + this.value = new BigDecimal(value); + } - /** - * Set the value of this time. - * - * @param s the string representation of the time. - * @param ac For errors and warnings reports. - * @throws InvalidParamException The unit is incorrect - */ - public void set(String s, ApplContext ac) throws InvalidParamException { + /** + * Set the value of this time. + * + * @param s the string representation of the time. + * @param ac For errors and warnings reports. + * @throws InvalidParamException The unit is incorrect + */ + public void set(String s, ApplContext ac) throws InvalidParamException { String low_s = s.toLowerCase(); int length = low_s.length(); int unitIdx = length - 1; @@ -100,47 +100,48 @@ } - /** - * Returns the current value - * Float - * TODO move to a BigDecimal - */ - public Object get() { + /** + * Returns the current value + * Float + * TODO move to a BigDecimal + */ + public Object get() { return value.multiply(factor).floatValue(); } - /** - * Returns the current value - */ - public String getUnit() { - return unit; - } + /** + * Returns the current value + */ + public String getUnit() { + return unit; + } - /** - * Returns a string representation of the object. - */ - public String toString() { - if (BigDecimal.ZERO.equals(value)) { - return value.toPlainString(); - } - return value.toPlainString() + unit; - } + /** + * Returns a string representation of the object. + */ + public String toString() { + if (BigDecimal.ZERO.compareTo(value) == 0) { + return value.toPlainString(); + } + return value.toPlainString() + unit; + } - /** - * Compares two values for equality. - * - * @param other The other value. - */ - public boolean equals(Object other) { - if (((CssValue)other).getType() == getType()) { - return get().equals(((CssValue)other).get()); + /** + * Compares two values for equality. + * + * @param other The other value. + */ + public boolean equals(Object other) { + if (((CssValue) other).getType() == getType()) { + return get().equals(((CssValue) other).get()); } return false; } /** * set the native value + * * @param v the BigDecimal */ public void setValue(BigDecimal v) { @@ -171,12 +172,13 @@ * @return a boolean */ public boolean isZero() { - return BigDecimal.ZERO.equals(value); + return (BigDecimal.ZERO.compareTo(value) == 0); } /** * check if the value is positive or null - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -190,7 +192,8 @@ /** * check if the value is strictly positive - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ Index: CssNumber.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssNumber.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- CssNumber.java 21 Sep 2012 14:16:26 -0000 1.17 +++ CssNumber.java 28 Sep 2012 18:37:56 -0000 1.18 @@ -75,6 +75,7 @@ isInt = false; } } + /** * Set the value explicitly */ @@ -146,7 +147,7 @@ * @return a boolean */ public boolean isZero() { - return BigDecimal.ZERO.equals(value); + return (BigDecimal.ZERO.compareTo(value) == 0); } /** @@ -156,7 +157,7 @@ * @throws InvalidParamException The value is not zero */ public CssLength getLength() throws InvalidParamException { - if (value.equals(BigDecimal.ZERO)) { + if (value.compareTo(BigDecimal.ZERO) == 0) { return new CssLength(); } throw new InvalidParamException("zero", "length", ac); @@ -169,7 +170,7 @@ * @throws InvalidParamException The value is not zero */ public CssPercentage getPercentage() throws InvalidParamException { - if (value.equals(BigDecimal.ZERO)) { + if (value.compareTo(BigDecimal.ZERO) == 0) { return new CssPercentage(); } throw new InvalidParamException("zero", @@ -184,7 +185,7 @@ * @throws InvalidParamException The value is not zero */ public CssTime getTime() throws InvalidParamException { - if (value.equals(BigDecimal.ZERO)) { + if (value.compareTo(BigDecimal.ZERO) == 0) { return new CssTime(); } throw new InvalidParamException("zero", value.toString(), @@ -198,7 +199,7 @@ * @throws InvalidParamException The value is not zero */ public CssAngle getAngle() throws InvalidParamException { - if (value.equals(BigDecimal.ZERO)) { + if (value.compareTo(BigDecimal.ZERO) == 0) { return new CssAngle(); } throw new InvalidParamException("zero", value.toString(), @@ -212,7 +213,7 @@ * @throws InvalidParamException The value is not zero */ public CssFrequency getFrequency() throws InvalidParamException { - if (value.equals(BigDecimal.ZERO)) { + if (value.compareTo(BigDecimal.ZERO) == 0) { return new CssFrequency(); } throw new InvalidParamException("zero", @@ -242,7 +243,8 @@ /** * check if the value is positive or null - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -256,7 +258,8 @@ /** * check if the value is strictly positive - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -270,7 +273,8 @@ /** * check if the value is an integer - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ Index: CssFrequency.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssFrequency.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CssFrequency.java 21 Sep 2012 14:16:26 -0000 1.10 +++ CssFrequency.java 28 Sep 2012 18:37:56 -0000 1.11 @@ -121,8 +121,8 @@ * Returns a string representation of the object. */ public String toString() { - if (BigDecimal.ZERO.equals(value)) { - return value.toPlainString(); + if (BigDecimal.ZERO.compareTo(value) == 0) { + return BigDecimal.ZERO.toPlainString(); } return value.toPlainString() + unit; } @@ -171,7 +171,7 @@ * @return a boolean */ public boolean isZero() { - return BigDecimal.ZERO.equals(value); + return (BigDecimal.ZERO.compareTo(value) == 0); } /** Index: CssPercentage.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssPercentage.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CssPercentage.java 21 Sep 2012 14:16:26 -0000 1.13 +++ CssPercentage.java 28 Sep 2012 18:37:56 -0000 1.14 @@ -97,6 +97,7 @@ /** * set the native value + * * @param v the BigDecimal */ public void setValue(BigDecimal v) { @@ -135,7 +136,7 @@ * @return a boolean */ public boolean isZero() { - return BigDecimal.ZERO.equals(value); + return (BigDecimal.ZERO.compareTo(value) == 0); } /** @@ -170,7 +171,8 @@ /** * check if the value is positive or null - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -184,7 +186,8 @@ /** * check if the value is strictly positive - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ Index: CssAngle.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssAngle.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- CssAngle.java 21 Sep 2012 14:16:26 -0000 1.13 +++ CssAngle.java 28 Sep 2012 18:37:56 -0000 1.14 @@ -71,6 +71,7 @@ /** * set the native value + * * @param v the BigDecimal */ public void setValue(BigDecimal v) { @@ -142,7 +143,7 @@ * Returns a string representation of the object. */ public String toString() { - return value.toPlainString() + ((BigDecimal.ZERO.equals(value)) ? "deg" : unit); + return value.toPlainString() + ((BigDecimal.ZERO.compareTo(value) == 0) ? "deg" : unit); } /** @@ -199,7 +200,8 @@ /** * check if the value is positive or null - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -213,7 +215,8 @@ /** * check if the value is strictly positive - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ Index: CssLength.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssLength.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- CssLength.java 21 Sep 2012 14:16:26 -0000 1.16 +++ CssLength.java 28 Sep 2012 18:37:56 -0000 1.17 @@ -162,6 +162,7 @@ /** * set the native value + * * @param v the BigDecimal */ public void setValue(BigDecimal v) { @@ -213,7 +214,7 @@ * @return a boolean */ public boolean isZero() { - return BigDecimal.ZERO.equals(value); + return (BigDecimal.ZERO.compareTo(value) == 0); } /** @@ -241,8 +242,8 @@ * Returns a string representation of the object. */ public String toString() { - if (BigDecimal.ZERO.equals(value)) { - return value.toPlainString(); + if (BigDecimal.ZERO.compareTo(value) == 0) { + return BigDecimal.ZERO.toPlainString(); } return value.toPlainString() + unit; } @@ -261,7 +262,8 @@ /** * check if the value is positive or null - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */ @@ -275,7 +277,8 @@ /** * check if the value is strictly positive - * @param ac the validation context + * + * @param ac the validation context * @param property the property the value is defined in * @throws InvalidParamException */
Received on Friday, 28 September 2012 18:38:00 UTC