- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 04 May 2012 12:58:24 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css21 In directory hutz:/tmp/cvs-serv17162/css/properties/css21 Modified Files: CssBackground.java Log Message: reformat + small fix Index: CssBackground.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css21/CssBackground.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CssBackground.java 9 Feb 2012 17:36:31 -0000 1.1 +++ CssBackground.java 4 May 2012 12:58:22 -0000 1.2 @@ -24,420 +24,335 @@ */ public class CssBackground extends org.w3c.css.properties.css.CssBackground { - public CssBackgroundColor color; - public CssBackgroundImage image; - public CssBackgroundRepeat repeat; - public CssBackgroundAttachment attachment; - public CssBackgroundPosition position; - - public boolean same; - - /** - * Create a new CssBackground - */ - public CssBackground() { - super(); - } - - /** - * Set the value of the property - * - * @param expression The expression for this property - * @throws InvalidParamException The expression is incorrect - */ - public CssBackground(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - CssValue val; - char op = SPACE; - boolean find = true; - CssExpression background_position_expression = null; - - // too many values - if (check && expression.getCount() > 6) { - throw new InvalidParamException("unrecognize", ac); - } - - setByUser(); - - boolean manyValues = (expression.getCount() > 1); - - while (find) { - val = expression.getValue(); - if (val == null) { - break; - } - op = expression.getOperator(); - - // if there are many values, we can't have inherit as one of them - if (manyValues && val.equals(inherit)) { - throw new InvalidParamException("unrecognize", null, null, ac); - } - - switch (val.getType()) { - case CssTypes.CSS_STRING: - if (check) { - throw new InvalidParamException("unrecognize", ac); - } - find = false; - break; - case CssTypes.CSS_URL: - if (getImage() == null) { - setImage(new CssBackgroundImage(ac, expression)); - continue; - } - find = false; - break; - case CssTypes.CSS_COLOR: - if (getColor2() == null) { - setColor(new CssBackgroundColor(ac, expression)); - continue; - } - find = false; - break; - case CssTypes.CSS_NUMBER: - case CssTypes.CSS_PERCENTAGE: - case CssTypes.CSS_LENGTH: - if (background_position_expression == null) { - background_position_expression = new CssExpression(); - } - background_position_expression.addValue(val); - expression.next(); - find = true; - break; - case CssTypes.CSS_IDENT: - // the hard part, as ident can be from different subproperties - find = false; - CssIdent identval = (CssIdent) val; - if (inherit.equals(identval) && !manyValues) { - find = true; - same = true; - expression.next(); - break; - } - // check background-image ident - if (CssBackgroundImage.checkMatchingIdent(identval)) { - if (getImage() == null) { - setImage(new CssBackgroundImage(ac, expression)); - find = true; - } - break; - } - // check background-repeat ident - if (CssBackgroundRepeat.checkMatchingIdent(identval)) { - if (getRepeat() == null) { - setRepeat(new CssBackgroundRepeat(ac, expression)); - find = true; - } - break; - } - // check background-attachment ident - if (CssBackgroundAttachment.checkMatchingIdent(identval)) { - if (getAttachment() == null) { - setAttachment(new CssBackgroundAttachment(ac, - expression)); - find = true; - } - break; - } - // check background-position ident - if (CssBackgroundPosition.checkMatchingIdent(identval)) { - if (background_position_expression == null) { - background_position_expression = new CssExpression(); - } - background_position_expression.addValue(val); - expression.next(); - find = true; - break; - } - - if (getColor2() == null) { - try { - setColor(new CssBackgroundColor(ac, expression)); - find = true; - break; - } catch (InvalidParamException e) { - // nothing to do, image will test this value - } - } - - default: - if (check) { - throw new InvalidParamException("unrecognize", ac); - } - find = false; - } - if (check && !find) { - throw new InvalidParamException("unrecognize", ac); - } - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), - ac); - } - } - if (background_position_expression != null) { - setPosition(new CssBackgroundPosition(ac, - background_position_expression, - check)); - } - } - - public CssBackground(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } + public CssBackgroundColor color; + public CssBackgroundImage image; + public CssBackgroundRepeat repeat; + public CssBackgroundAttachment attachment; + public CssBackgroundPosition position; - /** - * @return Returns the attachment. - */ - public CssBackgroundAttachment getAttachment() { - return attachment; - } + public boolean same; - /** - * @param attachment The attachment to set. - */ - public void setAttachment(CssBackgroundAttachment attachment) { - this.attachment = attachment; - } + /** + * Create a new CssBackground + */ + public CssBackground() { + super(); + } - /** - * @return Returns the image. - */ - public CssBackgroundImage getImage() { - return image; - } + /** + * Set the value of the property + * + * @param expression The expression for this property + * @throws InvalidParamException The expression is incorrect + */ + public CssBackground(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + CssValue val; + char op = SPACE; + boolean find = true; + CssExpression background_position_expression = null; - /** - * @param image The image to set. - */ - public void setImage(CssBackgroundImage image) { - this.image = image; - } + // too many values + if (check && expression.getCount() > 6) { + throw new InvalidParamException("unrecognize", ac); + } - /** - * @return Returns the repeat. - */ - public CssBackgroundRepeat getRepeat() { - return repeat; - } + setByUser(); - /** - * @param repeat The repeat to set. - */ - public void setRepeat(CssBackgroundRepeat repeat) { - this.repeat = repeat; - } + boolean manyValues = (expression.getCount() > 1); - /** - * @return Returns the same. - */ - public boolean isSame() { - return same; - } + while (find) { + val = expression.getValue(); + if (val == null) { + break; + } + op = expression.getOperator(); - /** - * @param same The same to set. - */ - public void setSame(boolean same) { - this.same = same; - } + // if there are many values, we can't have inherit as one of them + if (manyValues && val.equals(inherit)) { + throw new InvalidParamException("unrecognize", null, null, ac); + } - /** - * Returns the color - */ - public final CssBackgroundColor getColor2() { - return color; - } + switch (val.getType()) { + case CssTypes.CSS_STRING: + if (check) { + throw new InvalidParamException("unrecognize", ac); + } + find = false; + break; + case CssTypes.CSS_URL: + if (image == null) { + image = new CssBackgroundImage(ac, expression); + continue; + } + find = false; + break; + case CssTypes.CSS_COLOR: + if (color == null) { + color = new CssBackgroundColor(ac, expression); + continue; + } + find = false; + break; + case CssTypes.CSS_NUMBER: + case CssTypes.CSS_PERCENTAGE: + case CssTypes.CSS_LENGTH: + if (background_position_expression == null) { + background_position_expression = new CssExpression(); + } + background_position_expression.addValue(val); + expression.next(); + find = true; + break; + case CssTypes.CSS_IDENT: + // the hard part, as ident can be from different subproperties + find = false; + CssIdent identval = (CssIdent) val; + if (inherit.equals(identval) && !manyValues) { + find = true; + same = true; + expression.next(); + break; + } + // check background-image ident + if (CssBackgroundImage.checkMatchingIdent(identval)) { + if (image == null) { + image = new CssBackgroundImage(ac, expression); + find = true; + } + break; + } + // check background-repeat ident + if (CssBackgroundRepeat.checkMatchingIdent(identval)) { + if (repeat == null) { + repeat = new CssBackgroundRepeat(ac, expression); + find = true; + } + break; + } + // check background-attachment ident + if (CssBackgroundAttachment.checkMatchingIdent(identval)) { + if (attachment == null) { + attachment = new CssBackgroundAttachment(ac, expression); + find = true; + } + break; + } + // check background-position ident + if (CssBackgroundPosition.checkMatchingIdent(identval)) { + if (background_position_expression == null) { + background_position_expression = new CssExpression(); + } + background_position_expression.addValue(val); + expression.next(); + find = true; + break; + } - /** - * @param color The color to set. - */ - public void setColor(CssBackgroundColor color) { - this.color = color; - } + if (color == null) { + try { + color = new CssBackgroundColor(ac, expression); + find = true; + break; + } catch (InvalidParamException e) { + // nothing to do, image will test this value + } + } - /** - * @return Returns the position. - */ - public CssBackgroundPosition getPosition() { - return position; - } + default: + if (check) { + throw new InvalidParamException("unrecognize", ac); + } + find = false; + } + if (check && !find) { + throw new InvalidParamException("unrecognize", ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), + ac); + } + } + if (background_position_expression != null) { + position = new CssBackgroundPosition(ac, + background_position_expression, + check); + } + } - /** - * @param position The position to set. - */ - public void setPosition(CssBackgroundPosition position) { - this.position = position; - } + public CssBackground(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } - /** - * Returns the value of this property - */ - public Object get() { - return color; - } + /** + * Returns the value of this property + */ + public Object get() { + return color; + } - /** - * Returns the color - */ - public final CssValue getColor() { - if (color == null) { - return null; - } else { - return color.getColor(); - } - } + /** + * Returns the color + */ + public final CssValue getColor() { + if (color == null) { + return null; + } else { + return color.getColor(); + } + } - /** - * Returns a string representation of the object. - */ - public String toString() { + /** + * Returns a string representation of the object. + */ + public String toString() { - if (same) { - return inherit.toString(); - } else { - StringBuilder sb = new StringBuilder(); - boolean addspace = false; + if (same) { + return inherit.toString(); + } else { + StringBuilder sb = new StringBuilder(); + boolean addspace = false; - if (color != null) { - sb.append(color); - addspace = true; - } - if (image != null) { - if (addspace) { - sb.append(' '); - } - sb.append(image); - addspace = true; - } - if (repeat != null) { - if (addspace) { - sb.append(' '); - } - sb.append(repeat); - addspace = true; - } - if (attachment != null) { - if (addspace) { - sb.append(' '); - } - sb.append(attachment); - addspace = true; - } - if (position != null) { - if (addspace) { - sb.append(' '); - } - sb.append(position); - } - return sb.toString(); - } - } + if (color != null) { + sb.append(color); + addspace = true; + } + if (image != null) { + if (addspace) { + sb.append(' '); + } + sb.append(image); + addspace = true; + } + if (repeat != null) { + if (addspace) { + sb.append(' '); + } + sb.append(repeat); + addspace = true; + } + if (attachment != null) { + if (addspace) { + sb.append(' '); + } + sb.append(attachment); + addspace = true; + } + if (position != null) { + if (addspace) { + sb.append(' '); + } + sb.append(position); + } + return sb.toString(); + } + } - /** - * Set this property to be important. - * Overrides this method for a macro - */ + /** + * Set this property to be important. + * Overrides this method for a macro + */ - public void setImportant() { - important = true; - if (color != null) { - color.important = true; - } - if (image != null) { - image.important = true; - } - if (repeat != null) { - repeat.important = true; - } - if (attachment != null) { - attachment.important = true; - } - if (position != null) { - position.important = true; - } - } + public void setImportant() { + important = true; + if (color != null) { + color.important = true; + } + if (image != null) { + image.important = true; + } + if (repeat != null) { + repeat.important = true; + } + if (attachment != null) { + attachment.important = true; + } + if (position != null) { + position.important = true; + } + } - /** - * Returns true if this property is important. - * Overrides this method for a macro - */ - public boolean getImportant() { - if (same) { - return important; - } - return ((color == null || color.important) && - (image == null || image.important) && - (repeat == null || repeat.important) && - (attachment == null || attachment.important) && - (position == null || position.important)); - } + /** + * Returns true if this property is important. + * Overrides this method for a macro + */ + public boolean getImportant() { + if (same) { + return important; + } + return ((color == null || color.important) && + (image == null || image.important) && + (repeat == null || repeat.important) && + (attachment == null || attachment.important) && + (position == null || position.important)); + } - /** - * Set the context. - * Overrides this method for a macro - * - * @see org.w3c.css.css.CssCascadingOrder#order - * @see org.w3c.css.css.StyleSheetParser#handleRule - */ - public void setSelectors(CssSelectors selector) { - super.setSelectors(selector); - if (color != null) { - color.setSelectors(selector); - } - if (image != null) { - image.setSelectors(selector); - } - if (repeat != null) { - repeat.setSelectors(selector); - } - if (attachment != null) { - attachment.setSelectors(selector); - } - if (position != null) { - position.setSelectors(selector); - } - } + /** + * Set the context. + * Overrides this method for a macro + * + * @see org.w3c.css.css.CssCascadingOrder#order + * @see org.w3c.css.css.StyleSheetParser#handleRule + */ + public void setSelectors(CssSelectors selector) { + super.setSelectors(selector); + if (color != null) { + color.setSelectors(selector); + } + if (image != null) { + image.setSelectors(selector); + } + if (repeat != null) { + repeat.setSelectors(selector); + } + if (attachment != null) { + attachment.setSelectors(selector); + } + if (position != null) { + position.setSelectors(selector); + } + } - /** - * Add this property to the CssStyle - * - * @param style The CssStyle - */ - public void addToStyle(ApplContext ac, CssStyle style) { - ((Css1Style) style).cssBackground.same = same; - ((Css1Style) style).cssBackground.byUser = byUser; + /** + * Add this property to the CssStyle + * + * @param style The CssStyle + */ + public void addToStyle(ApplContext ac, CssStyle style) { + ((Css1Style) style).cssBackground.same = same; + ((Css1Style) style).cssBackground.byUser = byUser; - if (color != null) { - color.addToStyle(ac, style); - } - if (image != null) { - image.addToStyle(ac, style); - } - if (repeat != null) { - repeat.addToStyle(ac, style); - } - if (attachment != null) { - attachment.addToStyle(ac, style); - } - if (position != null) { - position.addToStyle(ac, style); - } - } + if (color != null) { + color.addToStyle(ac, style); + } + if (image != null) { + image.addToStyle(ac, style); + } + if (repeat != null) { + repeat.addToStyle(ac, style); + } + if (attachment != null) { + attachment.addToStyle(ac, style); + } + if (position != null) { + position.addToStyle(ac, style); + } + } - /** - * Get this property in the style. - * - * @param style The style where the property is - * @param resolve if true, resolve the style to find this property - */ - public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { - if (resolve) { - return ((Css1Style) style).getBackground(); - } else { - return ((Css1Style) style).cssBackground; - } - } + /** + * Get this property in the style. + * + * @param style The style where the property is + * @param resolve if true, resolve the style to find this property + */ + public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { + if (resolve) { + return ((Css1Style) style).getBackground(); + } else { + return ((Css1Style) style).cssBackground; + } + } }
Received on Friday, 4 May 2012 12:58:28 UTC