2002/css-validator/org/w3c/css/properties/css CssBackground.java,NONE,1.1 CssBackgroundAttachment.java,NONE,1.1 CssBackgroundClip.java,NONE,1.1 CssBackgroundColor.java,NONE,1.1 CssBackgroundConstants.java,NONE,1.1 CssBackgroundImage.java,NONE,1.1 CssBackgroundOrigin.java,NONE,1.1 CssBackgroundPosition.java,NONE,1.1 CssBackgroundRepeat.java,NONE,1.1 CssBackgroundSize.java,NONE,1.1 CssBreakAfter.java,NONE,1.1 CssBreakBefore.java,NONE,1.1 CssBreakInside.java,NONE,1.1 CssColumnCount.java,NONE,1.1 CssColumnFill.java,NONE,1.1 CssColumnGap.java,NONE,1.1 CssColumnRule.java,NONE,1.1 CssColumnRuleColor.java,NONE,1.1 CssColumnRuleStyle.java,NONE,1.1 CssColumnRuleWidth.java,NONE,1.1 CssColumnSpan.java,NONE,1.1 CssColumnWidth.java,NONE,1.1 CssColumns.java,NONE,1.1 CssDisplay.java,NONE,1.1 CssProperties.java,NONE,1.1 CssProperty.java,NONE,1.1 CssZIndex.java,NONE,1.1

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

Added Files:
	CssBackground.java CssBackgroundAttachment.java 
	CssBackgroundClip.java CssBackgroundColor.java 
	CssBackgroundConstants.java CssBackgroundImage.java 
	CssBackgroundOrigin.java CssBackgroundPosition.java 
	CssBackgroundRepeat.java CssBackgroundSize.java 
	CssBreakAfter.java CssBreakBefore.java CssBreakInside.java 
	CssColumnCount.java CssColumnFill.java CssColumnGap.java 
	CssColumnRule.java CssColumnRuleColor.java 
	CssColumnRuleStyle.java CssColumnRuleWidth.java 
	CssColumnSpan.java CssColumnWidth.java CssColumns.java 
	CssDisplay.java CssProperties.java CssProperty.java 
	CssZIndex.java 
Log Message:
Implementation of css3-background (partial, missing background-color and background, also borders not done)
cf. http://www.w3.org/TR/2009/CR-css3-background-20091217/

moved and corrected implementation of css3-multicol 
cf. http://www.w3.org/TR/2009/CR-css3-multicol-20091217/

Some reorganization of code.


--- NEW FILE: CssColumnFill.java ---
// $Id: CssColumnFill.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.HashMap;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#filling-columns
 * <p/>
 * There are two strategies for filling columns: columns can either be
 * balanced, or not. If columns are balanced, UAs should minimize the variation
 * in column length. Otherwise, columns are filled sequentially and will
 * therefore end up having different lengths. In any case, the user agent
 * should try to honor the ÔwidowsÕ and ÔorphansÕ properties.
 * <p/>
 * Name: 	column-fill
 * Value: 	auto | balance
 * Initial: 	balance
 * Applies to: 	multi-column elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	see below
 * Computed value: 	as specified
 */

public class CssColumnFill extends CssProperty {

    private static final String propertyName = "column-fill";

    CssIdent value;

    static CssIdent balance;
    public static HashMap<String, CssIdent> allowed_values;

    static {
        balance = CssIdent.getIdent("balance");
        allowed_values = new HashMap<String, CssIdent>();
        allowed_values.put("balance", balance);
        allowed_values.put("auto", CssIdent.getIdent("auto"));
    }

    /**
     * Create a new CssColumnWidth
     */
    public CssColumnFill() {
        value = balance;
    }

    /**
     * Create a new CssColumnFill
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check if length check is needed
     * @throws InvalidParamException Incorrect value
     */
    public CssColumnFill(ApplContext ac, CssExpression expression,
                         boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        if (val.getType() != CssTypes.CSS_IDENT) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        // ident, so inherit, or allowed value
        if (inherit.equals(val)) {
            value = inherit;
        } else {
            val = allowed_values.get(val.toString());
            if (val == null) {
                throw new InvalidParamException("value",
                        expression.getValue(),
                        getPropertyName(), ac);
            }
            value = (CssIdent) val;
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnFill != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnFill = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnFill();
        } else {
            return ((Css3Style) style).cssColumnFill;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssColumnFill &&
                value.equals(((CssColumnFill) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return value.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 (balance == value);
    }

}

--- NEW FILE: CssBackground.java ---
//
// $Id: CssBackground.java,v 1.1 2010/01/05 13:49:37 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.css;

import org.w3c.css.parser.CssPrinterStyle;
import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.properties.css.CssBackgroundSize;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssOperator;
import org.w3c.css.values.CssValue;

/**
 * <H4>
 * <A NAME="background">5.3.7 &nbsp;&nbsp; 'background'</A>
 * </H4>
 * <p/>
 * <EM>Value:</EM> &lt;background-color&gt; || &lt;background-image&gt; ||
 * &lt;background-repeat&gt; || &lt;background-attachment&gt; ||
 * &lt;background-position&gt;<BR>
 * <EM>Initial:</EM> not defined for shorthand properties<BR>
 * <EM>Applies to:</EM> all elements<BR>
 * <EM>Inherited:</EM> no<BR>
 * <EM>Percentage values:</EM> allowed on &lt;background-position&gt;<BR>
 * <p/>
 * The 'background' property is a shorthand property for setting the individual
 * background properties (i.e., 'background-color', 'background-image',
 * 'background-repeat', 'background-attachment' and 'background-position') at
 * the same place in the style sheet.
 * <p/>
 * Possible values on the 'background' properties are the set of all possible
 * values on the individual properties.
 * <PRE>
 * BODY { background: red }
 * P { background: url(chess.png) gray 50% repeat fixed }
 * </PRE>
 * <P> The 'background' property always sets all the individual background
 * properties.  In the first rule of the above example, only a value for
 * 'background-color' has been given and the other individual properties are
 * set to their initial value. In the second rule, all individual properties
 * have been specified.
 *
 * @version $Revision: 1.1 $
 * @see CssBackgroundColor
 * @see CssBackgroundImage
 * @see CssBackgroundRepeat
 * @see CssBackgroundAttachment
 * @see CssBackgroundPosition
 */
public class CssBackground extends CssProperty
        implements CssOperator, CssBackgroundConstants {

    public CssBackgroundColor color;
    public CssBackgroundImage image;
    public CssBackgroundRepeat repeat;
    public CssBackgroundAttachment attachment;
    public CssBackgroundPosition position;
    public CssBackgroundSize size;
    boolean sizedefined;

    boolean same;

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

    /**
     * Set the value of the property<br/>
     * Does not check the number of values
     *
     * @param expression The expression for this property
     * @throws InvalidParamException The expression is incorrect
     */
    public CssBackground(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 InvalidParamException The expression is incorrect
     */
    public CssBackground(ApplContext ac, CssExpression expression,
                         boolean check) throws InvalidParamException {

        CssValue val;
        char op;
        boolean find = true;
        setByUser();

        // if there are too many values -> error
        if (check && expression.getCount() > 6) {
            throw new InvalidParamException("unrecognize", ac);
        }

        boolean manyValues = (expression.getCount() > 1);

        while (find) {
            find = false;
            val = expression.getValue();
            op = expression.getOperator();

            if (val == null) {
                break;
            }

            // if there are many values, we can't have inherit as one of them
            if (manyValues && val != null && val.equals(inherit)) {
                throw new InvalidParamException("unrecognize", null, null, ac);
            }

            if (color == null) {
                try {
                    color = new CssBackgroundColor(ac, expression);
                    find = true;
                } catch (InvalidParamException e) {
                    // nothing to do, image will test this value
                }
            }
            if (!find && image == null) {
                try {
                    image = new CssBackgroundImage(ac, expression);
                    find = true;
                } catch (InvalidParamException e) {
                    // nothing to do, repeat will test this value
                }
            }
            if (!find && repeat == null) {
                try {
                    repeat = new CssBackgroundRepeat(ac, expression);
                    find = true;
                } catch (InvalidParamException e) {
                    // nothing to do, attachment will test this value
                }
            }
            if (!find && attachment == null) {
                try {
                    attachment = new CssBackgroundAttachment(ac, expression);
                    find = true;
                } catch (InvalidParamException e) {
                    // nothing to do, position will test this value
                }
            }
            if (!find && position == null) {
                try {
                    position = new CssBackgroundPosition(ac, expression);
                    find = true;
                } catch (InvalidParamException e) {
                    // nothing to do
                }
            }
            if (op != SPACE) {
                if (op != SLASH) {
                    throw new InvalidParamException("operator",
                            ((new Character(op)).toString()),
                            ac);
                } else {
                    //try {
                    size = new CssBackgroundSize(ac, expression);
                    sizedefined = true;
                    break;
                    //} catch (InvalidParamException e) {
                    // error!
                    //}
                }
            }
            if (check && !find && val != null) {
                throw new InvalidParamException("unrecognize", ac);
            }
        }
    }

    /**
     * @return Returns the image.
     */
    public CssBackgroundImage getImage() {
        return image;
    }

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

    /**
     * Returns the color
     */
    public CssValue getColor() {
        if (color == null) {
            return null;
        } else {
            return color.getColor();
        }
    }

    /**
     * Returns the name of this property
     */
    public String getPropertyName() {
        return "background";
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        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);
        }
        if (sizedefined) {
            sb.append('/').append(size);
        }
        return sb.toString();
    }

    /**
     * Set this property to be important.
     * Overrides this method for a macro
     */
    public void setImportant() {
        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() {
        return ((color == null || color.important) &&
                (image == null || image.important) &&
                (repeat == null || repeat.important) &&
                (attachment == null || attachment.important) &&
                (position == null || position.important));
    }

    /**
     * Print this property.
     *
     * @param printer The printer.
     * @see #toString()
     * @see #getPropertyName()
     */
    public void print(CssPrinterStyle printer) {
        if ((color != null && image != null &&
                repeat != null && attachment != null &&
                position != null) &&
                (getImportant() ||
                        (!image.important &&
                                !color.important &&
                                !repeat.important &&
                                !attachment.important &&
                                !position.important))) {
            if (color.byUser || image.byUser || repeat.byUser
                    || attachment.byUser || position.byUser) {
                printer.print(this);
            }
        } else {
            if (color != null)
                color.print(printer);
            if (image != null)
                image.print(printer);
            if (repeat != null)
                repeat.print(printer);
            if (attachment != null)
                attachment.print(printer);
            if (position != null)
                position.print(printer);
        }
    }

    /**
     * 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;

        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;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return false; // FIXME
    }

    /**
     * Update the source file and the line.
     * Overrides this method for a macro
     *
     * @param line   The line number where this property is defined
     * @param source The source file where this property is defined
     */
    public void setInfo(int line, String source) {
        super.setInfo(line, source);
        if (color != null) {
            color.setInfo(line, source);
        }
        if (image != null) {
            image.setInfo(line, source);
        }
        if (repeat != null) {
            repeat.setInfo(line, source);
        }
        if (attachment != null) {
            attachment.setInfo(line, source);
        }
        if (position != null) {
            position.setInfo(line, source);
        }
    }

}

--- NEW FILE: CssColumns.java ---
// $Id: CssColumns.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import static org.w3c.css.values.CssOperator.SPACE;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#columns
 * <p/>
 * Name:  	columns
 * Value: 	&lt;Ôcolumn-widthÕ&gt; || &lt;Ôcolumn-countÕ&gt;
 * Initial: 	see individual properties
 * Applies to: 	non-replaced block-level elements (except table elements),
 * table cells, and inline-block elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	see individual properties
 * <p/>
 * This is a shorthand property for setting Ôcolumn-widthÕ and Ôcolumn-countÕ.
 * Omitted values are set to their initial values.
 *
 * @see CssColumnWidth
 * @see CssColumnCount
 */

public class CssColumns extends CssProperty {

    private static final String propertyName = "columns";

    CssIdent value = null;
    CssColumnWidth width = null;
    CssColumnCount count = null;

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

    /**
     * Create a new CssColumns
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check if checking is enforced
     * @throws InvalidParamException Incorrect values
     */
    public CssColumns(ApplContext ac, CssExpression expression,
                      boolean check) throws InvalidParamException {

        CssValue val;
        char op;
        int nb_val = expression.getCount();
        int nb_auto = 0;

        if (check && nb_val > 2) {
            throw new InvalidParamException("unrecognize", ac);
        }
        setByUser();

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            if (op != SPACE) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()),
                        ac);
            }
            switch (val.getType()) {
                case CssTypes.CSS_NUMBER:
                    if (count != null) {
                        throw new InvalidParamException("unrecognize", ac);
                    }
                    count = new CssColumnCount(ac, expression);
                    break;
                case CssTypes.CSS_LENGTH:
                    if (width != null) {
                        throw new InvalidParamException("unrecognize", ac);
                    }
                    width = new CssColumnWidth(ac, expression);
                    break;
                case CssTypes.CSS_IDENT:
                    if (inherit.equals((CssIdent) val)) {
                        if (nb_val > 1) {
                            throw new InvalidParamException("unrecognize", ac);
                        }
                        value = inherit;
                        expression.next();
                        break;
                    }
                    if (CssColumnCount.auto.equals((CssIdent) val)) {
                        nb_auto++;
                        expression.next();
                        break;
                    }
                default:
                    throw new InvalidParamException("value",
                            expression.getValue(),
                            getPropertyName(), ac);
            }
        }
        if (nb_val == 1) {
            if (nb_auto == 1) {
                value = CssIdent.getIdent("auto");
            }
        } else {
            if (nb_auto == 2) {
                count = new CssColumnCount();
                width = new CssColumnWidth();
            } else if (nb_auto == 1) {
                if (count != null) {
                    width = new CssColumnWidth();
                } else {
                    count = new CssColumnCount();
                }
            }
        }
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumns != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumns = this;
        if (count != null) {
            count.addToStyle(ac, style);
        }
        if (width != null) {
            width.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 ((Css3Style) style).getColumns();
        } else {
            return ((Css3Style) style).cssColumns;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return false;
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        // TODO must use a compound value, like in background properties
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }
    /**
     * Returns a string representation of the object
     */
    public String toString() {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        if (value != null) {
            return value.toString();
        }
        if (count != null) {
            sb.append(count);
            first = false;
        }
        if (width != null) {
            if (!first) {
                sb.append(' ');
            }
            sb.append(width);
        }
        return sb.toString();
    }
}

--- NEW FILE: CssBackgroundPosition.java ---
// $Id: CssBackgroundPosition.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
// Rewritten by Yves Lafon <ylafon@w3.org>

// (c) COPYRIGHT MIT, Keio and ERCIM, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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.CssNumber;
import org.w3c.css.values.CssPercentage;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.util.ArrayList;
import java.util.HashMap;

import static org.w3c.css.values.CssOperator.COMMA;
import static org.w3c.css.values.CssOperator.SPACE;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#background-position
 * 
 * Name: 	background-position
 * Value: 	&lt;bg-position&gt; [ , &lt;bg-position&gt; ]*
 * Initial: 	0% 0%
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	refer to size of background positioning area minus size of
 * background image; see text
 * Media: 	visual
 * Computed value: 	If one or two values are specified, for a &lt;length&gt;
 * the absolute value, otherwise a percentage. If three or
 * four values are specified, two pairs of a keyword plus a
 * length or percentage.
 * <p/>
 * <p/>
 * If background images have been specified, this property specifies their
 * initial position (after any resizing) within their corresponding
 * background positioning area.
 * <p/>
 * Where
 * <p/>
 * &lt;bg-position&gt; = [
 * [ [ &lt;percentage&gt; | &lt;length&gt; | left | center | right ] ]
 * [ [ &lt;percentage&gt; | &lt;length&gt; | top | center | bottom ] ]?
 * |
 * [ center | [ left | right ] [ &lt;percentage&gt; | &lt;length&gt; ]? ] ||
 * [ center | [ top | bottom ] [ &lt;percentage&gt; | &lt;length&gt; ]? ]
 * ]
 */
public class CssBackgroundPosition extends CssProperty {

    private static final String propertyName = "background-position";

    public static HashMap<String, CssIdent> allowed_values;
    public static CssIdent center, top, bottom, left, right;
    private static CssPercentage defaultPercent0, defaultPercent50;
    private static CssPercentage defaultPercent100;

    static {
        top = CssIdent.getIdent("top");
        bottom = CssIdent.getIdent("bottom");
        left = CssIdent.getIdent("left");
        right = CssIdent.getIdent("right");
        center = CssIdent.getIdent("center");
        allowed_values = new HashMap<String, CssIdent>();
        allowed_values.put("top", top);
        allowed_values.put("bottom", bottom);
        allowed_values.put("left", left);
        allowed_values.put("right", right);
        allowed_values.put("center", center);

        defaultPercent0 = new CssPercentage(0);
        defaultPercent50 = new CssPercentage(50);
        defaultPercent100 = new CssPercentage(100);
    }

    Object value;

    /**
     * Create a new CssBackgroundPosition
     */
    public CssBackgroundPosition() {
        value = new CssBackgroundPositionValue();
    }

    /**
     * Creates a new CssBackgroundPosition
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundPosition(ApplContext ac, CssExpression expression,
                                 boolean check) throws InvalidParamException {
        setByUser();
        CssValue val;
        ArrayList<CssBackgroundPositionValue> values;
        CssBackgroundPositionValue b_val = null;
        char op;

        values = new ArrayList<CssBackgroundPositionValue>();
        // we just accumulate values and check at validation
        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();

            if (inherit.equals(val)) {
                if (expression.getCount() > 1) {
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
                }
                value = inherit;
                expression.next();
                return;
            }
            if (b_val == null) {
                b_val = new CssBackgroundPositionValue();
            }
            // we will check later
            b_val.add(val);
            expression.next();

            if (!expression.end()) {
                // incomplete value followed by a comma... it's complete!
                if (op == COMMA) {
                    check(b_val, ac);
                    values.add(b_val);
                    b_val = 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 (b_val != null) {
            check(b_val, ac);
            values.add(b_val);
        }
        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }

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


    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList v_list;
            v_list = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object val : v_list) {
                sb.append(val.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.position != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.position = this;
    }

    /**
     * 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).getBackgroundPosition();
        } else {
            return ((Css1Style) style).cssBackground.position;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return ((property != null) &&
                (property instanceof CssBackgroundPosition) &&
                (value.equals(((CssBackgroundPosition) property).value)));
    }

    /**
     * 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() {
        if (!(value instanceof CssBackgroundPositionValue)) {
            return false;
        }
        CssBackgroundPositionValue v = (CssBackgroundPositionValue) value;
        return ((v.val_vertical == defaultPercent0) &&
                (v.val_horizontal == defaultPercent0) &&
                (v.vertical_offset == null) &&
                (v.horizontal_offset == null));
    }

    public void check(CssBackgroundPositionValue v, ApplContext ac)
            throws InvalidParamException
    {
        int nb_keyword = 0;
        int nb_percentage = 0;
        int nb_length = 0;
        int nb_values = v.value.size();

        if (nb_values > 4) {
            throw new InvalidParamException("unrecognize", ac);
        }
        // basic check
        for (CssValue aValue : v.value) {
            switch (aValue.getType()) {
                case CssTypes.CSS_NUMBER:
                    aValue = ((CssNumber) aValue).getLength();
                case CssTypes.CSS_LENGTH:
                    nb_length++;
                    break;
                case CssTypes.CSS_PERCENTAGE:
                    nb_percentage++;
                    break;
                case CssTypes.CSS_IDENT:
                    nb_keyword++;
                    break;
                default:
                    throw new InvalidParamException("unrecognize", aValue,
                            ac);
            }
        }
        if ((nb_keyword > 2) || (nb_length > 2) || (nb_percentage > 2)) {
            throw new InvalidParamException("unrecognize", ac);
        }
        // this is unnecessary complex, blame it on the CSS3 spec.
        switch (nb_keyword) {
            case 0:
                // no keyword, so it's easy, it depends on the number
                // of values :)
                switch (nb_values) {
                    case 1:
                        // If only one value is specified, the second value
                        // is assumed to be ÔcenterÕ.
                        v.horizontal = v.value.get(0);
                        if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
                            v.horizontal = defaultPercent0;
                        }
                        v.val_horizontal = v.horizontal;
                        v.val_vertical = defaultPercent50;
                        break;
                    case 2:
                        v.horizontal = v.value.get(0);
                        if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
                            v.horizontal = defaultPercent0;
                        }
                        v.val_horizontal = v.horizontal;
                        v.vertical = v.value.get(1);
                        if (v.vertical.getType() == CssTypes.CSS_NUMBER) {
                            v.vertical = defaultPercent0;
                        }
                        v.val_vertical = v.vertical;
                        break;
                    default:
                        // If three or four values are given, then each
                        // <percentage> or<length> represents an offset and
                        // must be preceded by a keyword
                        throw new InvalidParamException("unrecognize",
                                ac);

                }
                break;
            // we got one keyword... let's have fun...
            case 1:
                switch (nb_values) {
                    case 1:
                        CssIdent ident = (CssIdent) v.value.get(0);
                        // ugly as we need to set values for equality tests
                        v.val_vertical = defaultPercent50;
                        v.val_horizontal = defaultPercent50;
                        ident = allowed_values.get(ident.toString());
                        if (ident != null) {
                            if (isVertical(ident)) {
                                v.vertical = ident;
                                v.val_vertical = identToPercent(ident);
                            } else {
                                // horizontal || center
                                v.horizontal = ident;
                                v.val_horizontal = identToPercent(ident);
                            }
                            break;
                        }
                        throw new InvalidParamException("unrecognize",
                                ident, propertyName, ac);
                    case 2:
                        // one ident, two values... first MUST be horizontal
                        // and second vertical
                        CssValue val0 = v.value.get(0);
                        if (val0.getType() == CssTypes.CSS_IDENT) {

                            ident = allowed_values.get(val0.toString());
                            if (ident == null) {
                                throw new InvalidParamException("unrecognize",
                                        ident, propertyName, ac);
                            }
                            if (isVertical(ident)) {
                                throw new InvalidParamException("incompatible",
                                        ident, v.value.get(1), ac);
                            }
                            v.horizontal = ident;
                            v.val_horizontal = identToPercent(ident);
                            // and the vertical value...
                            v.vertical = v.value.get(1);
                            if (v.vertical.getType() == CssTypes.CSS_NUMBER) {
                                v.vertical = defaultPercent0;
                            }
                            v.val_vertical = v.vertical;
                        } else {
                            ident = allowed_values.get(v.value.get(1).toString());
                            if (ident == null) {
                                throw new InvalidParamException("unrecognize",
                                        ident, propertyName, ac);
                            }
                            if (isHorizontal(ident)) {
                                throw new InvalidParamException("incompatible",
                                        val0, v.value.get(1), ac);
                            }
                            v.vertical = ident;
                            v.val_vertical = identToPercent(ident);
                            // and the first value
                            v.horizontal = val0;
                            if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
                                v.horizontal = defaultPercent0;
                            }
                            v.val_horizontal = v.horizontal;
                        }
                        break;
                    default:
                        // one ident, 3 or 4 values is not allowed
                        throw new InvalidParamException("unrecognize",
                                ac);
                }
                break;
            default:
                // ok so we have two keywords, with possible offsets
                // we must check that every possible offset is right
                // after a keyword and also that the two keywords are
                // not incompatible
                boolean got_ident = false;
                CssIdent id1 = null;
                CssIdent id2 = null;
                CssValue off1 = null;
                CssValue off2 = null;
                for (CssValue aValue : v.value) {
                    switch (aValue.getType()) {
                        case CssTypes.CSS_IDENT:
                            aValue = allowed_values.get(aValue.toString());
                            if (aValue == null) {
                                throw new InvalidParamException("unrecognize",
                                        aValue, propertyName, ac);
                            }
                            got_ident = true;
                            if (id1 == null) {
                                id1 = (CssIdent) aValue;
                            } else {
                                id2 = (CssIdent) aValue;
                                // we got both, let's check.
                                if (((isVertical(id1) && isVertical(id2))) ||
                                        (isHorizontal(id1) && isHorizontal(id2))) {
                                    throw new InvalidParamException("incompatible",
                                            id1, id2, ac);
                                }
                            }
                            break;
                        case CssTypes.CSS_NUMBER:
                            aValue = ((CssNumber) aValue).getPercentage();
                        case CssTypes.CSS_PERCENTAGE:
                        case CssTypes.CSS_LENGTH:
                            if (!got_ident) {
                                throw new InvalidParamException("unrecognize",
                                        aValue, propertyName, ac);
                            }
                            if (id2 == null) {
                                off2 = aValue;
                            } else {
                                off1 = aValue;
                            }
                            got_ident = false;
                            break;
                        default:
                            // should never happen
                    }
                }
                if (isVertical(id1) || isHorizontal(id2)) {
                    v.horizontal = id2;
                    v.val_horizontal = identToPercent(id2);
                    v.horizontal_offset = off2;
                    v.vertical = id1;
                    v.val_vertical = identToPercent(id1);
                    v.vertical_offset = off1;
                } else {
                    v.horizontal = id1;
                    v.val_horizontal = identToPercent(id1);
                    v.horizontal_offset = off1;
                    v.vertical = id2;
                    v.val_vertical = identToPercent(id2);
                    v.vertical_offset = off2;
                }
        }
    }

    public static CssPercentage identToPercent(CssIdent ident) {
        if (center.equals(ident)) {
            return defaultPercent50;
        } else if (top.equals(ident) || left.equals(ident)) {
            return defaultPercent0;
        } else if (bottom.equals(ident) || right.equals(ident)) {
            return defaultPercent100;
        }
        return defaultPercent0; // FIXME throw an exception ?
    }

    public static boolean isHorizontal(CssIdent ident) {
        return (left.equals(ident) || right.equals(ident));
    }

    public static boolean isVertical(CssIdent ident) {
        return (top.equals(ident) || bottom.equals(ident));
    }

    // placeholder for the different values
    public class CssBackgroundPositionValue extends CssValueList {
        public CssValue vertical = null;
        public CssValue horizontal = null;
        public CssValue vertical_offset = null;
        public CssValue horizontal_offset = null;

        public CssValue val_vertical = defaultPercent0;
        public CssValue val_horizontal = defaultPercent0;

        public boolean equals(CssBackgroundPositionValue v) {
            // check vertical compatibility (with optional values)
            if (!val_vertical.equals(v.val_vertical)) {
                return false;
            }
            if (vertical_offset != null) {
                if (!vertical_offset.equals(v.vertical_offset)) {
                    return false;
                }
            } else if (v.vertical_offset != null) {
                return false;
            }

            if (!val_horizontal.equals(v.val_horizontal)) {
                return false;
            }
            if (horizontal_offset != null) {
                if (!horizontal_offset.equals(v.horizontal_offset)) {
                    return false;
                }
            } else if (v.horizontal_offset != null) {
                return false;
            }
            // yeah!    
            return true;
        }

        public String toString() {
            StringBuilder sb = new StringBuilder();
            if (horizontal != null) {
                sb.append(horizontal);
                if (horizontal_offset != null) {
                    sb.append(' ').append(horizontal_offset);
                }
                if (vertical != null) {
                    sb.append(' ');
                }
            }
            if (vertical != null) {
                sb.append(vertical);
                if (vertical_offset != null) {
                    sb.append(' ').append(vertical_offset);
                }
            }
            return sb.toString();
        }

    }



}

--- NEW FILE: CssColumnRule.java ---
// $Id: CssColumnRule.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import static org.w3c.css.values.CssOperator.SPACE;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-rule
 * <p/>
 * Name:  	column-rule
 * Value: &lt;column-rule-width&gt; || &lt;border-style&gt; ||
 * [ &lt;color&gt; | transparent ]
 * Initial: 	see individual properties
 * Applies to: 	multicol elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	see individual properties
 * <p/>
 * This property is a shorthand for setting Ôcolumn-rule-widthÕ,
 * Ôcolumn-rule-styleÕ, and Ôcolumn-rule-colorÕ at the same place in the
 * style sheet. Omitted values are set to their initial values.
 */

public class CssColumnRule extends CssProperty {

    private static final String propertyName = "column-rule";

    CssIdent value = null;
    CssColumnRuleWidth rule_width = null;
    CssColumnRuleStyle rule_style = null;
    CssColumnRuleColor rule_color = null;

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

    /**
     * Create a new CssColumnRule
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect values
     */
    public CssColumnRule(ApplContext ac, CssExpression expression,
                         boolean check) throws InvalidParamException {

        CssValue val;
        char op;
        int nb_val = expression.getCount();

        if (check && nb_val > 3) {
            throw new InvalidParamException("unrecognize", ac);
        }
        setByUser();

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            if (op != SPACE) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()),
                        ac);
            }
            switch (val.getType()) {
                case CssTypes.CSS_FUNCTION:
                case CssTypes.CSS_COLOR:
                    if (rule_color != null) {
                        throw new InvalidParamException("unrecognize", ac);
                    }
                    rule_color = new CssColumnRuleColor(ac, expression);
                    break;
                case CssTypes.CSS_NUMBER:
                case CssTypes.CSS_LENGTH:
                    if (rule_width != null) {
                        throw new InvalidParamException("unrecognize", ac);
                    }
                    rule_width = new CssColumnRuleWidth(ac, expression);
                    break;
                case CssTypes.CSS_IDENT:
                    if (inherit.equals(val)) {
                        if (nb_val > 1) {
                            throw new InvalidParamException("unrecognize", ac);
                        }
                        value = inherit;
                        expression.next();
                        break;
                    }
                    if (rule_color == null) {
                        try {
                            rule_color = new CssColumnRuleColor(ac, expression);
                            break;
                        } catch (Exception ex) {
                        }
                    }
                    if (rule_width == null) {
                        try {
                            rule_width = new CssColumnRuleWidth(ac, expression);
                            break;
                        } catch (Exception ex) {
                        }
                    }
                    if (rule_style == null) {
                        try {
                            rule_style = new CssColumnRuleStyle(ac, expression);
                            break;
                        } catch (Exception ex) {
                        }
                    }
                default:
                    throw new InvalidParamException("value",
                            expression.getValue(),
                            getPropertyName(), ac);
            }
        }
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnRule != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnRule = this;
        if (rule_style != null) {
            rule_style.addToStyle(ac, style);
        }
        if (rule_color != null) {
            rule_color.addToStyle(ac, style);
        }
        if (rule_width != null) {
            rule_width.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 ((Css3Style) style).getColumnRule();
        } else {
            return ((Css3Style) style).cssColumnRule;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return false;
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        if (value != null) {
            return value.toString();
        }
        if (rule_color != null) {
            sb.append(rule_color);
            first = false;
        }
        if (rule_width != null) {
            if (!first) {
                sb.append(' ');
            }
            sb.append(rule_width);
        }
        if (rule_style != null) {
            if (!first) {
                sb.append(' ');
            }
            sb.append(rule_style);
        }
        return sb.toString();
    }
}

--- NEW FILE: CssColumnCount.java ---
// $Id: CssColumnCount.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#cc
 * <p/>
 * Name:  	column-count
 * Value: 	&lt;integer&gt; | auto
 * Initial: 	auto
 * Applies to: 	non-replaced block-level elements (except table elements),
 * table cells, and inline-block elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	specified value
 * <p/>
 * This property describes the number of columns of a multicol element.
 */

public class CssColumnCount extends CssProperty {

    private static final String propertyName = "column-count";

    CssValue count;

    static CssIdent auto = CssIdent.getIdent("auto");

    /**
     * Create a new CssColumnCount
     */
    public CssColumnCount() {
        count = auto;
    }

    /**
     * Create a new CssColumnCount
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssColumnCount(ApplContext ac, CssExpression expression,
                          boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();
        CssNumber num;

        switch (val.getType()) {
            case CssTypes.CSS_NUMBER:
                num = (CssNumber) val;
                if (!num.isInteger()) {
                    throw new InvalidParamException("integer",
                            expression.getValue(), getPropertyName(), ac);
                }
                if (num.getInt() <= 0) {
                    throw new InvalidParamException("strictly-positive",
                            expression.getValue(),
                            getPropertyName(), ac);
                }
                count = val;
                break;
            case CssTypes.CSS_IDENT:
                if (auto.equals(val)) {
                    count = auto;
                    break;
                }
                if (inherit.equals(val)) {
                    count = inherit;
                    break;
                }
            default:
                throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnCount != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnCount = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnCount();
        } else {
            return ((Css3Style) style).cssColumnCount;
        }
    }

    /**
     * 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 name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * 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);
    }
}

--- NEW FILE: CssProperties.java ---
// $Id: CssProperties.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT, ERCIM andd Keio, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.util.Utf8Properties;

import java.net.URL;

/**
 * @version $Revision: 1.1 $
 */
public class CssProperties {
    public static Utf8Properties properties;

    public static String getString(CssProperty property, String prop) {
	StringBuilder st = new StringBuilder(property.getPropertyName());
	st.append('.').append(prop);
	return properties.getProperty(st.toString());
    }

    public static boolean getInheritance(CssProperty property) {
	return "true".equals(getString(property, "inherited"));
    }

    static {
	properties = new Utf8Properties();
	try {
	    URL url = CssProperties.class.getResource("CSS1Default.properties");
	    java.io.InputStream f = url.openStream();
	    properties.load(f);
	    f.close();
	} catch (Exception e) {
	    System.err.println("org.w3c.css.properties.CssProperties: "+
			       "couldn't load properties ");
	    System.err.println("  " + e.toString());
	}
    }
}

--- NEW FILE: CssColumnRuleStyle.java ---
// $Id: CssColumnRuleStyle.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten Yves lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium
// (MIT, ERCIM, Keio University)
//
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.CssBorderStyleCSS2;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-rule-style
 * 
 * Name:  	column-rule-style
 * Value: 	&lt;Ôborder-styleÕ&gt;
 * Initial: 	none
 * Applies to: 	multicol elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	specified value
 *
 * The Ôcolumn-rule-styleÕ property sets the style of the rule between columns
 * of an element. The &lt;border-style&gt; values are defined in [CSS21].
 */

public class CssColumnRuleStyle extends CssProperty {

    private static final String propertyName = "column-rule-style";

    CssIdent value;

    /**
     * Create a new CssColumnRuleStyle
     */
    public CssColumnRuleStyle() {
        value = none;
    }

    /**
     * Create a new CssColumnRuleStyle
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check if check on length is required
     * @throws InvalidParamException Incorrect value
     */
    public CssColumnRuleStyle(ApplContext ac, CssExpression expression,
                              boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();
        // too many values
        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }
        // we only use Css Ident part of the CssBorderStyle acceptable values
        if (val.getType() != CssTypes.CSS_IDENT) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        CssIdent ident = (CssIdent) val;
        if (inherit.equals(ident)) {
            value = inherit;
        } else if (CssBorderStyleCSS2.acceptable_values.contains(ident)) {
            value = ident;
        } else {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnRuleStyle != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnRuleStyle = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnRuleStyle();
        } else {
            return ((Css3Style) style).cssColumnRuleStyle;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssColumnRuleStyle &&
                value.equals(((CssColumnRuleStyle) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return value.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 none.equals(value);
    }
}

--- NEW FILE: CssBreakBefore.java ---
// $Id: CssBreakBefore.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>

// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.HashMap;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks
 * <p/>
 * When content is laid out in multiple columns, the user agent must determine
 * where column breaks are placed. The problem of breaking content into columns
 * is similar to breaking content into pages.
 * <p/>
 * Three new properties are introduced to allow column breaks to be described
 * in the same properties as page breaks: ‘break-before’, ‘break-after’, and
 * ‘break-inside’. These properties take the same values as
 * ‘page-break-before’, ‘page-break-after’, and ‘page-break-inside’ [CSS21].
 * In addition, some new keyword values are added.
 * <p/>
 * Name:  	break-before
 * Value: 	auto | always | avoid | left | right | page | column |
 * avoid-page | avoid-column
 * Initial: 	auto
 * Applies to: 	block-level elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	paged
 * Computed value: 	specified value
 */

public class CssBreakBefore extends CssProperty {

    private static final String propertyName = "break-before";

    static CssIdent auto;
    static HashMap<String, CssIdent> allowed_values;

    CssIdent value;

    static {
        allowed_values = new HashMap<String, CssIdent>();
        auto = CssIdent.getIdent("auto");
        String id_values[] = {"auto", "always", "avoid", "left", "right",
                "page", "column", "avoid-page", "avoid-column"};
        for (String s : id_values) {
            allowed_values.put(s, CssIdent.getIdent(s));
        }
    }

    /**
     * Create a new CssColumnWidth
     */
    public CssBreakBefore() {
        value = auto;
    }

    /**
     * Create a new CssBreakBefore
     *
     * @param ac         the context
     * @param expression The expression for this property
     * @param check      if checking is needed
     * @throws InvalidParamException Incorrect value
     */
    public CssBreakBefore(ApplContext ac, CssExpression expression,
                          boolean check) throws InvalidParamException {
        setByUser();
        CssValue val = expression.getValue();

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        if (val.getType() != CssTypes.CSS_IDENT) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        // ident, so inherit, or allowed value
        if (inherit.equals(val)) {
            value = inherit;
        } else {
            val = allowed_values.get(val.toString());
            if (val == null) {
                throw new InvalidParamException("value",
                        expression.getValue(),
                        getPropertyName(), ac);
            }
            value = (CssIdent) val;
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssBreakBefore != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBreakBefore = this;
    }

    /**
     * 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 ((Css3Style) style).getBreakBefore();
        } else {
            return ((Css3Style) style).cssBreakBefore;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBreakBefore &&
                value.equals(((CssBreakBefore) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return value.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 (auto == value);
    }

}

--- NEW FILE: CssBackgroundRepeat.java ---
// $Id: CssBackgroundRepeat.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.util.ArrayList;
import java.util.HashMap;

import static org.w3c.css.values.CssOperator.COMMA;
import static org.w3c.css.values.CssOperator.SPACE;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-repeat
 *
 * Name: 	background-repeat
 * Value: 	&lt;repeat-style&gt; [ , &lt;repeat-style&gt; ]*
 * Initial: 	repeat
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	as specified
 *
 * Specifies how background images are tiled after they have been sized and
 * positioned. Where
 *
 * &lt;repeat-style&gt; = repeat-x | repeat-y | [repeat | space |
 *                        round | no-repeat]{1,2}
 *
 */
public class CssBackgroundRepeat extends CssProperty {

    private static final String propertyName = "background-repeat";
    public static CssIdent repeat;
    public static HashMap<String, CssIdent> allowed_simple_values;
    public static HashMap<String, CssIdent> allowed_double_values;

    static {
        allowed_simple_values = new HashMap<String, CssIdent>();
        allowed_double_values = new HashMap<String, CssIdent>();
        String[] REPEAT = {"repeat", "space", "round", "no-repeat"};

        allowed_simple_values.put("repeat-x", CssIdent.getIdent("repeat-x"));
        allowed_simple_values.put("repeat-y", CssIdent.getIdent("repeat-y"));

        for (String aREPEAT : REPEAT) {
            allowed_double_values.put(aREPEAT, CssIdent.getIdent(aREPEAT));
        }
        repeat = CssIdent.getIdent("repeat");
    }

    public Object value;

    /**
     * Create a new CssBackgroundRepeat
     */
    public CssBackgroundRepeat() {
        value = repeat;
    }

    /**
     * Set the value of the property
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check is length checking needed
     * @throws InvalidParamException The expression is incorrect
     */
    public CssBackgroundRepeat(ApplContext ac, CssExpression expression,
                               boolean check) throws InvalidParamException {

        ArrayList<CssValue> values = new ArrayList<CssValue>();
        boolean is_complete = true;
        CssValue val;
        CssValueList vl = null;
        char op;

        setByUser();

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();

            // not an ident? fail
            if (val.getType() != CssTypes.CSS_IDENT) {
                throw new InvalidParamException("value", expression.getValue(),
                        getPropertyName(), ac);
            }

            CssIdent id_val = (CssIdent) val;
            if (inherit.equals(id_val)) {
                // if we got inherit after other values, fail
                // if we got more than one value... fail
                if ((values.size() > 0) || (expression.getCount() > 1)) {
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
                }
                values.add(inherit);
            } else {
                String id_value = id_val.toString();
                CssIdent new_val;
                // check values that must be alone
                new_val = allowed_simple_values.get(id_value);
                if (new_val != null) {
                    // if we already have a double value... it's an error
                    if (!is_complete) {
                        throw new InvalidParamException("value",
                                val, getPropertyName(), ac);
                    }
                    values.add(new_val);
                    is_complete = true;
                } else {
                    // the the one that may come in pairs
                    new_val = allowed_double_values.get(id_value);
                    // not an allowed value !
                    if (new_val == null) {
                        throw new InvalidParamException("value",
                                val, getPropertyName(), ac);
                    }
                    if (is_complete) {
                        vl = new CssValueList();
                        vl.add(new_val);
                    } else {
                        vl.add(new_val);
                        values.add(vl);
                    }
                    is_complete = !is_complete;
                }
            }

            expression.next();
            if (!expression.end()) {
                // incomplete value followed by a comma... it's complete!
                if (!is_complete && (op == COMMA)) {
                    values.add(vl);
                    is_complete = true;
                }
                // complete values are separated by a comma, otherwise space
                if ((is_complete && (op != COMMA)) ||
                        (!is_complete && (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 (!is_complete) {
            values.add(vl);
        }
        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }


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

    /**
     * Returns the value of this property
     */

    public Object get() {
        return value;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList values = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.toString();
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.repeat != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.repeat = this;
    }

    /**
     * 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).getBackgroundRepeat();
        } else {
            return ((Css1Style) style).cssBackground.repeat;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundRepeat &&
                value == ((CssBackgroundRepeat) property).value);
    }

    /**
     * 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 (repeat == value);
    }

}




--- NEW FILE: CssColumnRuleColor.java ---
// $Id: CssColumnRuleColor.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.CssColor;
import org.w3c.css.properties.css3.Css3Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-rule-color
 *
 * Name:  	column-rule-color
 * Value: 	&lt;color&gt;
 * Initial: 	same as for ÔcolorÕ property [CSS21]
 * Applies to: 	multicol elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	the same as the computed value for the ÔcolorÕ
 * property [CSS21]
 *
 * This property sets the color of the column rule. The &lt;color&gt; values are
 * defined in [CSS21].
 */

public class CssColumnRuleColor extends CssProperty {

    private static final String propertyName = "column-rule-color";

    CssColor color;

    /**
     * Create a new CssColumnRuleColor
     */
    public CssColumnRuleColor() {
        // nothing to do
    }

    /**
     * Create a new CssColumnRuleColor
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssColumnRuleColor(ApplContext ac, CssExpression expression,
                              boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        try {
            // we use the latest version of CssColor, aka CSS3
            // instead of using CSS21 colors + transparent per spec.
            color = new CssColor(ac, expression);
        } catch (InvalidParamException e) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnRuleColor != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnRuleColor = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnRuleColor();
        } else {
            return ((Css3Style) style).cssColumnRuleColor;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssColumnRuleColor &&
                color.equals(((CssColumnRuleColor) property).color));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

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

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

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return color.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 false;
    }
}

--- NEW FILE: CssProperty.java ---
// $Id: CssProperty.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.css.StyleSheetOrigin;
import org.w3c.css.parser.CssPrinterStyle;
import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.CssStyle;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.Messages;
import org.w3c.css.values.CssIdent;

/**
 * <DL>
 * <DT>
 * <STRONG>property</STRONG>
 * <DD>
 * a stylistic parameter that can be influenced through CSS. This specification
 * defines a list of properties and their corresponding values.
 * </DL>
 * <p/>
 * If you want to add some properties to the parser, you should subclass this
 * class.
 *
 * @version $Revision: 1.1 $
 */
public abstract class CssProperty
        implements Cloneable, StyleSheetOrigin {

    /**
     * True if this property is important. false otherwise.
     */
    public boolean important;

    /**
     * The origin of this property.
     * the author's style sheets override the reader's style sheet which
     * override the UA's default values. An imported style sheet has the same
     * origin as the style sheet from which it is imported.
     *
     * @see StyleSheetOrigin#BROWSER
     * @see StyleSheetOrigin#READER
     * @see StyleSheetOrigin#AUTHOR
     */
    public int origin;

    /**
     * A unique number for this property.
     * Used by the cascading order algorithm to sort by order specified.
     * If two rules have the same weight, the latter specified wins.
     */
    public long order;

    /**
     * the position of the first character of this value.
     */
    public int line;

    /**
     * the origin file.
     */
    public String sourceFile;

    /**
     * the context.
     */
    public CssSelectors context;

    // internal counter
    private static long increment;

    /**
     * for validator only, true if the property comes from a file
     */
    public boolean byUser = false;

    /**
     * This keyword is used a lot of time in CSS2
     */
    public static final CssIdent inherit;

    /**
     * Used in all CSS versions
     */
    public static final CssIdent transparent;

    /**
     * Value introduced in CSS3
     */
    public static final CssIdent initial;
    public static final CssIdent none;

    static {
        inherit = CssIdent.getIdent("inherit");
        transparent = CssIdent.getIdent("transparent");
        initial = CssIdent.getIdent("initial");
        none = CssIdent.getIdent("none");
    }

    /**
     * Create a new CssProperty.
     */
    public CssProperty() {
        order = increment++;
    }

    /**
     * @return true if the property is inherited.
     */
    public boolean inherited() {
        return CssProperties.getInheritance(this);
    }

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

    /**
     * @return the value of this property.
     *         It is not very usable, implements your own function.
     */
    public abstract Object get();

    /**
     * @return the name of this property IN LOWER CASE.
     */
    public abstract String getPropertyName();

    /**
     * @return the name of this property IN LOWER CASE. escaped
     */
    public String getPropertyNameEscaped() {
        return Messages.escapeString(getPropertyName());
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     * @return a boolean, true if equal
     */
    public abstract boolean equals(CssProperty property);

    /**
     * Print this property.
     *
     * @param printer The printer.
     * @see #toString()
     * @see #getPropertyName()
     */
    public void print(CssPrinterStyle printer) {
        if (byUser || inherited() || important) {
            // if (Inherited() || important) {
            printer.print(this);
        }
    }

    /**
     * Returns a string representation of values.
     * <BR>
     * So if you want have something like this :
     * <SAMP> property-name : property-value1 properpty-value2 ...</SAMP>
     * <BR>
     * You should write something like this :
     * <code>property.getPropertyName() + " : " + property.toString()</code>
     */
    public abstract String toString();

    public String getEscaped() {
        return Messages.escapeString(toString());
    }

    /**
     * Set this property to be important.
     * Overrides this method for a macro
     */
    public void setImportant() {
        important = true;
    }

    /**
     * Returns true if this property is important.
     * Overrides this method for a macro
     *
     * @return a <EM>boolean</EM> true if important
     */
    public boolean getImportant() {
        return important;
    }

    /**
     * Calculate an hashCode for this property.
     */
    public final int hashCode() {
        return getPropertyName().hashCode();
    }

    /**
     * Update the source file and the line.
     * Overrides this method for a macro
     *
     * @param line   The line number where this property is defined
     * @param source The source file where this property is defined
     */
    public void setInfo(int line, String source) {
        this.line = line;
        this.sourceFile = source;
    }

    /**
     * Fix the origin of this property
     * Overrides this method for a macro
     *
     * @param origin, an <EM>int</EM>
     * @see #BROWSER
     * @see #READER
     * @see #AUTHOR
     */
    public void setOrigin(int origin) {
        this.origin = origin;
    }

    /**
     * Returns the attribute origin
     *
     * @return the value of the attribute
     */
    public int getOrigin() {
        return origin;
    }

    /**
     * Is the value of this property is a default value.
     * It is used by all macro for the function <code>print</code>
     *
     * @see #print(CssPrinterStyle)
     */
    public boolean isDefault() {
        return false;
    }

    /**
     * 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 context) {
        this.context = context;
    }

    /**
     * Returns the context.
     *
     * @see org.w3c.css.css.CssCascadingOrder
     */
    public CssSelectors getSelectors() {
        return context;
    }

    /**
     * Duplicate this property.
     *
     * @see org.w3c.css.css.CssCascadingOrder#order
     */
    public CssProperty duplicate() {
        try {
            return (CssProperty) clone();
        } catch (CloneNotSupportedException e) {
            return null;
        }
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public abstract void addToStyle(ApplContext ac, CssStyle 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 abstract CssProperty getPropertyInStyle(CssStyle style,
                                                   boolean resolve);

    /**
     * Returns the source file.
     */
    public final String getSourceFile() {
        return sourceFile;
    }

    /**
     * Returns the line number in the source file.
     */
    public final int getLine() {
        return line;
    }

    /**
     * Calculate the explicit weight and the origin.
     * Declarations marked '!important' carry more weight than unmarked
     * (normal) declarations.
     *
     * @see org.w3c.css.css.CssCascadingOrder
     */
    public final int getExplicitWeight() {
        // browser < reader < author < browser !important < reader !important
        //                                                < author !important
        // here, I use a little trick :
        //  1 < 2 < 3 < 4 ( 1 + 3 ) < 5 ( 2 + 3 ) < 6 ( 3 + 3 )
        return origin + ((important) ? AUTHOR : 0);
    }

    /**
     * Calculate the order specified.
     *
     * @see org.w3c.css.css.CssCascadingOrder
     * @see #order
     */
    public final long getOrderSpecified() {
        return order;
    }

    /**
     * Mark this property comes from the user
     */
    public void setByUser() {
        byUser = true;
    }

    /**
     * Returns the attribute byUser
     *
     * @return the value of the attribute
     */
    public boolean isByUser() {
        return byUser;
    }

}





--- NEW FILE: CssColumnWidth.java ---
// $Id: CssColumnWidth.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewriten 2010 Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-width
 * <p/>
 * Name:  	column-width
 * Value: 	&lt;length&gt; | auto
 * Initial: 	auto
 * Applies to: 	non-replaced block-level elements (except table elements),
 * table cells, and inline-block elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	the absolute length
 * <p/>
 * This property describes the width of columns in multicol elements.
 */

public class CssColumnWidth extends CssProperty {

    private static final String propertyName = "column-width";

    CssValue width;

    static CssIdent auto;

    static {
        auto = CssIdent.getIdent("auto");
    }

    /**
     * Create a new CssColumnWidth
     */
    public CssColumnWidth() {
        width = auto;
    }

    /**
     * Create a new CssColumnWidth
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssColumnWidth(ApplContext ac, CssExpression expression,
                          boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();
        Float value;

        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:
                value = (Float) ((CssLength) val).get();
                if (value == null || value.floatValue() <= 0.0) {
                    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();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnWidth != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnWidth = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnWidth();
        } else {
            return ((Css3Style) style).cssColumnWidth;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssColumnWidth &&
                width.equals(((CssColumnWidth) property).width));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return width;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == width);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return width.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 (auto == width);
    }

}

--- NEW FILE: CssColumnSpan.java ---
//
// $Id: CssColumnSpan.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
//
// (c) COPYRIGHT 1995-2009 
// World Wide Web Consortium (MIT, ERCIM, Keio University)
//
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css3.Css3Style;
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.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

/**
 * From http://www.w3.org/TR/css3-multicol
 *  <P>
 *  <EM>Value:</EM> 1 ||  all <BR>
 *  <EM>Initial:</EM>1<BR>
 *  <EM>Applies to:</EM>static, non-floating elements<BR>
 *  <EM>Inherited:</EM>no<BR>
 *  <EM>Percentages:</EM>N/A<BR>
 *  <EM>Media:</EM>:visual
 */

public class CssColumnSpan extends CssProperty {

    CssValue value;
    ApplContext ac;

    static CssIdent all;
    static {
	all = new CssIdent("all");
    }

    /**
     * Create a new CssColumnSpan
     */
    public CssColumnSpan() {
	//nothing to do
    }

    /**
     * Create a new CssColumnSpan
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */
    public CssColumnSpan(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	this.ac = ac;
	setByUser(); // tell this property is set by the user
	CssValue val = expression.getValue();

	switch (val.getType()) {
	case CssTypes.CSS_NUMBER:
	    int ival = ((CssNumber) val).getInt();
	    if (ival != 1) {
		throw new InvalidParamException("value", val.toString(),
						getPropertyName(), ac);
	    }
	    value = val;
	    break;
	case CssTypes.CSS_IDENT:
	    if (all.equals(val)) {
		value = all;
		break;
	    }
	    if (inherit.equals(val)) {
		value = inherit;
		break;
	    }
	default:
	    throw new InvalidParamException("value", val.toString(),
					    getPropertyName(), ac);
	}
    }

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

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
	if (((Css3Style) style).cssColumnSpan != null)
	    style.addRedefinitionWarning(ac, this);
	((Css3Style) style).cssColumnSpan = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnSpan();
	} else {
	    return ((Css3Style) style).cssColumnSpan;
	}
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
	return (property instanceof CssColumnSpan &&
		value.equals( ((CssColumnSpan) property).value));
    }

    /**
     * Returns the name of this property
     */
    public String getPropertyName() {
	return "column-span";
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
	return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
	return (value == inherit);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
	return value.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() {
	// we only have 3 values
	return ((value != all) && (value != inherit));
    }

}

--- NEW FILE: CssColumnRuleWidth.java ---
//
// $Id: CssColumnRuleWidth.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
//
// (c) COPYRIGHT 1995-2000  World Wide Web Consortium (MIT, INRIA, Keio University)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css1.CssBorderFaceWidthCSS2;
import org.w3c.css.properties.css3.Css3Style;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * http://www.w3.org/TR/css3-multicol/
 *  <P>
 *  <EM>Value:</EM> &lt;border-width&gt;<BR>
 *  <EM>Initial:</EM>medium<BR>
 *  <EM>Applies to:</EM>multicol elements<BR>
 *  <EM>Inherited:</EM>no<BR>
 *  <EM>Percentages:</EM>N/A<BR>
 *  <EM>Media:</EM>:visual
 */

public class CssColumnRuleWidth extends CssProperty {

    CssBorderFaceWidthCSS2 value;

    /**
     * Create a new CssColumnRuleWidth
     */
    public CssColumnRuleWidth() {
	// nothing to do
    }

    /**
     * Create a new CssColumnRuleWidth
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Incorrect value
     */
    public CssColumnRuleWidth(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {

	setByUser();
	CssValue val = expression.getValue();

	if (check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}

	try {
	    value = new CssBorderFaceWidthCSS2(ac, expression);
	} catch (InvalidParamException e) {
	    throw new InvalidParamException("value",
					    expression.getValue(),
					    getPropertyName(), ac);
	}
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
	if (((Css3Style) style).cssColumnRuleWidth != null)
	    style.addRedefinitionWarning(ac, this);
	((Css3Style) style).cssColumnRuleWidth = this;
    }

    /**
     * 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 ((Css3Style) style).getColumnRuleWidth();
	}
	else {
	    return ((Css3Style) style).cssColumnRuleWidth;
	}
    }

    /**
     * Compares two properties for equality.
     *
     * @param value The other property.
     */
    public boolean equals(CssProperty property) {
	return (property instanceof CssColumnRuleWidth &&
		value.equals(((CssColumnRuleWidth) property).value));
    }

    /**
     * Returns the name of this property
     */
    public String getPropertyName() {
	return "column-rule-width";
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
	return value.getValue();
    }

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

    /**
     * Returns a string representation of the object
     */
    public String toString() {
	return value.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 false;
    }

}

--- NEW FILE: CssBreakAfter.java ---
// $Id: CssBreakAfter.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 by Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010  World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.HashMap;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks
 * <p/>
 * When content is laid out in multiple columns, the user agent must determine
 * where column breaks are placed. The problem of breaking content into columns
 * is similar to breaking content into pages.
 * <p/>
 * Three new properties are introduced to allow column breaks to be described
 * in the same properties as page breaks: ‘break-before’, ‘break-after’, and
 * ‘break-inside’. These properties take the same values as
 * ‘page-break-before’, ‘page-break-after’, and ‘page-break-inside’ [CSS21].
 * In addition, some new keyword values are added.
 * <p/>
 * Name:  	break-after
 * Value: 	auto | always | avoid | left | right | page | column |
 * avoid-page | avoid-column
 * Initial: 	auto
 * Applies to: 	block-level elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	paged
 * Computed value: 	specified value
 */

public class CssBreakAfter extends CssProperty {

    private static final String propertyName = "break-after";

    static CssIdent auto;
    static HashMap<String, CssIdent> allowed_values;

    CssIdent value;

    static {
        allowed_values = new HashMap<String, CssIdent>();
        auto = CssIdent.getIdent("auto");
        String id_values[] = {"auto", "always", "avoid", "left", "right",
                "page", "column", "avoid-page", "avoid-column"};
        for (String s : id_values) {
            allowed_values.put(s, CssIdent.getIdent(s));
        }
    }

    /**
     * Create a new CssColumnWidth
     */
    public CssBreakAfter() {
        value = auto;
    }

    /**
     * Create a new CssBreakAfter
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssBreakAfter(ApplContext ac, CssExpression expression,
                         boolean check) throws InvalidParamException {

        setByUser();
        CssValue val = expression.getValue();

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        if (val.getType() != CssTypes.CSS_IDENT) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        // ident, so inherit, or allowed value
        if (inherit.equals(val)) {
            value = inherit;
        } else {
            val = allowed_values.get(val.toString());
            if (val == null) {
                throw new InvalidParamException("value",
                        expression.getValue(),
                        getPropertyName(), ac);
            }
            value = (CssIdent) val;
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssBreakAfter != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBreakAfter = this;
    }

    /**
     * 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 ((Css3Style) style).getBreakAfter();
        } else {
            return ((Css3Style) style).cssBreakAfter;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBreakAfter &&
                value.equals(((CssBreakAfter) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return value.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 (auto == value);
    }

}

--- NEW FILE: CssBreakInside.java ---
// $Id: CssBreakInside.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 1995-2010 World Wide Web Consortium (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.HashMap;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-breaks
 * <p/>
 * When content is laid out in multiple columns, the user agent must determine
 * where column breaks are placed. The problem of breaking content into columns
 * is similar to breaking content into pages.
 * <p/>
 * Three new properties are introduced to allow column breaks to be described
 * in the same properties as page breaks: ‘break-before’, ‘break-after’, and
 * ‘break-inside’. These properties take the same values as
 * ‘page-break-before’, ‘page-break-after’, and ‘page-break-inside’ [CSS21].
 * In addition, some new keyword values are added.
 * <p/>
 * Name:  	break-inside
 * Value: 	auto | avoid | avoid-page | avoid-column
 * Initial: 	auto
 * Applies to: 	block-level elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	paged
 * Computed value: 	specified value
 */

public class CssBreakInside extends CssProperty {

    private static final String propertyName = "break-inside";

    static CssIdent auto;
    static HashMap<String, CssIdent> allowed_values;

    CssIdent value;

    static {
        allowed_values = new HashMap<String, CssIdent>();
        auto = CssIdent.getIdent("auto");
        String id_values[] = {"auto", "always", "avoid", "left", "right",
                "page", "column", "avoid-page", "avoid-column"};
        for (String s : id_values) {
            allowed_values.put(s, CssIdent.getIdent(s));
        }
    }

    /**
     * Create a new CssColumnWidth
     */
    public CssBreakInside() {
        value = auto;
    }

    /**
     * Create a new CssBreakInside
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssBreakInside(ApplContext ac, CssExpression expression,
                          boolean check) throws InvalidParamException {
        setByUser();
        CssValue val = expression.getValue();

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        if (val.getType() != CssTypes.CSS_IDENT) {
            throw new InvalidParamException("value",
                    expression.getValue(),
                    getPropertyName(), ac);
        }
        // ident, so inherit, or allowed value
        if (inherit.equals(val)) {
            value = inherit;
        } else {
            val = allowed_values.get(val.toString());
            if (val == null) {
                throw new InvalidParamException("value",
                        expression.getValue(),
                        getPropertyName(), ac);
            }
            value = (CssIdent)val;
        }
        expression.next();
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssBreakInside != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBreakInside = this;
    }

    /**
     * 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 ((Css3Style) style).getBreakInside();
        } else {
            return ((Css3Style) style).cssBreakInside;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBreakInside &&
                value.equals(((CssBreakInside) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        return value.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 (auto == value);
    }

}

--- NEW FILE: CssDisplay.java ---
// $Id: CssDisplay.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
// Updated September 14th 2000 Sijtsche de Jong (sy.de.jong@let.rug.nl)
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.HashMap;

/**
 * The 'display' property
 * using CSS21 values for now
 */
public class CssDisplay extends CssProperty {

    private static final String propertyName = "display";

    public CssIdent value;
    public static CssIdent inline;
    public static HashMap<String, CssIdent> allowed_values;

    static {
        allowed_values = new HashMap<String, CssIdent>();

        String[] DISPLAY = {
                "inline", "block", "list-item", "run-in", "inline-block",
                "table", "inline-table", "table-row-group",
                "table-header-group", "table-footer-group",
                "table-row", "table-column-group", "table-column",
                "table-cell", "table-caption", "none"};

        for (String aDISPLAY : DISPLAY) {
            allowed_values.put(aDISPLAY, CssIdent.getIdent(aDISPLAY));
        }
        inline = CssIdent.getIdent("inline");
    }

    /**
     * Create a new CssDisplay
     */
    public CssDisplay() {
        // nothing to do
    }

    /**
     * Create a new CssDisplay
     *
     * @param ac         The context
     * @param expression The expression for this property
     * @param check      true if explicit check is needed
     * @throws InvalidParamException Values are incorect
     */
    public CssDisplay(ApplContext ac, CssExpression expression,
                      boolean check) throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        CssValue val = expression.getValue();

        setByUser();

        if (val.getType() == CssTypes.CSS_IDENT) {
            CssIdent id_val = (CssIdent) val;
            String id_value = id_val.toString();
            if (inherit.equals(id_val)) {
                value = inherit;
            } else {
                value = allowed_values.get(id_value);
            }
            if (value != null) {
                expression.next();
                return;
            }
        }

        throw new InvalidParamException("value", expression.getValue(),
                getPropertyName(), ac);
    }

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

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        Css1Style style0 = (Css1Style) style;
        if (style0.cssDisplay != null)
            style0.addRedefinitionWarning(ac, this);
        style0.cssDisplay = this;
    }

    /**
     * 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).getDisplay();
        } else {
            return ((Css1Style) style).cssDisplay;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssDisplay &&
                value == ((CssDisplay) property).value);
    }

    /**
     * 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 == inline);
    }

}

--- NEW FILE: CssColumnGap.java ---
// $Id: CssColumnGap.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
// Rewritten 2010 Yves Lafon <ylafon@w3.org>
//
// COPYRIGHT (c) 1995-2010 World Wide Web Consortium, (MIT, ERCIM and Keio)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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;

/**
 * http://www.w3.org/TR/2009/CR-css3-multicol-20091217/#column-gap
 * <p/>
 * Name:  	column-gap
 * Value: 	&lt;length&gt; | normal
 * Initial: 	normal
 * Applies to: 	multicol elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	absolute length or ‘normal’
 * <p/>
 * The ‘column-gap’ property sets the gap between columns. If there is a
 * column rule between columns, it will appear in the middle of the gap.
 * <p/>
 * The ‘normal’ value is UA-specific. A value of ‘1em’ is suggested.
 * <p/>
 * Column gaps cannot be negative.
 */

public class CssColumnGap extends CssProperty {

    private static final String propertyName = "column-gap";

    CssValue columngap;

    static CssIdent normal;

    static {
        normal = CssIdent.getIdent("normal");
    }

    /**
     * Create a new CssColumnGap
     */
    public CssColumnGap() {
        columngap = normal;
    }

    /**
     * Create a new CssColumnGap
     */
    public CssColumnGap(ApplContext ac, CssExpression expression,
                        boolean check) throws InvalidParamException {
        setByUser();
        CssValue val = expression.getValue();
        Float value;

        switch (val.getType()) {
            case CssTypes.CSS_NUMBER:
                val = ((CssNumber) val).getLength();
            case CssTypes.CSS_LENGTH:
                value = (Float) ((CssLength) val).get();
                if (value == null || value.floatValue() < 0.0) {
                    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);
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssColumnGap != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssColumnGap = this;

    }

    /**
     * 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 ((Css3Style) style).getColumnGap();
        } else {
            return ((Css3Style) style).cssColumnGap;
        }
    }

    /**
     * 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 name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * 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 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 == normal);
    }

}

--- NEW FILE: CssBackgroundOrigin.java ---
//
// $Id: CssBackgroundOrigin.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 2010  World Wide Web Consortium (MIT, ERCIM, Keio University)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.COMMA;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-origin
 *
 * Name: 	background-origin
 * Value: 	&lt;bg-origin&gt; [ , &lt;bg-origin&gt; ]*
 * Initial: 	padding-box
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	same as specified value
 *
 * For elements rendered as a single box, specifies the background positioning
 * area. For elements rendered as multiple boxes (e.g., inline boxes on several
 * lines, boxes on several pages) specifies which boxes Ôbox-decoration-breakÕ
 *  operates on to determine the background positioning area(s).
 *
 * &lt;bg-origin&gt; = border-box | padding-box | content-box
 */

public class CssBackgroundOrigin extends CssProperty {

    private static final String propertyName = "background-origin";
    public static CssIdent border_box;
    public static CssIdent padding_box;
    public static CssIdent content_box;

    Object value;

    static {
        border_box  = CssIdent.getIdent("border-box");
        padding_box = CssIdent.getIdent("padding-box");
        content_box = CssIdent.getIdent("content-box");
    }

    /**
     * Create a new CssBackgroundClip
     */
    public CssBackgroundOrigin() {
        value = padding_box;
    }

    /**
     * Create a new CssBackgroundClip
     *
     * @param expression The expression for this property
     * @throws org.w3c.css.util.InvalidParamException Incorrect value
     */
    public CssBackgroundOrigin(ApplContext ac, CssExpression expression,
                             boolean check) throws InvalidParamException {

        ArrayList<CssValue> values = new ArrayList<CssValue>();

        CssValue val = expression.getValue();
        char op;

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            switch (val.getType()) {
                case CssTypes.CSS_IDENT:
                    if (inherit.equals(val)) {
                        // if we got inherit after other values, fail
                        // if we got more than one value... fail
                        if ((values.size() > 0)||(expression.getCount() > 1)) {
                            throw new InvalidParamException("value", val,
                                    getPropertyName(), ac);
                        }
                        values.add(inherit);
                        break;
                    } else if (border_box.equals(val)) {
                        values.add(border_box);
                        break;
                    } else if (content_box.equals(val)) {
                        values.add(content_box);
                        break;
                    } else if (padding_box.equals(val)) {
                        values.add(padding_box);
                        break;
                    }
                default:
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
            }
            expression.next();
            if (!expression.end() && (op != COMMA)) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()), ac);
            }
        }
        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        // TODO FIXME -> in CssStyle
        if (((Css3Style) style).cssBackgroundOrigin != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBackgroundOrigin = this;
    }

    /**
     * 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 ((Css3Style) style).getCssBackgroundOrigin();
        } else {
            return ((Css3Style) style).cssBackgroundOrigin;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundOrigin &&
                value.equals(((CssBackgroundOrigin) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

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

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList values = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.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 (padding_box == value);
    }

}
--- NEW FILE: CssBackgroundClip.java ---
// $Id: CssBackgroundClip.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT 2010  World Wide Web Consortium (MIT, ERCIM, Keio University)
// Please first read the full copyright statement at
// http://www.w3.org/Consortium/Legal/copyright-software-19980720

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.COMMA;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-clip
 * Name: 	background-clip
 * Value: 	[border-box | padding-box ] [ , [border-box | padding-box ] ]*
 * Initial: 	border-box
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	same as specified value
 * <p/>
 * Determines the background painting area.
 */

public class CssBackgroundClip extends CssProperty {

    private static final String propertyName = "background-clip";
    public static CssIdent border_box;
    public static CssIdent padding_box;

    Object value;

    static {
        border_box = CssIdent.getIdent("border-box");
        padding_box = CssIdent.getIdent("padding-box");
    }

    /**
     * Create a new CssBackgroundClip
     */
    public CssBackgroundClip() {
        value = border_box;
    }

    /**
     * Create a new CssBackgroundClip
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Incorrect value
     */
    public CssBackgroundClip(ApplContext ac, CssExpression expression,
                             boolean check) throws InvalidParamException {

        ArrayList<CssValue> values = new ArrayList<CssValue>();

        CssValue val = expression.getValue();
        char op;

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            switch (val.getType()) {
                case CssTypes.CSS_IDENT:
                    if (inherit.equals(val)) {
                        // if we got inherit after other values, fail
                        // if we got more than one value... fail
                        if ((values.size() > 0)||(expression.getCount() > 1)) {
                            throw new InvalidParamException("value", val,
                                    getPropertyName(), ac);
                        }
                        values.add(inherit);
                        break;
                    } else if (border_box.equals(val)) {
                        values.add(border_box);
                        break;
                    } else if (padding_box.equals(val)) {
                        values.add(padding_box);
                        break;
                    }
                default:
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
            }
            expression.next();
            if (!expression.end() && (op != COMMA)) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()), ac);
            }
        }
        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }

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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        // TODO FIXME -> in CssStyle
        if (((Css3Style) style).cssBackgroundClip != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBackgroundClip = this;
    }

    /**
     * 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 ((Css3Style) style).getCssBackgroundClip();
        } else {
            return ((Css3Style) style).cssBackgroundClip;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundClip &&
                value.equals(((CssBackgroundClip) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

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

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList values = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.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 (border_box == value);
    }

}

--- NEW FILE: CssBackgroundAttachment.java ---
// $Id: CssBackgroundAttachment.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>

// (c) COPYRIGHT MIT, ERCIM and Keio, 2010.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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.CssTypes;
import org.w3c.css.values.CssValue;

import java.util.ArrayList;
import java.util.HashMap;

import static org.w3c.css.values.CssOperator.COMMA;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-attachment
 * Name: 	background-attachment
 * Value: 	&lt;attachment&gt; [ , &lt;attachment&gt; ]*
 * Initial: 	scroll
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	as specified
 *
 * If background images are specified, this property specifies whether they
 * are fixed with regard to the viewport (ÔfixedÕ) or scroll along with the
 * element (ÔscrollÕ) or its contents (ÔlocalÕ). The property's value is given
 *  as a comma-separated list of &lt;attachment&gt; keywords where
 *
 * &lt;attachment&gt; = scroll | fixed | local
 */
public class CssBackgroundAttachment extends CssProperty {

    private static final String propertyName = "background-attachment";

    public static HashMap<String, CssIdent> allowed_values;
    public static CssIdent scroll;

    static {
        allowed_values = new HashMap<String, CssIdent>();
        scroll = CssIdent.getIdent("scroll");
        allowed_values.put("scroll", scroll);
        allowed_values.put("fixed", CssIdent.getIdent("fixed"));
        allowed_values.put("local", CssIdent.getIdent("local"));
    }

    Object value;

    /**
     * Create a new CssBackgroundAttachment
     */
    public CssBackgroundAttachment() {
        value = scroll;
    }

    /**
     * Creates a new CssBackgroundAttachment
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check if some length checking is required
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundAttachment(ApplContext ac, CssExpression expression,
                                   boolean check) throws InvalidParamException {

        ArrayList<CssValue> values = new ArrayList<CssValue>();
        char op;
        CssValue val;

        setByUser();

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            if (val.getType() != CssTypes.CSS_IDENT) {
                throw new InvalidParamException("value", val,
                        getPropertyName(), ac);
            }
            if (inherit.equals(val)) {
                // if we got inherit after other values, fail
                // if we got more than one value... fail
                if ((values.size() > 0) || (expression.getCount() > 1)) {
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
                }
                values.add(inherit);
            } else {
                // check that it's in the allowed values
                CssValue new_val = allowed_values.get(val.toString());
                if (new_val == null) {
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
                }
                values.add(new_val);
            }
            expression.next();
            // and check that values are separated by commas
            if (!expression.end() && (op != COMMA)) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()), ac);
            }
        }

        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }

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

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList values = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.toString();
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.attachment != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.attachment = this;
    }

    /**
     * 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).getBackgroundAttachment();
        } else {
            return ((Css1Style) style).cssBackground.attachment;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundAttachment &&
                value.equals(((CssBackgroundAttachment) property).value));
    }

    /**
     * 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 (scroll == value);
    }
}

--- NEW FILE: CssZIndex.java ---
// $Id: CssZIndex.java,v 1.1 2010/01/05 13:49:38 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 1997-2010.
// Please first read the full copyright statement in file COPYRIGHT.html
/*
 */
package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;

/**
 */
public class CssZIndex extends CssProperty {

    private static final String propertyName = "z-index";

    CssValue value;

    private static CssIdent auto = CssIdent.getIdent("auto");

    /**
     * Create a new CssZIndex
     */
    public CssZIndex() {
        value = auto;
    }

    /**
     * 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 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);
        }

        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();
    }

    /**
     * Create a new CssZIndex
     *
     * @param ac, the Context
     * @param expression The expression for this property
     * @throws InvalidParamException The expression is incorrect
     */
    public CssZIndex(ApplContext ac, CssExpression expression)
            throws InvalidParamException {
        this(ac, expression, false);
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return value.toString();
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        Css1Style style0 = (Css1Style) style;
        if (style0.cssZIndex != null) {
            style0.addRedefinitionWarning(ac, this);
        }
        style0.cssZIndex = this;
    }

    /**
     * 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).getZIndex();
        } else {
            return ((Css1Style) style).cssZIndex;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     * @return boolean
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssZIndex &&
                value.equals(((CssZIndex) property).value));
    }

    /**
     * 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);
    }

}

--- NEW FILE: CssBackgroundConstants.java ---
//
// $Id: CssBackgroundConstants.java,v 1.1 2010/01/05 13:49:37 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.css;

/**
 * @version $Revision: 1.1 $
 */
public interface CssBackgroundConstants {
  static String[] REPEAT = { "repeat", "repeat-x", "repeat-y", "no-repeat", "inherit" };
    
  static String[] ATTACHMENT = { "scroll", "fixed", "inherit" };
  static String[] ATTACHMENTMOB = { "scroll", "inherit" };
    
  static String[] POSITION = { "top", "center", "bottom", "left", "right", "inherit" };

  /**
   * The top position
   */
  static int POSITION_TOP = 0;

  /**
   * The center position
   */
  static int POSITION_CENTER = 1;

  /**
   * The bottom position
   */
  static int POSITION_BOTTOM = 2;

  /**
   * The left position
   */
  static int POSITION_LEFT = 3;

  /**
   * The right position
   */
  static int POSITION_RIGHT = 4;

  /**
   * Inherit
   */
  static int POSITION_INHERIT = 5;
}

--- NEW FILE: CssBackgroundImage.java ---
// $Id: CssBackgroundImage.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio, 2010.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css1.Css1Style;
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;

import java.util.ArrayList;

import static org.w3c.css.values.CssOperator.COMMA;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-image
 *
 * Name: 	background-image
 * Value: 	&lt;bg-image&gt; [ , &lt;bg-image&gt; ]*
 * Initial: 	none
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	N/A
 * Media: 	visual
 * Computed value: 	as specified, but with URIs made absolute
 *
 * This property sets the background image(s) of an element. Images are drawn
 * with the first specified one on top (closest to the user) and each
 * subsequent image behind the previous one. Where
 *
 * &lt;bg-image&gt; = &lt;image&gt; | none
 */
public class CssBackgroundImage extends CssProperty {

    private static final String propertyName = "background-image";

    Object url = null;

    /**
     * Create a new CssBackgroundImage
     */
    public CssBackgroundImage() {
        url = none;
    }

    /**
     * Creates a new CssBackgroundImage
     *
     * @param ac the context
     * @param expression The expression for this property
     * @param check boolean
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundImage(ApplContext ac, CssExpression expression,
                              boolean check) throws InvalidParamException {

        ArrayList<CssValue> values = new ArrayList <CssValue>();
        setByUser();

        CssValue val;
        char op;

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            switch (val.getType()) {
                case CssTypes.CSS_URL:
                    values.add(val);
                    break;
                case CssTypes.CSS_IDENT:
                    if (inherit.equals(val)) {
                        // if we got inherit after other values, fail
                        // if we got more than one value... fail
                        if ((values.size()>0) || (expression.getCount()>1 )) {
                            throw new InvalidParamException("value", val,
                                    getPropertyName(), ac);
                        }
                        values.add(inherit);
                        break;
                    } else if (none.equals(val)) {
                        values.add(none);
                        break;
                    }
                default:
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);
            }
            expression.next();
            if (!expression.end() && (op != COMMA)) {
                throw new InvalidParamException("operator",
                        ((new Character(op)).toString()), ac);
            }
        }
        if (values.size() == 1) {
            url = values.get(0);
        } else {
            url = values;
        }
    }

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

    /**
     * Returns the value of this property
     */

    public Object get() {
        return url;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        if (url instanceof ArrayList) {
            ArrayList values = (ArrayList) url;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return url.toString();
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.image != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.image = this;
    }

    /**
     * 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).getBackgroundImage();
        } else {
            return ((Css1Style) style).cssBackground.image;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundImage && url != null &&
                url.equals(((CssBackgroundImage) property).url));
    }

    /**
     * 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 (url == none);
    }

}

--- NEW FILE: CssBackgroundSize.java ---
// $Id: CssBackgroundSize.java,v 1.1 2010/01/05 13:49:37 ylafon Exp $
// @author Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2010.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css3.Css3Style;
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.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import org.w3c.css.values.CssValueList;

import java.util.ArrayList;
import java.util.HashMap;

import static org.w3c.css.values.CssOperator.COMMA;
import static org.w3c.css.values.CssOperator.SPACE;

/**
 * http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-size
 *
 * <p/>
 * Name: 	background-size
 * Value: 	&lt;bg-size&gt; [ , &lt;bg-size&gt; ]*
 * Initial: 	auto
 * Applies to: 	all elements
 * Inherited: 	no
 * Percentages: 	see text
 * Media: 	visual
 * Computed value: 	for &lt;length&gt; the absolute value, otherwise as
 * specified
 * <p/>
 * Specifies the size of the background images. Where
 * <p/>
 * &lt;bg-size&gt; = [ &lt;length&gt; | &lt;percentage&gt; | auto ]{1,2} |
 * cover | contain
 */
public class CssBackgroundSize extends CssProperty {

    private static final String propertyName = "background-size";

    public static CssIdent auto;
    public static HashMap<String, CssIdent> allowed_values;

    static {
        auto = CssIdent.getIdent("auto");
        allowed_values = new HashMap<String, CssIdent>();
        allowed_values.put("auto", auto);
        allowed_values.put("cover", CssIdent.getIdent("cover"));
        allowed_values.put("contain", CssIdent.getIdent("contain"));
    }

    Object value;

    /**
     * Create a new CssBackgroundSize
     */
    public CssBackgroundSize() {
        value = auto;
    }

    /**
     * Create a new CssBackgroundSize
     *
     * @param ac         The context
     * @param expression The expression for this property
     * @param check      if arguments count must be checked.
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundSize(ApplContext ac, CssExpression expression,
                             boolean check) throws InvalidParamException {
        ArrayList<CssValue> values = new ArrayList<CssValue>();
        char op;
        CssValue val;
        CssValueList vl = null;
        boolean is_complete = true;

        setByUser();

        while (!expression.end()) {
            val = expression.getValue();
            op = expression.getOperator();
            switch (val.getType()) {
                case CssTypes.CSS_NUMBER:
                    val = ((CssNumber) val).getLength();
                case CssTypes.CSS_LENGTH:
                case CssTypes.CSS_PERCENTAGE:
                    // per spec only non-negative values are allowed
                    float f = ((Float) val.get()).floatValue();
                    if (f < 0) {
                        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_IDENT:
                    if (inherit.equals(val)) {
                        // if we got inherit after other values, fail
                        // if we got more than one value... fail
                        if ((values.size() > 0) || (expression.getCount() > 1)) {
                            throw new InvalidParamException("value", val,
                                    getPropertyName(), ac);
                        }
                        values.add(inherit);
                        break;
                    } else if (auto.equals(val)) {
                        if (is_complete) {
                            vl = new CssValueList();
                            vl.add(auto);
                        } else {
                            vl.add(auto);
                            values.add(vl);
                        }
                        is_complete = !is_complete;
                        break;
                    } else {
                        CssValue v = allowed_values.get(val.toString());
                        // if ok, and if we are not in a middle of a compound
                        // value...
                        if (v != null && is_complete) {
                            values.add(v);
                            break;
                        }
                    }
                default:
                    throw new InvalidParamException("value", val,
                            getPropertyName(), ac);

            }
            expression.next();
            if (!expression.end()) {
                // incomplete value followed by a comma... it's complete!
                if (!is_complete && (op == COMMA)) {
                    values.add(vl);
                    is_complete = true;
                }
                // complete values are separated by a comma, otherwise space
                if ((is_complete && (op != COMMA)) ||
                        (!is_complete && (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 (!is_complete) {
            values.add(vl);
        }
        if (values.size() == 1) {
            value = values.get(0);
        } else {
            value = values;
        }
    }


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

    /**
     * Add this property to the CssStyle
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        if (((Css3Style) style).cssBackgroundSize != null)
            style.addRedefinitionWarning(ac, this);
        ((Css3Style) style).cssBackgroundSize = this;
    }

    /**
     * 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 ((Css3Style) style).getCssBackgroundSize();
        } else {
            return ((Css3Style) style).cssBackgroundSize;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundSize &&
                value.equals(((CssBackgroundSize) property).value));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * Returns the value of this property
     */
    public Object get() {
        return value;
    }

    /**
     * Returns true if this property is "softly" inherited
     */
    public boolean isSoftlyInherited() {
        return (inherit == value);
    }

    /**
     * Returns a string representation of the object
     */
    public String toString() {
        if (value instanceof ArrayList) {
            ArrayList values = (ArrayList) value;
            StringBuilder sb = new StringBuilder();
            for (Object aValue : values) {
                sb.append(aValue.toString()).append(", ");
            }
            sb.setLength(sb.length() - 2);
            return sb.toString();
        }
        return value.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 (auto == value);
    }

}

--- NEW FILE: CssBackgroundColor.java ---
//
// $Id: CssBackgroundColor.java,v 1.1 2010/01/05 13:49:37 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.css;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css1.Css1Style;
import org.w3c.css.properties.css1.CssColor;
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.CssValue;

/**
 * <H4>
 * &nbsp;&nbsp; 'background-color'
 * </H4>
 * <p/>
 * <EM>Value:</EM> &lt;color&gt; | transparent<BR>
 * <EM>Initial:</EM> transparent<BR>
 * <EM>Applies to:</EM> all elements<BR>
 * <EM>Inherited:</EM> no<BR>
 * <EM>Percentage values:</EM> N/A<BR>
 * <p/>
 * This property sets the background color of an element.
 * <PRE>
 * H1 { background-color: #F00 }
 * </PRE>
 *
 * @version $Revision: 1.1 $
 */
public class CssBackgroundColor extends CssProperty {

    CssValue color;

    private static final String propertyName = "background-color";

    /**
     * Create a new CssBackgroundColor
     */
    public CssBackgroundColor() {
        color = transparent;
    }

    /**
     * Create a new CssBackgroundColor
     *
     * @param expression The expression for this property
     * @throws InvalidParamException Values are incorrect
     */
    public CssBackgroundColor(ApplContext ac, CssExpression expression,
                              boolean check) throws InvalidParamException {

        if (check && expression.getCount() > 1) {
            throw new InvalidParamException("unrecognize", ac);
        }

        setByUser();
        CssColor tempcolor = new CssColor(ac, expression, check);
        color = (CssValue) tempcolor.get();
    }

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

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

    /**
     * Returns the color
     */
    public CssValue getColor() {
        return color;
    }

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

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
        return color.toString();
    }


    /**
     * Add this property to the CssStyle.
     *
     * @param style The CssStyle
     */
    public void addToStyle(ApplContext ac, CssStyle style) {
        CssBackground cssBackground = ((Css1Style) style).cssBackground;
        if (cssBackground.color != null)
            style.addRedefinitionWarning(ac, this);
        cssBackground.color = this;
    }

    /**
     * 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).getBackgroundColor();
        } else {
            return ((Css1Style) style).cssBackground.color;
        }
    }

    /**
     * Compares two properties for equality.
     *
     * @param property The other property.
     */
    public boolean equals(CssProperty property) {
        return (property instanceof CssBackgroundColor &&
                color.equals(((CssBackgroundColor) property).color));
    }

    /**
     * Returns the name of this property
     */
    public final String getPropertyName() {
        return propertyName;
    }

    /**
     * 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 color == transparent;
    }

}

Received on Tuesday, 5 January 2010 13:49:44 UTC