2002/css-validator/org/w3c/css/properties/css2 CssColor.java,NONE,1.1 CssBackgroundRepeatCSS2.java,1.2,1.3

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2
In directory hutz:/tmp/cvs-serv17942/org/w3c/css/properties/css2

Modified Files:
	CssBackgroundRepeatCSS2.java 
Added Files:
	CssColor.java 
Log Message:
some reordering to have only one background-color to check in checkConflicts (like what was done for CssColors

Index: CssBackgroundRepeatCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css2/CssBackgroundRepeatCSS2.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- CssBackgroundRepeatCSS2.java	5 Jan 2010 19:49:51 -0000	1.2
+++ CssBackgroundRepeatCSS2.java	4 Oct 2011 13:05:24 -0000	1.3
@@ -50,7 +50,7 @@
  */
 public class CssBackgroundRepeatCSS2 extends CssBackgroundRepeat {
     // FIXME TODO is that the best way ?
-    
+
     public static boolean checkMatchingIdent(CssIdent ident) {
         return allowed_values.containsValue(ident);
     }

--- NEW FILE: CssColor.java ---
//
// $Id: CssColor.java,v 1.1 2011/10/04 13:05:24 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css2;

import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

/**
 * @version $Revision: 1.1 $
 * @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/colors.html#propdef-color
 */
public class CssColor extends org.w3c.css.properties.css.CssColor {

    org.w3c.css.values.CssColor color;
    String attrvalue = null;
    boolean inherited;

    /**
     * Create a new CssColor
     */
    public CssColor() {
    }

    /**
     * Set the value of the property
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException
     *          Values are incorrect
     */
    public CssColor(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:
                if (inherit.equals(val)) {
                    inherited = true;
                } else {
                    color = new org.w3c.css.values.CssColor(ac, (String) val.get());
                }
                break;
            // in the parser, rgb func and hexval func generate a CssColor directly
            // so, no need for a CSS_FUNCTION case
            case CssTypes.CSS_COLOR:
                try {
                   color = (org.w3c.css.values.CssColor) val;
                } catch (ClassCastException ex) {
                    // as we checked the type, it can't happen
                    throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
                }
                break;
            default:
                throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
        }
        expression.next();
    }

    public CssColor(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return (inherited) ? inherit : color;
    }

    /**
     * Returns the color
     */
    public org.w3c.css.values.CssColor getColor() {
        return (inherited) ? null : color;
    }

    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
        return inherited;
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (attrvalue != null) {
            return attrvalue;
        } else {
            return (inherited) ? inherit.toString() : color.toString();
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        CssColor other;
        try {
            other = (CssColor) property;
            return ((inherited && other.inherited) ||
                    (!inherited && !other.inherited) && (color.equals(other.color)));
        } catch (ClassCastException ex) {
            return false;
        }
    }
}

Received on Tuesday, 4 October 2011 13:05:29 UTC