- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 06 Sep 2012 12:37:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2 In directory hutz:/tmp/cvs-serv26889/properties/css2 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/css2/CssHeight.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssHeight.java 9 Feb 2012 17:36:30 -0000 1.2 +++ CssHeight.java 6 Sep 2012 12:37:56 -0000 1.3 @@ -4,7 +4,6 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css2; -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,10 +20,6 @@ */ public class CssHeight extends org.w3c.css.properties.css.CssHeight { - CssLength lenVal; - CssPercentage perVal; - CssIdent identVal; - /** * Create a new CssHeight */ @@ -52,9 +47,9 @@ case CssTypes.CSS_IDENT: CssIdent ident = (CssIdent) val; if (inherit.equals(val)) { - identVal = inherit; + value = inherit; } else if (auto.equals(val)) { - identVal = auto; + value = auto; } else { throw new InvalidParamException("unrecognize", ac); } @@ -62,18 +57,20 @@ case CssTypes.CSS_NUMBER: val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: - lenVal = (CssLength) val; - if (!lenVal.isPositive()) { + CssLength l = (CssLength) val; + if (!l.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); } + value = l; break; case CssTypes.CSS_PERCENTAGE: - perVal = (CssPercentage) val; - if (perVal.floatValue() < 0.) { + 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); @@ -87,68 +84,11 @@ } /** - * Returns the value of this property. - */ - public Object get() { - if (identVal != null) { - return identVal; - } - if (perVal != null) { - return perVal; - } - return lenVal; - } - - /** - * Returns true if this property is "softly" inherited - * e.g. his value equals inherit - */ - public boolean isSoftlyInherited() { - return identVal == inherit; - } - - /** - * 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(); - } - - /** - * 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))); - - } catch (ClassCastException ex) { - return 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; + return value == auto; } } Index: CssWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssWidth.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssWidth.java 9 Feb 2012 17:36:31 -0000 1.2 +++ CssWidth.java 6 Sep 2012 12:37:56 -0000 1.3 @@ -4,7 +4,6 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css2; -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,10 +20,6 @@ */ public class CssWidth extends org.w3c.css.properties.css.CssWidth { - CssLength lenVal; - CssPercentage perVal; - CssIdent identVal; - /** * Create a new CssWidth */ @@ -52,9 +47,9 @@ case CssTypes.CSS_IDENT: CssIdent ident = (CssIdent) val; if (inherit.equals(val)) { - identVal = inherit; + value = inherit; } else if (auto.equals(val)) { - identVal = auto; + value = auto; } else { throw new InvalidParamException("unrecognize", ac); } @@ -62,18 +57,20 @@ case CssTypes.CSS_NUMBER: val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: - lenVal = (CssLength) val; + CssLength lenVal = (CssLength) val; if (!lenVal.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); } + value = lenVal; break; case CssTypes.CSS_PERCENTAGE: - perVal = (CssPercentage) val; - if (perVal.floatValue() < 0.) { + CssPercentage perVal = (CssPercentage) val; + if (!perVal.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); } + value = perVal; break; default: throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -87,68 +84,11 @@ } /** - * Returns the value of this property. - */ - public Object get() { - if (identVal != null) { - return identVal; - } - if (perVal != null) { - return perVal; - } - return lenVal; - } - - /** - * Returns true if this property is "softly" inherited - * e.g. his value equals inherit - */ - public boolean isSoftlyInherited() { - return identVal == inherit; - } - - /** - * 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(); - } - - /** - * 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))); - - } catch (ClassCastException ex) { - return 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; + return value == auto; } }
Received on Thursday, 6 September 2012 12:38:37 UTC