- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 06 Sep 2012 12:38:00 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3 In directory hutz:/tmp/cvs-serv26889/properties/css3 Modified Files: CssBackgroundPosition.java CssBackgroundSize.java CssBorder.java CssBorderImageOutset.java CssBorderImageSlice.java CssBorderImageWidth.java CssBorderRadius.java CssBorderWidth.java CssBoxShadow.java CssColumnCount.java CssColumnGap.java CssColumnWidth.java CssFontFeatureSettings.java CssFontSize.java CssFontWeight.java CssHeight.java CssLetterSpacing.java CssLineHeight.java CssMarqueePlayCount.java CssOpacity.java CssTabSize.java CssTextIndent.java CssTextShadow.java CssWidth.java CssWordSpacing.java CssZIndex.java Log Message: preparation of new css3 types support, parser already modified to accept them, some alignment of coding std for old properties Index: CssTabSize.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssTabSize.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssTabSize.java 5 Sep 2012 12:21:43 -0000 1.3 +++ CssTabSize.java 6 Sep 2012 12:37:58 -0000 1.4 @@ -42,7 +42,7 @@ } switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssNumber number = (CssNumber) val; + CssNumber number = val.getNumber(); if (!number.isInteger()) { throw new InvalidParamException("integer", val.toString(), @@ -55,7 +55,7 @@ value = val; break; case CssTypes.CSS_LENGTH: - CssLength l = (CssLength) val; + CssLength l = val.getLength(); if (!l.isPositive()) { throw new InvalidParamException("negative-value", l, getPropertyName(), ac); Index: CssBorderImageSlice.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorderImageSlice.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssBorderImageSlice.java 26 Apr 2012 18:33:30 -0000 1.2 +++ CssBorderImageSlice.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -22,104 +22,104 @@ */ public class CssBorderImageSlice extends org.w3c.css.properties.css.CssBorderImageSlice { - public static final CssIdent fill; + public static final CssIdent fill; - static { - fill = CssIdent.getIdent("fill"); - } + static { + fill = CssIdent.getIdent("fill"); + } - public final static CssIdent getMatchingIdent(CssIdent ident) { - return (fill.equals(ident)) ? fill : null; - } + public final static CssIdent getMatchingIdent(CssIdent ident) { + return (fill.equals(ident)) ? fill : null; + } - /** - * Create a new CssBorderImageSlice - */ - public CssBorderImageSlice() { - value = initial; - } + /** + * Create a new CssBorderImageSlice + */ + public CssBorderImageSlice() { + value = initial; + } - /** - * Creates a new CssBorderImageSlice - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssBorderImageSlice(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssBorderImageSlice + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssBorderImageSlice(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { - CssValueList valueList = new CssValueList(); - if (check && expression.getCount() > 5) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue val; - char op; - boolean gotFill = false; + CssValueList valueList = new CssValueList(); + if (check && expression.getCount() > 5) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue val; + char op; + boolean gotFill = false; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - CssNumber num = (CssNumber)val; - if (!num.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_PERCENTAGE: - CssPercentage percent = (CssPercentage) val; - if (!percent.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - getPropertyName(), ac); - } - if (percent.floatValue() > 100f) { - ac.getFrame().addWarning("out-of-range", percent.toString()); - } - valueList.add(val); - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - valueList.add(inherit); - break; - } - if (fill.equals(val)) { - // fill is first or last and can't appear twice - if (gotFill || (valueList.size() != 0 && expression.getRemainingCount() > 1)) { - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); - } - gotFill = true; - break; - } - // unrecognized ident, let it fail - default: - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); - } - expression.next(); - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - // we add fill last to normalize - if (gotFill) { - valueList.add(fill); - } - value = (valueList.size() == 1) ? valueList.get(0) : valueList; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + CssNumber num = val.getNumber(); + if (!num.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage percent = val.getPercentage(); + if (!percent.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + getPropertyName(), ac); + } + if (percent.floatValue() > 100f) { + ac.getFrame().addWarning("out-of-range", percent.toString()); + } + valueList.add(val); + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + valueList.add(inherit); + break; + } + if (fill.equals(val)) { + // fill is first or last and can't appear twice + if (gotFill || (valueList.size() != 0 && expression.getRemainingCount() > 1)) { + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + gotFill = true; + break; + } + // unrecognized ident, let it fail + default: + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + expression.next(); + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + // we add fill last to normalize + if (gotFill) { + valueList.add(fill); + } + value = (valueList.size() == 1) ? valueList.get(0) : valueList; + } - public CssBorderImageSlice(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBorderImageSlice(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssBackgroundPosition.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackgroundPosition.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssBackgroundPosition.java 28 Aug 2012 20:31:17 -0000 1.4 +++ CssBackgroundPosition.java 6 Sep 2012 12:37:57 -0000 1.5 @@ -12,7 +12,7 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; -import org.w3c.css.values.CssNumber; +import org.w3c.css.values.CssLength; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -171,7 +171,7 @@ for (CssValue aValue : v.value) { switch (aValue.getType()) { case CssTypes.CSS_NUMBER: - aValue = ((CssNumber) aValue).getLength(); + CssLength l = aValue.getLength(); case CssTypes.CSS_LENGTH: nb_length++; break; @@ -332,7 +332,7 @@ } break; case CssTypes.CSS_NUMBER: - aValue = ((CssNumber) aValue).getPercentage(); + aValue = aValue.getPercentage(); case CssTypes.CSS_PERCENTAGE: case CssTypes.CSS_LENGTH: if (!got_ident) { Index: CssColumnCount.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnCount.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- CssColumnCount.java 9 Feb 2012 17:36:32 -0000 1.10 +++ CssColumnCount.java 6 Sep 2012 12:37:57 -0000 1.11 @@ -8,7 +8,6 @@ package org.w3c.css.properties.css3; -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; @@ -23,7 +22,6 @@ public class CssColumnCount extends org.w3c.css.properties.css.CssColumnCount { - CssValue count; static CssIdent auto = CssIdent.getIdent("auto"); @@ -31,7 +29,7 @@ * Create a new CssColumnCount */ public CssColumnCount() { - count = auto; + value = initial; } /** @@ -54,7 +52,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - num = (CssNumber) val; + num = val.getNumber(); if (!num.isInteger()) { throw new InvalidParamException("integer", expression.getValue(), getPropertyName(), ac); @@ -64,15 +62,15 @@ expression.getValue(), getPropertyName(), ac); } - count = val; + value = val; break; case CssTypes.CSS_IDENT: if (auto.equals(val)) { - count = auto; + value = auto; break; } if (inherit.equals(val)) { - count = inherit; + value = inherit; break; } default: @@ -88,41 +86,10 @@ } /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssColumnCount && - count.equals(((CssColumnCount) property).count)); - } - - /** - * Returns the value of this property - */ - public Object get() { - return count; - } - - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return (count == inherit); - } - - /** - * Returns a string representation of the object - */ - public String toString() { - return count.toString(); - } - - /** * Is the value of this property a default value * It is used by alle macro for the function <code>print</code> */ public boolean isDefault() { - return (count == auto); + return (value == auto) || (value == initial); } } Index: CssBorderImageWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorderImageWidth.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssBorderImageWidth.java 26 Apr 2012 18:33:31 -0000 1.2 +++ CssBorderImageWidth.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -23,100 +23,100 @@ */ public class CssBorderImageWidth extends org.w3c.css.properties.css.CssBorderImageWidth { - public static final CssIdent auto; + public static final CssIdent auto; - static { - auto = CssIdent.getIdent("auto"); - } + static { + auto = CssIdent.getIdent("auto"); + } - public final static CssIdent getMatchingIdent(CssIdent ident) { - return (auto.equals(ident)) ? auto : null; - } + public final static CssIdent getMatchingIdent(CssIdent ident) { + return (auto.equals(ident)) ? auto : null; + } - /** - * Create a new CssBorderImageWidth - */ - public CssBorderImageWidth() { - value = initial; - } + /** + * Create a new CssBorderImageWidth + */ + public CssBorderImageWidth() { + value = initial; + } - /** - * Creates a new CssBorderImageWidth - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssBorderImageWidth(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssBorderImageWidth + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssBorderImageWidth(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { - CssValueList valueList = new CssValueList(); - if (check && expression.getCount() > 4) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue val; - char op; + CssValueList valueList = new CssValueList(); + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue val; + char op; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - CssNumber num = (CssNumber)val; - if (!num.isPositive()) { - throw new InvalidParamException("negative-value", num, - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_LENGTH: - CssLength length = (CssLength)val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", length, - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_PERCENTAGE: - CssPercentage percent = (CssPercentage) val; - if (!percent.isPositive()) { - throw new InvalidParamException("negative-value", percent, - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - valueList.add(inherit); - break; - } - if (auto.equals(val)) { - // fill is first or last and can't appear twice - valueList.add(auto); - break; - } - // unrecognized ident, let it fail - default: - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); - } - expression.next(); - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - value = (valueList.size() == 1) ? valueList.get(0) : valueList; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + CssNumber num = val.getNumber(); + if (!num.isPositive()) { + throw new InvalidParamException("negative-value", num, + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_LENGTH: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", length, + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage percent = val.getPercentage(); + if (!percent.isPositive()) { + throw new InvalidParamException("negative-value", percent, + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + valueList.add(inherit); + break; + } + if (auto.equals(val)) { + // fill is first or last and can't appear twice + valueList.add(auto); + break; + } + // unrecognized ident, let it fail + default: + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + expression.next(); + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + value = (valueList.size() == 1) ? valueList.get(0) : valueList; + } - public CssBorderImageWidth(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBorderImageWidth(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssHeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/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:32 -0000 1.2 +++ CssHeight.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -4,13 +4,11 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; -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; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -21,136 +19,76 @@ */ 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 org.w3c.css.util.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 (inherit.equals(val)) { - identVal = inherit; - } else if (initial.equals(val)) { - identVal = initial; - } else 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() { + value = initial; + } - public CssHeight(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Create a new CssHeight. + * + * @param expression The expression for this property + * @throws org.w3c.css.util.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 (inherit.equals(val)) { + value = inherit; + } else if (auto.equals(val)) { + value = auto; + } else { + throw new InvalidParamException("unrecognize", ac); + } + break; + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength l = val.getLength(); + if (!l.isPositive()) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + value = l; + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage p = val.getPercentage(); + 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) || (identVal == initial)); - } + /** + * 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) || (value == initial)); + } } Index: CssTextIndent.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssTextIndent.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CssTextIndent.java 3 Sep 2012 20:35:45 -0000 1.1 +++ CssTextIndent.java 6 Sep 2012 12:37:58 -0000 1.2 @@ -9,7 +9,6 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -61,7 +60,7 @@ op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); + val = val.getLength(); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: if (sizeVal != null) { Index: CssBorderRadius.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorderRadius.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CssBorderRadius.java 26 Apr 2012 18:33:31 -0000 1.7 +++ CssBorderRadius.java 6 Sep 2012 12:37:57 -0000 1.8 @@ -10,7 +10,6 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssSwitch; import org.w3c.css.values.CssTypes; @@ -27,218 +26,216 @@ public class CssBorderRadius extends org.w3c.css.properties.css.CssBorderRadius { - /** - * Create new CssBorderRadius - */ - public CssBorderRadius() { - value = initial; - topLeft = new CssBorderTopLeftRadius(); - topRight = new CssBorderTopRightRadius(); - bottomLeft = new CssBorderBottomLeftRadius(); - bottomRight = new CssBorderBottomRightRadius(); - } + /** + * Create new CssBorderRadius + */ + public CssBorderRadius() { + value = initial; + topLeft = new CssBorderTopLeftRadius(); + topRight = new CssBorderTopRightRadius(); + bottomLeft = new CssBorderBottomLeftRadius(); + bottomRight = new CssBorderBottomRightRadius(); + } - /** - * Create new CssBorderRadius - * - * @param expression The expression for this property - * @throws InvalidParamException Values are incorrect - */ - public CssBorderRadius(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - if (check && expression.getCount() > 9) { - throw new InvalidParamException("unrecognize", ac); - } - setByUser(); - CssValue val; - char op; - boolean switched = false; + /** + * Create new CssBorderRadius + * + * @param expression The expression for this property + * @throws InvalidParamException Values are incorrect + */ + public CssBorderRadius(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + if (check && expression.getCount() > 9) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + CssValue val; + char op; + boolean switched = false; - ArrayList<CssValue> h_radius = new ArrayList<CssValue>(); - ArrayList<CssValue> v_radius = new ArrayList<CssValue>(); - ArrayList<CssValue> cur_radius = h_radius; + ArrayList<CssValue> h_radius = new ArrayList<CssValue>(); + ArrayList<CssValue> v_radius = new ArrayList<CssValue>(); + ArrayList<CssValue> cur_radius = h_radius; - while (!expression.end() && h_radius.size() < 4 && v_radius.size() < 4) { - val = expression.getValue(); - op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - getPropertyName(), ac); - } - cur_radius.add(length); - break; - case CssTypes.CSS_PERCENTAGE: - CssPercentage percentage = (CssPercentage) val; - if (!percentage.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - getPropertyName(), ac); - } - cur_radius.add(percentage); - break; - case CssTypes.CSS_SWITCH: - if (switched) { - throw new InvalidParamException("operator", - val.toString(), ac); - } - switched = true; - cur_radius = v_radius; - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - cur_radius.add(inherit); - break; - } - default: - throw new InvalidParamException("unrecognize", ac); - } - expression.next(); - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - if (v_radius.size() == 0) { - value = new CssValueList(h_radius); - } else { - CssValueList vlist = new CssValueList(); - for (CssValue h : h_radius) { - vlist.add(h); - } - vlist.add(new CssSwitch()); - for (CssValue v : v_radius) { - vlist.add(v); - } - value = vlist; - } - // now assign the computed values... - topLeft = new CssBorderTopLeftRadius(); - topRight = new CssBorderTopRightRadius(); - bottomLeft = new CssBorderBottomLeftRadius(); - bottomRight = new CssBorderBottomRightRadius(); + while (!expression.end() && h_radius.size() < 4 && v_radius.size() < 4) { + val = expression.getValue(); + op = expression.getOperator(); + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + getPropertyName(), ac); + } + cur_radius.add(length); + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage percentage = val.getPercentage(); + if (!percentage.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + getPropertyName(), ac); + } + cur_radius.add(percentage); + break; + case CssTypes.CSS_SWITCH: + if (switched) { + throw new InvalidParamException("operator", + val.toString(), ac); + } + switched = true; + cur_radius = v_radius; + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + cur_radius.add(inherit); + break; + } + default: + throw new InvalidParamException("unrecognize", ac); + } + expression.next(); + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + if (v_radius.size() == 0) { + value = new CssValueList(h_radius); + } else { + CssValueList vlist = new CssValueList(); + for (CssValue h : h_radius) { + vlist.add(h); + } + vlist.add(new CssSwitch()); + for (CssValue v : v_radius) { + vlist.add(v); + } + value = vlist; + } + // now assign the computed values... + topLeft = new CssBorderTopLeftRadius(); + topRight = new CssBorderTopRightRadius(); + bottomLeft = new CssBorderBottomLeftRadius(); + bottomRight = new CssBorderBottomRightRadius(); - switch (h_radius.size()) { - case 1: - topLeft.h_radius = topRight.h_radius = bottomLeft.h_radius = bottomRight.h_radius = h_radius.get(0); - break; - case 2: - topLeft.h_radius = bottomRight.h_radius = h_radius.get(0); - topRight.h_radius = bottomLeft.h_radius = h_radius.get(1); - break; - case 3: - topLeft.h_radius = h_radius.get(0); - topRight.h_radius = bottomLeft.h_radius = h_radius.get(1); - bottomRight.h_radius = h_radius.get(2); - break; - case 4: - topLeft.h_radius = h_radius.get(0); - topRight.h_radius = h_radius.get(1); - bottomRight.h_radius = h_radius.get(2); - bottomLeft.h_radius = h_radius.get(3); - break; - default: - // can't happen - throw new InvalidParamException("unrecognize", ac); - } - switch (v_radius.size()) { - case 0: - // v = h - topLeft.v_radius = topRight.v_radius = bottomLeft.v_radius = bottomRight.v_radius = h_radius.get(0); - break; - case 1: - topLeft.v_radius = topRight.v_radius = bottomLeft.v_radius = bottomRight.v_radius = v_radius.get(0); - break; - case 2: - topLeft.v_radius = bottomRight.v_radius = v_radius.get(0); - topRight.v_radius = bottomLeft.v_radius = v_radius.get(1); - break; - case 3: - topLeft.v_radius = v_radius.get(0); - topRight.v_radius = bottomLeft.v_radius = v_radius.get(1); - bottomRight.v_radius = v_radius.get(2); - break; - case 4: - topLeft.v_radius = v_radius.get(0); - topRight.v_radius = v_radius.get(1); - bottomRight.v_radius = v_radius.get(2); - bottomLeft.v_radius = v_radius.get(3); - break; - default: - // can't happen - throw new InvalidParamException("unrecognize", ac); - } - shorthand = true; - } + switch (h_radius.size()) { + case 1: + topLeft.h_radius = topRight.h_radius = bottomLeft.h_radius = bottomRight.h_radius = h_radius.get(0); + break; + case 2: + topLeft.h_radius = bottomRight.h_radius = h_radius.get(0); + topRight.h_radius = bottomLeft.h_radius = h_radius.get(1); + break; + case 3: + topLeft.h_radius = h_radius.get(0); + topRight.h_radius = bottomLeft.h_radius = h_radius.get(1); + bottomRight.h_radius = h_radius.get(2); + break; + case 4: + topLeft.h_radius = h_radius.get(0); + topRight.h_radius = h_radius.get(1); + bottomRight.h_radius = h_radius.get(2); + bottomLeft.h_radius = h_radius.get(3); + break; + default: + // can't happen + throw new InvalidParamException("unrecognize", ac); + } + switch (v_radius.size()) { + case 0: + // v = h + topLeft.v_radius = topRight.v_radius = bottomLeft.v_radius = bottomRight.v_radius = h_radius.get(0); + break; + case 1: + topLeft.v_radius = topRight.v_radius = bottomLeft.v_radius = bottomRight.v_radius = v_radius.get(0); + break; + case 2: + topLeft.v_radius = bottomRight.v_radius = v_radius.get(0); + topRight.v_radius = bottomLeft.v_radius = v_radius.get(1); + break; + case 3: + topLeft.v_radius = v_radius.get(0); + topRight.v_radius = bottomLeft.v_radius = v_radius.get(1); + bottomRight.v_radius = v_radius.get(2); + break; + case 4: + topLeft.v_radius = v_radius.get(0); + topRight.v_radius = v_radius.get(1); + bottomRight.v_radius = v_radius.get(2); + bottomLeft.v_radius = v_radius.get(3); + break; + default: + // can't happen + throw new InvalidParamException("unrecognize", ac); + } + shorthand = true; + } - public CssBorderRadius(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBorderRadius(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Check the border-*-radius and returns a value. - * It makes sense to do it only once for all the corners, so by having the code here. - */ - protected static CssValue checkBorderCornerRadius(ApplContext ac, CssProperty caller, - CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Check the border-*-radius and returns a value. + * It makes sense to do it only once for all the corners, so by having the code here. + */ + protected static CssValue checkBorderCornerRadius(ApplContext ac, CssProperty caller, + CssExpression expression, boolean check) + throws InvalidParamException { - if (check && expression.getCount() > 2) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue val; - CssValueList res = new CssValueList(); - char op; + if (check && expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue val; + CssValueList res = new CssValueList(); + char op; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - caller.getPropertyName(), ac); - } - res.add(length); - break; - case CssTypes.CSS_PERCENTAGE: - CssPercentage percentage = (CssPercentage) val; - if (!percentage.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - caller.getPropertyName(), ac); - } - res.add(percentage); - break; - case CssTypes.CSS_IDENT: - if (inherit.equals((val))) { - if (res.size() > 0) { - throw new InvalidParamException("unrecognize", ac); - } - res.add(inherit); - break; - } - default: - throw new InvalidParamException("unrecognize", ac); - } - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - expression.next(); - } - return (res.size() == 1) ? res.get(0) : res; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + caller.getPropertyName(), ac); + } + res.add(length); + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage percentage = val.getPercentage(); + if (!percentage.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + caller.getPropertyName(), ac); + } + res.add(percentage); + break; + case CssTypes.CSS_IDENT: + if (inherit.equals((val))) { + if (res.size() > 0) { + throw new InvalidParamException("unrecognize", ac); + } + res.add(inherit); + break; + } + default: + throw new InvalidParamException("unrecognize", ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + expression.next(); + } + return (res.size() == 1) ? res.get(0) : res; + } } Index: CssFontFeatureSettings.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontFeatureSettings.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssFontFeatureSettings.java 29 Aug 2012 09:50:25 -0000 1.3 +++ CssFontFeatureSettings.java 6 Sep 2012 12:37:57 -0000 1.4 @@ -139,7 +139,7 @@ val = exp.getValue(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssNumber n = (CssNumber) val; + CssNumber n = val.getNumber(); if (!n.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), Index: CssFontWeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontWeight.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssFontWeight.java 23 Aug 2012 13:55:34 -0000 1.3 +++ CssFontWeight.java 6 Sep 2012 12:37:57 -0000 1.4 @@ -66,7 +66,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssNumber num = (CssNumber) val; + CssNumber num = val.getNumber(); switch (num.getInt()) { case 100: case 200: Index: CssBoxShadow.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBoxShadow.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- CssBoxShadow.java 28 Aug 2012 20:31:47 -0000 1.11 +++ CssBoxShadow.java 6 Sep 2012 12:37:57 -0000 1.12 @@ -14,7 +14,6 @@ import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -30,273 +29,273 @@ public class CssBoxShadow extends org.w3c.css.properties.css.CssBoxShadow { - public static CssIdent inset; + public static CssIdent inset; - static { - inset = CssIdent.getIdent("inset"); - } + static { + inset = CssIdent.getIdent("inset"); + } - /** - * Create new CssBoxShadow - */ - public CssBoxShadow() { - value = none; - } + /** + * Create new CssBoxShadow + */ + public CssBoxShadow() { + value = none; + } - /** - * Create new CssBoxShadow - * - * @param expression The expression for this property - * @throws InvalidParamException Values are incorrect - */ - public CssBoxShadow(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - CssExpression single_layer = null; - ArrayList<CssValue> values; - CssBoxShadowValue boxShadowValue; + /** + * Create new CssBoxShadow + * + * @param expression The expression for this property + * @throws InvalidParamException Values are incorrect + */ + public CssBoxShadow(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + CssExpression single_layer = null; + ArrayList<CssValue> values; + CssBoxShadowValue boxShadowValue; - setByUser(); - CssValue val = expression.getValue(); - char op; + setByUser(); + CssValue val = expression.getValue(); + char op; - if (expression.getCount() == 1) { - // it can be only 'none' or 'inherit' - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - expression.next(); - return; - } else if (none.equals(ident)) { - value = none; - expression.next(); - return; - } - } - // if it is another ident, or not an ident, fail. - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - // ok, so we have one or multiple layers here... - values = new ArrayList<CssValue>(); + if (expression.getCount() == 1) { + // it can be only 'none' or 'inherit' + if (val.getType() == CssTypes.CSS_IDENT) { + CssIdent ident = (CssIdent) val; + if (inherit.equals(ident)) { + value = inherit; + expression.next(); + return; + } else if (none.equals(ident)) { + value = none; + expression.next(); + return; + } + } + // if it is another ident, or not an ident, fail. + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); + } + // ok, so we have one or multiple layers here... + values = new ArrayList<CssValue>(); - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - if (single_layer == null) { - single_layer = new CssExpression(); - } - single_layer.addValue(val); - single_layer.setOperator(op); - expression.next(); + if (single_layer == null) { + single_layer = new CssExpression(); + } + single_layer.addValue(val); + single_layer.setOperator(op); + expression.next(); - if (!expression.end()) { - // incomplete value followed by a comma... it's complete! - if (op == COMMA) { - single_layer.setOperator(SPACE); - boxShadowValue = check(ac, single_layer, check); - values.add(boxShadowValue); - single_layer = null; - } else if ((op != SPACE)) { - throw new InvalidParamException("operator", - ((new Character(op)).toString()), ac); - } - } - } - // if we reach the end in a value that can come in pair - if (single_layer != null) { - boxShadowValue = check(ac, single_layer, check); - values.add(boxShadowValue); - } - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); - } + if (!expression.end()) { + // incomplete value followed by a comma... it's complete! + if (op == COMMA) { + single_layer.setOperator(SPACE); + boxShadowValue = check(ac, single_layer, check); + values.add(boxShadowValue); + single_layer = null; + } else if ((op != SPACE)) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + } + } + // if we reach the end in a value that can come in pair + if (single_layer != null) { + boxShadowValue = check(ac, single_layer, check); + values.add(boxShadowValue); + } + if (values.size() == 1) { + value = values.get(0); + } else { + value = new CssLayerList(values); + } - } + } - public CssBoxShadowValue check(ApplContext ac, CssExpression expression, - boolean check) - throws InvalidParamException { - if (check && expression.getCount() > 6) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue val; - char op; - CssBoxShadowValue value = new CssBoxShadowValue(); - boolean length_ok = true; - int got_length = 0; + public CssBoxShadowValue check(ApplContext ac, CssExpression expression, + boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 6) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue val; + char op; + CssBoxShadowValue value = new CssBoxShadowValue(); + boolean length_ok = true; + int got_length = 0; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - case CssTypes.CSS_LENGTH: - if (!length_ok) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); - } - got_length++; - switch (got_length) { - case 1: - value.horizontal_offset = val; - break; - case 2: - value.vertical_offset = val; - break; - case 3: - CssLength length = (CssLength) val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", - expression.getValue(), - getPropertyName(), ac); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val = val.getLength(); + case CssTypes.CSS_LENGTH: + if (!length_ok) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + got_length++; + switch (got_length) { + case 1: + value.horizontal_offset = val; + break; + case 2: + value.vertical_offset = val; + break; + case 3: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", + expression.getValue(), + getPropertyName(), ac); - } - value.blur_radius = length; - break; - case 4: - value.spread_distance = val; - break; - default: - throw new InvalidParamException("value", val, - getPropertyName(), ac); - } - break; - case CssTypes.CSS_IDENT: - // if we got 2 to 4 length tokens we must not have others - if (got_length != 0) { - length_ok = false; - } - CssIdent ident = (CssIdent) val; - // checked before, not allowed here - if (inherit.equals(ident)) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); - } - if (inset.equals(ident)) { - value.shadow_mod = inset; - // inset can be first or last - if ((value.color != null || got_length != 0) && - expression.getRemainingCount() != 1) { - throw new InvalidParamException("unrecognize", ac); - } - break; - } - // if not a known ident, it must be a color - // and let's use the CSS3 color. - CssExpression exp = new CssExpression(); - exp.addValue(val); - CssColor color = new CssColor(ac, exp, check); - value.color = (CssValue) color.get(); - break; - case CssTypes.CSS_COLOR: - case CssTypes.CSS_FUNCTION: - if (got_length != 0) { - length_ok = false; - } - // this one is a pain... need to remove function for colors. - CssExpression fexp = new CssExpression(); - fexp.addValue(val); - CssColor fcolor = new CssColor(ac, fexp, check); - value.color = (CssValue) fcolor.get(); - break; - default: - throw new InvalidParamException("value", val, - getPropertyName(), ac); - } - if (op != SPACE) { - throw new InvalidParamException("operator", val, - getPropertyName(), ac); - } - expression.next(); - } - // we need 2 to 4 length. > 4 is taken care of in the first switch - if (got_length < 2) { - throw new InvalidParamException("unrecognize", ac); - } - return value; - } + } + value.blur_radius = length; + break; + case 4: + value.spread_distance = val; + break; + default: + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + break; + case CssTypes.CSS_IDENT: + // if we got 2 to 4 length tokens we must not have others + if (got_length != 0) { + length_ok = false; + } + CssIdent ident = (CssIdent) val; + // checked before, not allowed here + if (inherit.equals(ident)) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + if (inset.equals(ident)) { + value.shadow_mod = inset; + // inset can be first or last + if ((value.color != null || got_length != 0) && + expression.getRemainingCount() != 1) { + throw new InvalidParamException("unrecognize", ac); + } + break; + } + // if not a known ident, it must be a color + // and let's use the CSS3 color. + CssExpression exp = new CssExpression(); + exp.addValue(val); + CssColor color = new CssColor(ac, exp, check); + value.color = (CssValue) color.get(); + break; + case CssTypes.CSS_COLOR: + case CssTypes.CSS_FUNCTION: + if (got_length != 0) { + length_ok = false; + } + // this one is a pain... need to remove function for colors. + CssExpression fexp = new CssExpression(); + fexp.addValue(val); + CssColor fcolor = new CssColor(ac, fexp, check); + value.color = (CssValue) fcolor.get(); + break; + default: + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", val, + getPropertyName(), ac); + } + expression.next(); + } + // we need 2 to 4 length. > 4 is taken care of in the first switch + if (got_length < 2) { + throw new InvalidParamException("unrecognize", ac); + } + return value; + } - public CssBoxShadow(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBoxShadow(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Is the value of this property a default value - * It is used by all macro for the function <code>print</code> - */ - public boolean isDefault() { - return none == value; - } + /** + * Is the value of this property a default value + * It is used by all macro for the function <code>print</code> + */ + public boolean isDefault() { + return none == value; + } // placeholder for the different values - public class CssBoxShadowValue extends CssValueList { + public class CssBoxShadowValue extends CssValueList { - CssValue horizontal_offset; - CssValue vertical_offset; - CssValue blur_radius; - CssValue spread_distance; - CssValue color; - CssValue shadow_mod; + CssValue horizontal_offset; + CssValue vertical_offset; + CssValue blur_radius; + CssValue spread_distance; + CssValue color; + CssValue shadow_mod; - public boolean equals(CssBoxShadowValue v) { - if (!v.horizontal_offset.equals(horizontal_offset)) { - return false; - } - if (!v.vertical_offset.equals(vertical_offset)) { - return false; - } - if (blur_radius != null && !blur_radius.equals(v.blur_radius)) { - return false; - } - if (blur_radius == null && v.blur_radius != null) { - return false; - } - if (spread_distance != null && !spread_distance.equals(v.spread_distance)) { - return false; - } - if (spread_distance == null && v.spread_distance != null) { - return false; - } - if (color != null && !color.equals(v.color)) { - return false; - } - if (color == null && v.color != null) { - return false; - } - if (shadow_mod != null && !shadow_mod.equals(v.shadow_mod)) { - return false; - } - if (shadow_mod == null && v.color != shadow_mod) { - return false; - } - // at last! - return true; - } + public boolean equals(CssBoxShadowValue v) { + if (!v.horizontal_offset.equals(horizontal_offset)) { + return false; + } + if (!v.vertical_offset.equals(vertical_offset)) { + return false; + } + if (blur_radius != null && !blur_radius.equals(v.blur_radius)) { + return false; + } + if (blur_radius == null && v.blur_radius != null) { + return false; + } + if (spread_distance != null && !spread_distance.equals(v.spread_distance)) { + return false; + } + if (spread_distance == null && v.spread_distance != null) { + return false; + } + if (color != null && !color.equals(v.color)) { + return false; + } + if (color == null && v.color != null) { + return false; + } + if (shadow_mod != null && !shadow_mod.equals(v.shadow_mod)) { + return false; + } + if (shadow_mod == null && v.color != shadow_mod) { + return false; + } + // at last! + return true; + } - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(horizontal_offset).append(' ').append(vertical_offset); - if (blur_radius != null) { - sb.append(' ').append(blur_radius); - } - if (spread_distance != null) { - sb.append(' ').append(spread_distance); - } - if (color != null) { - sb.append(' ').append(color); - } - if (shadow_mod != null) { - sb.append(' ').append(shadow_mod); - } - return sb.toString(); - } - } + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(horizontal_offset).append(' ').append(vertical_offset); + if (blur_radius != null) { + sb.append(' ').append(blur_radius); + } + if (spread_distance != null) { + sb.append(' ').append(spread_distance); + } + if (color != null) { + sb.append(' ').append(color); + } + if (shadow_mod != null) { + sb.append(' ').append(shadow_mod); + } + return sb.toString(); + } + } } Index: CssOpacity.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssOpacity.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssOpacity.java 7 Oct 2011 09:33:19 -0000 1.5 +++ CssOpacity.java 6 Sep 2012 12:37:58 -0000 1.6 @@ -7,7 +7,6 @@ package org.w3c.css.properties.css3; -import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.util.Util; @@ -22,105 +21,75 @@ public class CssOpacity extends org.w3c.css.properties.css.CssOpacity { - CssValue value; - - /** - * Create a new CssOpacity - */ - public CssOpacity() { - value = initial; - } - - /** - * Create a new CssOpacity - * - * @param expression The expression for this property - * @throws InvalidParamException Values are incorrect - */ - public CssOpacity(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { - setByUser(); // tell this property is set by the user - CssValue val = expression.getValue(); - - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - CssNumber number = (CssNumber) val; - // this will generate a warning if necessary - number.setFloatValue(clampedValue(ac, number.getValue())); - value = number; - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - break; - } - // let it flow through the exception - default: - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); - } - expression.next(); - } - - public CssOpacity(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } - - /** - * Brings all values back between 0 and 1 - * - * @param opacity The value to be modified if necessary - */ - private float clampedValue(ApplContext ac, float opacity) { - if (opacity < 0.f || opacity > 1.f) { - ac.getFrame().addWarning("out-of-range", Util.displayFloat(opacity)); - return ((opacity < 0.f) ? 0.f : 1.f); - } - return opacity; - } - + /** + * Create a new CssOpacity + */ + public CssOpacity() { + value = initial; + } - /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssOpacity && value - .equals(((CssOpacity) property).value)); - } + /** + * Create a new CssOpacity + * + * @param expression The expression for this property + * @throws InvalidParamException Values are incorrect + */ + public CssOpacity(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); // tell this property is set by the user + CssValue val = expression.getValue(); - /** - * Returns the value of this property - */ - public Object get() { - return value; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + CssNumber number = val.getNumber(); + // this will generate a warning if necessary + number.setFloatValue(clampedValue(ac, number.getValue())); + value = number; + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + value = inherit; + break; + } + // let it flow through the exception + default: + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + expression.next(); + } - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return inherit == value; - } + public CssOpacity(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Returns a string representation of the object - */ - public String toString() { - return value.toString(); - } + /** + * Brings all values back between 0 and 1 + * + * @param opacity The value to be modified if necessary + */ + private float clampedValue(ApplContext ac, float opacity) { + if (opacity < 0.f || opacity > 1.f) { + ac.getFrame().addWarning("out-of-range", Util.displayFloat(opacity)); + return ((opacity < 0.f) ? 0.f : 1.f); + } + return opacity; + } - /** - * Is the value of this property a default value It is used by all macro for - * the function <code>print</code> - */ - public boolean isDefault() { - if (value.getType() == CssTypes.CSS_NUMBER) { - return (((CssNumber) value).getValue() == 1.f); - } - return (value == initial); - } + /** + * Is the value of this property a default value It is used by all macro for + * the function <code>print</code> + */ + public boolean isDefault() { + if (value.getType() == CssTypes.CSS_NUMBER) { + try { + return (value.getNumber().getValue() == 1.f); + } catch (Exception ex) { + return false; + } + } + return (value == initial); + } } Index: CssTextShadow.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssTextShadow.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssTextShadow.java 4 Sep 2012 09:10:27 -0000 1.3 +++ CssTextShadow.java 6 Sep 2012 12:37:58 -0000 1.4 @@ -10,7 +10,6 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssLayerList; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -122,7 +121,7 @@ // color is last, so if we reach this, we are in error if (val.getType() == CssTypes.CSS_NUMBER) { // case of 0, a number and a length - val = ((CssNumber) val).getLength(); + val = val.getLength(); } if (val.getType() == CssTypes.CSS_LENGTH) { values.add(val); @@ -149,7 +148,7 @@ int lcount = values.size(); // sanity check third length if present must not be negative if (lcount == 3) { - CssLength l = (CssLength) values.get(2); + CssLength l = values.get(2).getLength(); if (!l.isPositive()) { throw new InvalidParamException("negative-value", l, getPropertyName(), ac); Index: CssBorder.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssBorder.java 26 Apr 2012 18:33:30 -0000 1.2 +++ CssBorder.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -11,7 +11,6 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -23,177 +22,176 @@ */ public class CssBorder extends org.w3c.css.properties.css.CssBorder { - /** - * Create a new CssBorder - */ - public CssBorder() { - value = initial; - } + /** + * Create a new CssBorder + */ + public CssBorder() { + value = initial; + } - /** - * Set the value of the property<br/> - * Does not check the number of values - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect - */ - public CssBorder(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Set the value of the property<br/> + * Does not check the number of values + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * The expression is incorrect + */ + public CssBorder(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Set the value of the property - * - * @param expression The expression for this property - * @param check set it to true to check the number of values - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect - */ - public CssBorder(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - // great, it's the same thing as one side! - CssValueList valueList = new CssValueList(); + /** + * Set the value of the property + * + * @param expression The expression for this property + * @param check set it to true to check the number of values + * @throws org.w3c.css.util.InvalidParamException + * The expression is incorrect + */ + public CssBorder(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + // great, it's the same thing as one side! + CssValueList valueList = new CssValueList(); - SideValues values = checkBorderSide(ac, this, expression, check); - shorthand = true; - if (values.color != null) { - valueList.add(values.color); - borderColor = new CssBorderColor(); - borderColor.bottom = new CssBorderBottomColor(); - borderColor.bottom.value = values.color; - borderColor.top = new CssBorderTopColor(); - borderColor.top.value = values.color; - borderColor.left = new CssBorderLeftColor(); - borderColor.left.value = values.color; - borderColor.right = new CssBorderRightColor(); - borderColor.right.value = values.color; - } - if (values.style != null) { - valueList.add(values.style); - borderStyle = new CssBorderStyle(); - borderStyle.bottom = new CssBorderBottomStyle(); - borderStyle.bottom.value = values.style; - borderStyle.top = new CssBorderTopStyle(); - borderStyle.top.value = values.style; - borderStyle.left = new CssBorderLeftStyle(); - borderStyle.left.value = values.style; - borderStyle.right = new CssBorderRightStyle(); - borderStyle.right.value = values.style; - } - if (values.width != null) { - valueList.add(values.width); - borderWidth = new CssBorderWidth(); - borderWidth.bottom = new CssBorderBottomWidth(); - borderWidth.bottom.value = values.width; - borderWidth.top = new CssBorderTopWidth(); - borderWidth.top.value = values.width; - borderWidth.left = new CssBorderLeftWidth(); - borderWidth.left.value = values.width; - borderWidth.right = new CssBorderRightWidth(); - borderWidth.right.value = values.width; - } - value = valueList; - } + SideValues values = checkBorderSide(ac, this, expression, check); + shorthand = true; + if (values.color != null) { + valueList.add(values.color); + borderColor = new CssBorderColor(); + borderColor.bottom = new CssBorderBottomColor(); + borderColor.bottom.value = values.color; + borderColor.top = new CssBorderTopColor(); + borderColor.top.value = values.color; + borderColor.left = new CssBorderLeftColor(); + borderColor.left.value = values.color; + borderColor.right = new CssBorderRightColor(); + borderColor.right.value = values.color; + } + if (values.style != null) { + valueList.add(values.style); + borderStyle = new CssBorderStyle(); + borderStyle.bottom = new CssBorderBottomStyle(); + borderStyle.bottom.value = values.style; + borderStyle.top = new CssBorderTopStyle(); + borderStyle.top.value = values.style; + borderStyle.left = new CssBorderLeftStyle(); + borderStyle.left.value = values.style; + borderStyle.right = new CssBorderRightStyle(); + borderStyle.right.value = values.style; + } + if (values.width != null) { + valueList.add(values.width); + borderWidth = new CssBorderWidth(); + borderWidth.bottom = new CssBorderBottomWidth(); + borderWidth.bottom.value = values.width; + borderWidth.top = new CssBorderTopWidth(); + borderWidth.top.value = values.width; + borderWidth.left = new CssBorderLeftWidth(); + borderWidth.left.value = values.width; + borderWidth.right = new CssBorderRightWidth(); + borderWidth.right.value = values.width; + } + value = valueList; + } - /** - * Check the border-* and returns a value. - * It makes sense to do it only once for all the sides, so by having the code here. - */ - protected static SideValues checkBorderSide(ApplContext ac, CssProperty caller, CssExpression expression, - boolean check) throws InvalidParamException { - if (check && expression.getCount() > 3) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue _width = null; - CssValue _style = null; - CssValue _color = null; - CssExpression nex; + /** + * Check the border-* and returns a value. + * It makes sense to do it only once for all the sides, so by having the code here. + */ + protected static SideValues checkBorderSide(ApplContext ac, CssProperty caller, CssExpression expression, + boolean check) throws InvalidParamException { + if (check && expression.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue _width = null; + CssValue _style = null; + CssValue _color = null; + CssExpression nex; - CssValue val; - char op; + CssValue val; + char op; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", expression.getValue(), - caller.getPropertyName(), ac); - } - _width = val; - break; - case CssTypes.CSS_COLOR: - _color = val; - break; - case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (transparent.equals(id)) { - _color = transparent; - break; - } - if (inherit.equals(id)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - _width = inherit; - _style = inherit; - _color = inherit; - break; - } - CssIdent match = CssBorderWidth.getMatchingIdent(id); - if (match != null) { - _width = match; - } else { - match = CssBorderStyle.getMatchingIdent(id); - if (match != null) { - _style = match; - } else { - // if not a width or a style, fail if it's not a proper color - nex = new CssExpression(); - nex.addValue(val); - CssColor cssColor = new CssColor(ac, nex, false); - _color = cssColor.color; - } - } - break; - case CssTypes.CSS_FUNCTION: - nex = new CssExpression(); - nex.addValue(val); - CssColor cssColor = new CssColor(ac, nex, false); - _color = cssColor.color; - break; - default: - throw new InvalidParamException("value", val.toString(), - caller.getPropertyName(), ac); - } - expression.next(); - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - return new SideValues(_width, _style, _color); - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", expression.getValue(), + caller.getPropertyName(), ac); + } + _width = val; + break; + case CssTypes.CSS_COLOR: + _color = val; + break; + case CssTypes.CSS_IDENT: + CssIdent id = (CssIdent) val; + if (transparent.equals(id)) { + _color = transparent; + break; + } + if (inherit.equals(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + _width = inherit; + _style = inherit; + _color = inherit; + break; + } + CssIdent match = CssBorderWidth.getMatchingIdent(id); + if (match != null) { + _width = match; + } else { + match = CssBorderStyle.getMatchingIdent(id); + if (match != null) { + _style = match; + } else { + // if not a width or a style, fail if it's not a proper color + nex = new CssExpression(); + nex.addValue(val); + CssColor cssColor = new CssColor(ac, nex, false); + _color = cssColor.color; + } + } + break; + case CssTypes.CSS_FUNCTION: + nex = new CssExpression(); + nex.addValue(val); + CssColor cssColor = new CssColor(ac, nex, false); + _color = cssColor.color; + break; + default: + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + return new SideValues(_width, _style, _color); + } - // small wrapper to return values... - protected static class SideValues { - CssValue width; - CssValue style; - CssValue color; + // small wrapper to return values... + protected static class SideValues { + CssValue width; + CssValue style; + CssValue color; - SideValues(CssValue width, CssValue style, CssValue color) { - this.width = width; - this.style = style; - this.color = color; + SideValues(CssValue width, CssValue style, CssValue color) { + this.width = width; + this.style = style; + this.color = color; - } - } + } + } } Index: CssLetterSpacing.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssLetterSpacing.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssLetterSpacing.java 4 Sep 2012 08:40:02 -0000 1.2 +++ CssLetterSpacing.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -8,7 +8,6 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -21,24 +20,24 @@ */ public class CssLetterSpacing extends org.w3c.css.properties.css.CssLetterSpacing { - private static CssIdent normal = CssIdent.getIdent("normal"); + private static CssIdent normal = CssIdent.getIdent("normal"); - /** - * Create a new CssLetterSpacing. - */ - public CssLetterSpacing() { - value = initial; - } + /** + * Create a new CssLetterSpacing. + */ + public CssLetterSpacing() { + value = initial; + } - /** - * Create a new CssLetterSpacing with an expression - * - * @param expression The expression - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect - */ - public CssLetterSpacing(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { + /** + * Create a new CssLetterSpacing with an expression + * + * @param expression The expression + * @throws org.w3c.css.util.InvalidParamException + * The expression is incorrect + */ + public CssLetterSpacing(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { if (check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } @@ -54,7 +53,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); + val = val.getLength(); case CssTypes.CSS_LENGTH: v.add(val); break; @@ -84,11 +83,11 @@ if (value != inherit) { value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } - } + } - public CssLetterSpacing(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssLetterSpacing(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssMarqueePlayCount.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssMarqueePlayCount.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssMarqueePlayCount.java 5 Sep 2012 12:20:23 -0000 1.2 +++ CssMarqueePlayCount.java 6 Sep 2012 12:37:58 -0000 1.3 @@ -49,7 +49,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssNumber num = (CssNumber) val; + CssNumber num = val.getNumber(); if (!num.isInteger()) { throw new InvalidParamException("integer", val.toString(), Index: CssWordSpacing.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssWordSpacing.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssWordSpacing.java 4 Sep 2012 08:33:13 -0000 1.2 +++ CssWordSpacing.java 6 Sep 2012 12:37:58 -0000 1.3 @@ -8,7 +8,6 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -55,7 +54,7 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); + val = val.getLength(); case CssTypes.CSS_LENGTH: v.add(val); break; Index: CssLineHeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssLineHeight.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssLineHeight.java 4 Aug 2012 21:24:28 -0000 1.2 +++ CssLineHeight.java 6 Sep 2012 12:37:58 -0000 1.3 @@ -16,29 +16,29 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2002/WD-css3-linebox-20020515/#line-height * @version $Revision$ + * @spec http://www.w3.org/TR/2002/WD-css3-linebox-20020515/#line-height */ public class CssLineHeight extends org.w3c.css.properties.css.CssLineHeight { public static final CssIdent normal = CssIdent.getIdent("normal"); - /** - * Create a new CssLineHeight - */ - public CssLineHeight() { + /** + * Create a new CssLineHeight + */ + public CssLineHeight() { value = initial; - } + } - /** - * Creates a new CssLineHeight - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssLineHeight(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssLineHeight + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssLineHeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } @@ -59,7 +59,7 @@ } break; case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; + CssLength length = val.getLength(); if (!length.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); @@ -67,7 +67,7 @@ value = val; break; case CssTypes.CSS_NUMBER: - CssNumber number = (CssNumber) val; + CssNumber number = val.getNumber(); if (!number.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); @@ -75,7 +75,7 @@ value = val; break; case CssTypes.CSS_PERCENTAGE: - CssPercentage percent = (CssPercentage) val; + CssPercentage percent = val.getPercentage(); if (!percent.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); @@ -87,12 +87,12 @@ getPropertyName(), ac); } expression.next(); - } + } - public CssLineHeight(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssLineHeight(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssColumnGap.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnGap.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- CssColumnGap.java 9 Feb 2012 17:36:32 -0000 1.9 +++ CssColumnGap.java 6 Sep 2012 12:37:57 -0000 1.10 @@ -14,7 +14,6 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -24,103 +23,102 @@ public class CssColumnGap extends org.w3c.css.properties.css.CssColumnGap { - CssValue columngap; + CssValue columngap; - static CssIdent normal; + static CssIdent normal; - static { - normal = CssIdent.getIdent("normal"); - } + static { + normal = CssIdent.getIdent("normal"); + } - /** - * Create a new CssColumnGap - */ - public CssColumnGap() { - columngap = initial; - } + /** + * Create a new CssColumnGap + */ + public CssColumnGap() { + columngap = initial; + } - /** - * Create a new CssColumnGap - */ - public CssColumnGap(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - setByUser(); - CssValue val = expression.getValue(); + /** + * Create a new CssColumnGap + */ + public CssColumnGap(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); - if (check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - case CssTypes.CSS_LENGTH: - CssLength l = (CssLength) val; - if (l == null || !l.isPositive()) { - throw new InvalidParamException("negative-value", - expression.getValue(), - getPropertyName(), ac); - } - columngap = val; - break; - case CssTypes.CSS_IDENT: - if (normal.equals(val)) { - columngap = normal; - break; - } - if (inherit.equals(val)) { - columngap = inherit; - break; - } - default: - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - expression.next(); - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength l = val.getLength(); + if (l == null || !l.isPositive()) { + throw new InvalidParamException("negative-value", + expression.getValue(), + getPropertyName(), ac); + } + columngap = val; + break; + case CssTypes.CSS_IDENT: + if (normal.equals(val)) { + columngap = normal; + break; + } + if (inherit.equals(val)) { + columngap = inherit; + break; + } + default: + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); + } + expression.next(); + } - public CssColumnGap(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssColumnGap(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssColumnGap && - columngap.equals(((CssColumnGap) property).columngap)); - } + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssColumnGap && + columngap.equals(((CssColumnGap) property).columngap)); + } - /** - * Returns the value of this property - */ - public Object get() { - return columngap; - } + /** + * Returns the value of this property + */ + public Object get() { + return columngap; + } - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return (inherit == columngap); - } + /** + * Returns true if this property is "softly" inherited + */ + public boolean isSoftlyInherited() { + return (inherit == columngap); + } - /** - * Returns a string representation of the object - */ - public String toString() { - return columngap.toString(); - } + /** + * Returns a string representation of the object + */ + public String toString() { + return columngap.toString(); + } - /** - * Is the value of this property a default value - * It is used by all macro for the function <code>print</code> - */ - public boolean isDefault() { - return (columngap == initial); - } + /** + * Is the value of this property a default value + * It is used by all macro for the function <code>print</code> + */ + public boolean isDefault() { + return (columngap == initial); + } } Index: CssFontSize.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssFontSize.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssFontSize.java 23 Aug 2012 13:24:19 -0000 1.3 +++ CssFontSize.java 6 Sep 2012 12:37:57 -0000 1.4 @@ -10,7 +10,6 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -75,9 +74,8 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: - CssLength l = (CssLength) val; + CssLength l = val.getLength(); if (!l.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); @@ -85,7 +83,7 @@ value = l; break; case CssTypes.CSS_PERCENTAGE: - CssPercentage p = (CssPercentage) val; + CssPercentage p = val.getPercentage(); if (!p.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); Index: CssBackgroundSize.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackgroundSize.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CssBackgroundSize.java 28 Aug 2012 20:31:17 -0000 1.6 +++ CssBackgroundSize.java 6 Sep 2012 12:37:57 -0000 1.7 @@ -11,7 +11,8 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; -import org.w3c.css.values.CssNumber; +import org.w3c.css.values.CssLength; +import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -81,12 +82,25 @@ op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: + CssLength l = val.getLength(); + if (!l.isPositive()) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + if (is_complete) { + vl = new CssValueList(); + vl.add(val); + } else { + vl.add(val); + values.add(vl); + } + is_complete = !is_complete; + break; case CssTypes.CSS_PERCENTAGE: // per spec only non-negative values are allowed - float f = ((Float) val.get()).floatValue(); - if (f < 0) { + CssPercentage p = val.getPercentage(); + if (!p.isPositive()) { throw new InvalidParamException("negative-value", val.toString(), ac); } Index: CssZIndex.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssZIndex.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CssZIndex.java 15 Aug 2012 20:10:10 -0000 1.1 +++ CssZIndex.java 6 Sep 2012 12:37:58 -0000 1.2 @@ -11,7 +11,6 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -20,70 +19,72 @@ */ public class CssZIndex extends org.w3c.css.properties.css.CssZIndex { - /** - * Create a new CssZIndex - */ - public CssZIndex() { - value = auto; - } + /** + * Create a new CssZIndex + */ + public CssZIndex() { + value = initial; + } - /** - * Create a new CssZIndex - * - * @param ac The context - * @param expression The expression for this property - * @param check true will test the number of parameters - * @throws org.w3c.css.util.InvalidParamException The expression is incorrect - */ - public CssZIndex(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Create a new CssZIndex + * + * @param ac The context + * @param expression The expression for this property + * @param check true will test the number of parameters + * @throws org.w3c.css.util.InvalidParamException + * The expression is incorrect + */ + public CssZIndex(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { - if (check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - CssValue val = expression.getValue(); + CssValue val = expression.getValue(); - setByUser(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - if (((CssNumber) val).isInteger()) { - value = val; - break; - } - throw new InvalidParamException("integer", - val.toString(), - getPropertyName(), ac); - case CssTypes.CSS_IDENT: - CssIdent ide = (CssIdent) val; - if (inherit.equals(ide)) { - value = inherit; - break; - } else if (auto.equals(ide)) { - value = auto; - break; - } - default: - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - expression.next(); - } + setByUser(); + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + if (val.getNumber().isInteger()) { + value = val; + break; + } + throw new InvalidParamException("integer", + val.toString(), + getPropertyName(), ac); + case CssTypes.CSS_IDENT: + CssIdent ide = (CssIdent) val; + if (inherit.equals(ide)) { + value = inherit; + break; + } else if (auto.equals(ide)) { + value = auto; + break; + } + default: + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); + } + expression.next(); + } - /** - * Create a new CssZIndex - * - * @param ac, the Context - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException The expression is incorrect - */ - public CssZIndex(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Create a new CssZIndex + * + * @param ac, the Context + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * The expression is incorrect + */ + public CssZIndex(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - public boolean isDefault() { - return (auto == value); - } + public boolean isDefault() { + return (auto == value) || (auto == initial); + } } Index: CssBorderImageOutset.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorderImageOutset.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssBorderImageOutset.java 26 Apr 2012 18:33:30 -0000 1.2 +++ CssBorderImageOutset.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -21,77 +21,77 @@ */ public class CssBorderImageOutset extends org.w3c.css.properties.css.CssBorderImageOutset { - /** - * Create a new CssBorderImageOutset - */ - public CssBorderImageOutset() { - value = initial; - } + /** + * Create a new CssBorderImageOutset + */ + public CssBorderImageOutset() { + value = initial; + } - /** - * Creates a new CssBorderImageOutset - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssBorderImageOutset(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + /** + * Creates a new CssBorderImageOutset + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssBorderImageOutset(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { - CssValueList valueList = new CssValueList(); - if (check && expression.getCount() > 4) { - throw new InvalidParamException("unrecognize", ac); - } - CssValue val; - char op; + CssValueList valueList = new CssValueList(); + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + CssValue val; + char op; - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - CssNumber num = (CssNumber)val; - if (!num.isPositive()) { - throw new InvalidParamException("negative-value", num, - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_LENGTH: - CssLength length = (CssLength)val; - if (!length.isPositive()) { - throw new InvalidParamException("negative-value", length, - getPropertyName(), ac); - } - valueList.add(val); - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - valueList.add(inherit); - break; - } - // unrecognized ident, let it fail - default: - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); - } - expression.next(); - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - value = (valueList.size() == 1) ? valueList.get(0) : valueList; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + CssNumber num = val.getNumber(); + if (!num.isPositive()) { + throw new InvalidParamException("negative-value", num, + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_LENGTH: + CssLength length = val.getLength(); + if (!length.isPositive()) { + throw new InvalidParamException("negative-value", length, + getPropertyName(), ac); + } + valueList.add(val); + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + valueList.add(inherit); + break; + } + // unrecognized ident, let it fail + default: + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + expression.next(); + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + value = (valueList.size() == 1) ? valueList.get(0) : valueList; + } - public CssBorderImageOutset(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBorderImageOutset(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } } Index: CssBorderWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBorderWidth.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CssBorderWidth.java 26 Apr 2012 18:33:31 -0000 1.2 +++ CssBorderWidth.java 6 Sep 2012 12:37:57 -0000 1.3 @@ -11,7 +11,6 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -94,9 +93,8 @@ switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; + CssLength length = val.getLength(); if (!length.isPositive()) { throw new InvalidParamException("negative-value", expression.getValue(), getPropertyName(), ac); @@ -177,9 +175,8 @@ CssValue val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); case CssTypes.CSS_LENGTH: - CssLength length = (CssLength) val; + CssLength length = val.getLength(); if (!length.isPositive()) { throw new InvalidParamException("negative-value", expression.getValue(), caller.getPropertyName(), ac); Index: CssWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/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:33 -0000 1.2 +++ CssWidth.java 6 Sep 2012 12:37:58 -0000 1.3 @@ -4,13 +4,11 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; -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; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -21,136 +19,76 @@ */ 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 org.w3c.css.util.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 (inherit.equals(val)) { - identVal = inherit; - } else if (initial.equals(val)) { - identVal = initial; - } else 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() { + value = initial; + } - public CssWidth(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Create a new CssWidth. + * + * @param expression The expression for this property + * @throws org.w3c.css.util.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 (inherit.equals(val)) { + value = inherit; + } else if (auto.equals(val)) { + value = auto; + } else { + throw new InvalidParamException("unrecognize", ac); + } + break; + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_LENGTH: + CssLength l = val.getLength(); + if (!l.isPositive()) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + value = l; + break; + case CssTypes.CSS_PERCENTAGE: + CssPercentage p = val.getPercentage(); + 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) || (identVal == initial)); - } + /** + * 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) || (value == initial)); + } } Index: CssColumnWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnWidth.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- CssColumnWidth.java 9 Feb 2012 17:36:32 -0000 1.11 +++ CssColumnWidth.java 6 Sep 2012 12:37:57 -0000 1.12 @@ -8,13 +8,11 @@ package org.w3c.css.properties.css3; -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; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -24,113 +22,81 @@ public class CssColumnWidth extends org.w3c.css.properties.css.CssColumnWidth { - private static final String propertyName = "column-width"; - - CssValue width; - - static CssIdent auto; - - static { - auto = CssIdent.getIdent("auto"); - } - - /** - * Create a new CssColumnWidth - */ - public CssColumnWidth() { - width = initial; - } + private static final String propertyName = "column-width"; - /** - * Create a new CssColumnWidth - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Incorrect value - */ - public CssColumnWidth(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - setByUser(); - CssValue val = expression.getValue(); + static CssIdent auto; - if (check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } + static { + auto = CssIdent.getIdent("auto"); + } - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val = ((CssNumber) val).getLength(); - // if we didn't fall in the first trap, there is another one :) - throw new InvalidParamException("strictly-positive", - expression.getValue(), - getPropertyName(), ac); - case CssTypes.CSS_LENGTH: - CssLength l = (CssLength) val; - if (l == null || !l.isStrictlyPositive()) { - throw new InvalidParamException("strictly-positive", - expression.getValue(), - getPropertyName(), ac); - } - width = val; - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - width = inherit; - break; - } else if (auto.equals(val)) { - width = auto; - break; - } - default: - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - expression.next(); - } + /** + * Create a new CssColumnWidth + */ + public CssColumnWidth() { + value = initial; + } - public CssColumnWidth(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + /** + * Create a new CssColumnWidth + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Incorrect value + */ + public CssColumnWidth(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { - /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssColumnWidth && - width.equals(((CssColumnWidth) property).width)); - } + setByUser(); + CssValue val = expression.getValue(); - /** - * Returns the value of this property - */ - public Object get() { - return width; - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return (inherit == width); - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val = val.getLength(); + // if we didn't fall in the first trap, there is another one :) + throw new InvalidParamException("strictly-positive", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_LENGTH: + CssLength l = val.getLength(); + if (l == null || !l.isStrictlyPositive()) { + throw new InvalidParamException("strictly-positive", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + break; + case CssTypes.CSS_IDENT: + if (inherit.equals(val)) { + value = inherit; + break; + } else if (auto.equals(val)) { + value = auto; + break; + } + default: + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); + } + expression.next(); + } - /** - * Returns a string representation of the object - */ - public String toString() { - return width.toString(); - } + public CssColumnWidth(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Is the value of this property a default value - * It is used by all macro for the function <code>print</code> - */ - public boolean isDefault() { - return (auto == initial); - } + /** + * Is the value of this property a default value + * It is used by all macro for the function <code>print</code> + */ + public boolean isDefault() { + return (auto == initial); + } }
Received on Thursday, 6 September 2012 12:38:08 UTC