2002/css-validator/org/w3c/css/properties/css21 Css21Style.java,NONE,1.1 CssBackgroundCSS21.java,NONE,1.1 CssBackgroundColorCSS21.java,NONE,1.1 CssBackgroundPositionCSS21.java,NONE,1.1 CssBorderBottomCSS21.java,NONE,1.1 CssBorderBottomColorCSS21.java,NONE,1.1 CssBorderCSS21.java,NONE,1.1 CssBorderColorCSS21.java,NONE,1.1 CssBorderFaceColorCSS21.java,NONE,1.1 CssBorderLeftCSS21.java,NONE,1.1 CssBorderLeftColorCSS21.java,NONE,1.1 CssBorderRightCSS21.java,NONE,1.1 CssBorderRightColorCSS21.java,NONE,1.1 CssBorderTopCSS21.java,NONE,1.1 CssBorderTopColorCSS21.java,NONE,1.1 CssColorCSS21.java,NONE,1.1 CssContentCSS21.java,NONE,1.1 CssCursorCSS21.java,NONE,1.1 CssDisplayCSS21.java,NONE,1.1 CssListStyleCSS21.java,NONE,1.1 CssListStyleTypeCSS21.java,NONE,1.1 CssTextAlignCSS21.java,NONE,1.1 CssWhiteSpaceCSS21.java,NONE,1.1

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

Added Files:
	Css21Style.java CssBackgroundCSS21.java 
	CssBackgroundColorCSS21.java CssBackgroundPositionCSS21.java 
	CssBorderBottomCSS21.java CssBorderBottomColorCSS21.java 
	CssBorderCSS21.java CssBorderColorCSS21.java 
	CssBorderFaceColorCSS21.java CssBorderLeftCSS21.java 
	CssBorderLeftColorCSS21.java CssBorderRightCSS21.java 
	CssBorderRightColorCSS21.java CssBorderTopCSS21.java 
	CssBorderTopColorCSS21.java CssColorCSS21.java 
	CssContentCSS21.java CssCursorCSS21.java CssDisplayCSS21.java 
	CssListStyleCSS21.java CssListStyleTypeCSS21.java 
	CssTextAlignCSS21.java CssWhiteSpaceCSS21.java 
Log Message:
>From Jean-Guilhem Rouel:
CSS 2.1 first implementation




--- NEW FILE: CssBorderFaceColorCSS21.java ---
// $Id: CssBorderFaceColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
import org.w3c.css.properties.css1.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssValue;

/**
 * CssBorderFaceColorCSS21<br />
 * Created: Aug 31, 2005 3:29:22 PM<br />
 */
public class CssBorderFaceColorCSS21 extends CssBorderFaceColorCSS2 {
    
    /**
     * Create a new CssBorderFaceColor
     */
    public CssBorderFaceColorCSS21() {
	super();
    }

    /**
     * Create a new CssBorderFaceColor with a color property.
     *
     * @param color A color property
     */
    public CssBorderFaceColorCSS21(org.w3c.css.properties.css1.CssColorCSS2 color) {
	super(color);
    }

    /**
     * Create a new CssBorderFaceColor with an another CssBorderFaceColor
     *
     * @param another An another face.
     */
    public CssBorderFaceColorCSS21(CssBorderFaceColorCSS2 another) {
	super(another);
    }

    /**
     * Create a new CssBorderFaceColor with an expression
     *
     * @param expression The expression for this property.
     * @exception InvalidParamException color is not a color
     */
    public CssBorderFaceColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}

	CssValue val = expression.getValue();

	if (val instanceof org.w3c.css.values.CssColor) {
	    setFace(val);
	} else if (val.equals(CssProperty.inherit)) {
	    setFace(CssProperty.inherit);
	} else if(val.equals(CssProperty.transparent)) {	    
	    setFace(CssProperty.transparent);  
	} else if (val instanceof CssIdent) {
	    setFace(new org.w3c.css.values.CssColorCSS21(ac, (String) val.get()));
	} else {
	    throw new InvalidParamException("value", val.toString(),
					    "border-color", ac);
	}
	expression.next();
    }

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

--- NEW FILE: CssBorderLeftCSS21.java ---
// $Id: CssBorderLeftCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderLeftCSS2;
import org.w3c.css.properties.css1.CssBorderLeftStyleCSS2;
import org.w3c.css.properties.css1.CssBorderLeftWidthCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBorderLeftCSS21<br />
 * Created: Aug 31, 2005 2:08:48 PM<br />
 */
public class CssBorderLeftCSS21 extends CssBorderLeftCSS2 {
    
    /**
     * Create a new CssBorderLeftCSS21
     */
    public CssBorderLeftCSS21() {
	super();
    }  
    
    /**
     * Create a new CssBorderLeftCSS21
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssBorderLeftCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	CssValue val = null;
	char op = SPACE;
	boolean find = true;
	
	if(check && expression.getCount() > 3) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	boolean manyValues = (expression.getCount() > 1);
	
	setByUser();
	
	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.equals(inherit)) {
		throw new InvalidParamException("unrecognize", null, null, ac);
	    }
	    
	    if (op != SPACE)
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);   
	    if (getWidth() == null) {
		try {
		    setWidth(new CssBorderLeftWidthCSS2(ac, expression));		
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, style will test this value		    
		}
	    }
	    if (!find && getStyle() == null) {
		try {
		    setStyle(new CssBorderLeftStyleCSS2(ac, expression));		    
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, color will test this value
		}
	    }
	    if (!find && getColor() == null) {
		// throws an exception if the value is not valid
		setColor(new CssBorderLeftColorCSS21(ac, expression));
		find = true;		
	    }
	}
    }
    
    public CssBorderLeftCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression,false);
    }
    
}

--- NEW FILE: CssTextAlignCSS21.java ---
// $Id: CssTextAlignCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssTextAlign;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssString;

/**
 * CssTextAlignCSS21<br />
 * Created: Aug 31, 2005 11:39:33 AM<br />
 */
public class CssTextAlignCSS21 extends CssTextAlign {
    /**
     * Create a new CssTextAlignCSS21
     */
    public CssTextAlignCSS21() {
	// depends on user agent and writing direction
    }  
    
    /**
     * Create a new CssTextAlign
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssTextAlignCSS21(ApplContext ac, CssExpression expression, boolean check)
    	throws InvalidParamException {
	
	super(ac, expression, check);
	
	Object val = get();
	
	if(val instanceof CssString) {
	    throw new InvalidParamException("value", val.toString(), 
		    getPropertyName(), ac);
	}	
    }
    
    public CssTextAlignCSS21(ApplContext ac, CssExpression expression) 
	throws InvalidParamException {
	this(ac, expression, false);
    }
}

--- NEW FILE: CssContentCSS21.java ---
// $Id: CssContentCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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

/**
 * CssContentCSS21<br />
 * Created: Aug 30, 2005 4:18:11 PM<br />
 */
public class CssContentCSS21 extends CssContentCSS2{

    static final CssIdent normal = new CssIdent("normal");
    static final CssIdent none = new CssIdent("none");
    
    /**
     * Create a new CssContent
     */
    public CssContentCSS21() {
    }  
    
    /**
     * Create a new CssContent
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssContentCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	CssValue val = expression.getValue();

	setByUser();
	
	if (val.equals(inherit)) {
	    if(expression.getCount() > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    getValues().addElement(inherit);
	    expression.next();
	    return;
	}
	if (val.equals(normal)) {
	    if(expression.getCount() > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    getValues().addElement(normal);
	    expression.next();
	    return;
	}
	if (val.equals(none)) {
	    if(expression.getCount() > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    getValues().addElement(none);
	    expression.next();
	    return;
	}
	
	addContent(ac, expression);
	
    }
    
    public CssContentCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression, false);
    }
}

--- NEW FILE: Css21Style.java ---
// $Id: Css21Style.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html

package org.w3c.css.properties.css21;

import org.w3c.css.properties.css2.font.Css2Style;
import org.w3c.css.parser.CssPrinterStyle;

/**
 * Css21Style<br />
 * Created: Aug 30, 2005 2:25:17 PM<br />
 */
public class Css21Style extends Css2Style {
    
    public void print(CssPrinterStyle printer) {
	super.print(printer);
    }
    
}

--- NEW FILE: CssColorCSS21.java ---
// $Id: CssColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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

/**
 * CssColorCSS21<br />
 * Created: Aug 30, 2005 2:33:04 PM<br />
 */
public class CssColorCSS21 extends CssColorCSS2 {

    /**
     * Set the value of the property
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */
    public CssColorCSS21(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.equals(inherit)) {
	    setColor(inherit);
	    expression.next();
	} else if (val instanceof org.w3c.css.values.CssColor) {	    
	    setColor(val);
	    expression.next();
	} else if (val instanceof CssIdent) {	    
	    setColor(new org.w3c.css.values.CssColorCSS21(ac,
							(String) val.get()));
	    expression.next();
	} else {
	    throw new InvalidParamException("value", expression.getValue(),
					    getPropertyName(), ac);
	}
    }

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

--- NEW FILE: CssDisplayCSS21.java ---
// $Id: CssDisplayCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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

/**
 * CssDisplayCSS21<br />
 * Created: Aug 30, 2005 3:54:43 PM<br />
 */
public class CssDisplayCSS21 extends CssDisplayCSS2 {

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

    private static int[] hash_values;
    
    static {
	hash_values = new int[DISPLAY.length];
	for (int i = 0; i < DISPLAY.length; i++)
	    hash_values[i] = DISPLAY[i].hashCode();
    }
    
    /**
     * Create a new CssDisplay
     */
    public CssDisplayCSS21() {
	// nothing to do
    }  
    
    /**
     * Create a new CssDisplay
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorect
     */  
    public CssDisplayCSS21(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 instanceof CssIdent) {
	    int hash = val.hashCode();
	    for (int i = 0; i < DISPLAY.length; i++) {
		if (hash_values[i] == hash) {
		    setValue(i);		    
		    expression.next();
		    return;
		}
	    }
	}
	
	throw new InvalidParamException("value", expression.getValue(), 
					getPropertyName(), ac);
    }
    
    public CssDisplayCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression, false);
    }
    
    /**
     * Returns a string representation of the object.
     */
    public String toString() {
	return DISPLAY[getValue()];
    }
    
    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
	return getValue() == DISPLAY.length - 1;
    }
    
    /**
     * Returns the value of this property
     */
    public Object get() {
	return DISPLAY[getValue()];
    }
}

--- NEW FILE: CssBorderLeftColorCSS21.java ---
// $Id: CssBorderLeftColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
import org.w3c.css.properties.css1.CssBorderLeftColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssBorderLeftColorCSS21<br />
 * Created: Aug 31, 2005 2:10:19 PM<br />
 */
public class CssBorderLeftColorCSS21 extends CssBorderLeftColorCSS2 {
    
    /**
     * Create a new CssBorderLeftColorCSS21 with an another CssBorderFaceColorCSS2
     *
     * @param another An another face.
     */
    public CssBorderLeftColorCSS21(CssBorderFaceColorCSS2 another) {
	super(another);
    }
    
    /**
     * Create a new CssBorderLeftColor
     *
     * @param expression The expression for this property.
     * @exception InvalidParamException Values are incorrect
     */
    public CssBorderLeftColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();
	setFace(new CssBorderFaceColorCSS21(ac, expression));
    }
    
    public CssBorderLeftColorCSS21(ApplContext ac, CssExpression expression) 
    throws InvalidParamException {
	this(ac, expression, false);
    }	
}

--- NEW FILE: CssBorderRightColorCSS21.java ---
// $Id: CssBorderRightColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
import org.w3c.css.properties.css1.CssBorderRightColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssBorderRightColorCSS21<br />
 * Created: Aug 31, 2005 2:09:31 PM<br />
 */
public class CssBorderRightColorCSS21 extends CssBorderRightColorCSS2 {
    
    /**
     * Create a new CssBorderRightColorCSS21 with an another CssBorderFaceColorCSS2
     *
     * @param another An another face.
     */
    public CssBorderRightColorCSS21(CssBorderFaceColorCSS2 another) {
	super(another);
    }
    
    /**
     * Create a new CssBorderRightColor
     *
     * @param expression The expression for this property.
     * @exception InvalidParamException Values are incorrect
     */
    public CssBorderRightColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();
	setFace(new CssBorderFaceColorCSS21(ac, expression));
    }
    
    public CssBorderRightColorCSS21(ApplContext ac, CssExpression expression) 
    throws InvalidParamException {
	this(ac, expression, false);
    }	
}

--- NEW FILE: CssListStyleTypeCSS21.java ---
// $Id: CssListStyleTypeCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssListStyleTypeCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssListStyleTypeCSS21<br />
 * Created: Aug 31, 2005 10:54:09 AM<br />
 */
public class CssListStyleTypeCSS21 extends CssListStyleTypeCSS2 {
    
    
    
    /**
     * Create a new CssListStyleTypeCSS21
     */
    public CssListStyleTypeCSS21() {
	// nothing to do
    }  
    
    /**
     * Create a new CssListStyleTypeCSS21
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssListStyleTypeCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	super(ac, expression, check);
	
	// fast but ugly
	if(getValue() == 12 || getValue() == 15 || getValue() == 16 ||
		getValue() == 17 || getValue() == 18 || getValue() == 19) {	    
	    throw new InvalidParamException("value", get().toString(),
		    getPropertyName(), ac);
	}
    }
    
    public CssListStyleTypeCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression, false);
    }

}

--- NEW FILE: CssBackgroundCSS21.java ---
// $Id: CssBackgroundCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBackgroundAttachmentCSS2;
import org.w3c.css.properties.css1.CssBackgroundCSS2;
import org.w3c.css.properties.css1.CssBackgroundImageCSS2;
import org.w3c.css.properties.css1.CssBackgroundRepeatCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBackgroundCSS21<br />
 * Created: Aug 31, 2005 2:03:41 PM<br />
 */
public class CssBackgroundCSS21 extends CssBackgroundCSS2 {
    /**
     * Create a new CssBackgroundCSS2
     */
    public CssBackgroundCSS21() {
	super();
    }  
    
    /**
     * Set the value of the property
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssBackgroundCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {			

	CssValue val = expression.getValue();
	char op = SPACE;
	boolean find = true;
	
	// too many values
	if(check && expression.getCount() > 6) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();

	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 (getColor2() == null) {
		try {
		    setColor(new CssBackgroundColorCSS21(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		    // nothing to do, image will test this value
		}
	    }
	    if (!find && getImage() == null) {
		try {
		    setImage(new CssBackgroundImageCSS2(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		    // nothing to do, repeat will test this value
		}
	    }
	    if (!find && getRepeat() == null) {
		try {		    
		    setRepeat(new CssBackgroundRepeatCSS2(ac, expression));		    
		    find = true;
		} catch (InvalidParamException e) {		    
		    // nothing to do, attachment will test this value
		}
	    }
	    if (!find && getAttachment() == null) {
		try {
		    setAttachment(new CssBackgroundAttachmentCSS2(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		    // nothing to do, position will test this value
		}
	    }
	    if (!find && getPosition() == null) {
		try {
		    setPosition(new CssBackgroundPositionCSS21(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		    // nothing to do
		}
	    }
	    if(check && val != null && !find) {		
		throw new InvalidParamException("unrecognize", ac);
	    }
	    if (op != SPACE) {
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);
	    }
	    if(check && !find && val != null) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	}

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

--- NEW FILE: CssBorderBottomCSS21.java ---
// $Id: CssBorderBottomCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderBottomCSS2;
import org.w3c.css.properties.css1.CssBorderBottomStyleCSS2;
import org.w3c.css.properties.css1.CssBorderBottomWidthCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBorderBottomCSS21<br />
 * Created: Aug 31, 2005 2:07:13 PM<br />
 */
public class CssBorderBottomCSS21 extends CssBorderBottomCSS2 {
    
    /**
     * Create a new CssBorderBottomCSS21
     */
    public CssBorderBottomCSS21() {
	super();
    }  
    
    /**
     * Create a new CssBorderBottomCSS21
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssBorderBottomCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	CssValue val = null;
	char op = SPACE;
	boolean find = true;
	
	if(check && expression.getCount() > 3) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	boolean manyValues = (expression.getCount() > 1);
	
	setByUser();
	
	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.equals(inherit)) {
		throw new InvalidParamException("unrecognize", null, null, ac);
	    }
	    
	    if (op != SPACE)
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);   
	    if (getWidth() == null) {
		try {
		    setWidth(new CssBorderBottomWidthCSS2(ac, expression));		
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, style will test this value		    
		}
	    }
	    if (!find && getStyle() == null) {
		try {
		    setStyle(new CssBorderBottomStyleCSS2(ac, expression));		    
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, color will test this value
		}
	    }
	    if (!find && getColor() == null) {
		// throws an exception if the value is not valid
		setColor(new CssBorderBottomColorCSS21(ac, expression));
		find = true;		
	    }
	}
    }
    
    public CssBorderBottomCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression,false);
    }
    
}

--- NEW FILE: CssCursorCSS21.java ---
// $Id: CssCursorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css2.user.CursorCSS2;
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.CssURL;
import org.w3c.css.values.CssValue;

/**
 * CssCursorCSS21<br />
 * Created: Aug 30, 2005 4:47:16 PM<br />
 */
public class CssCursorCSS21 extends CursorCSS2 {
    
    private static String CURSOR[] = {
	"auto", "crosshair", "default", "pointer", "move", "e-resize", 
	"ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", 
	"s-resize", "w-resize", "text", "wait", "help", "progress" };
    
    private static int[] hash_values;
       
    /**
     * Create a new Cursor
     */
    public CssCursorCSS21() {
	super();
    }
    
    /**
     * Create a new Cursor
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssCursorCSS21(ApplContext ac, CssExpression expression, boolean check) 
	throws InvalidParamException {
	CssValue val = expression.getValue();
	char op = expression.getOperator();
	
	setByUser();
	
	if (val.equals(inherit)) {
	    if(expression.getCount() > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setInheritedValue(true);
	    expression.next();
	    return;
	}
	
	while ((op == COMMA) && (val instanceof CssURL)) {
	    if(val != null && val.equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    getUris().addElement(val);
	    expression.next();
	    val = expression.getValue();
	    op = expression.getOperator();
	} 
	if (val instanceof CssURL) {
	    throw new InvalidParamException("comma", 
					    val.toString(), 
					    getPropertyName(), ac);
	}
	
	if (val instanceof CssIdent) {
	    int hash = val.hashCode();
	    
	    for (int i = 0; i < CURSOR.length; i++) {
		if (hash_values[i] == hash) {
		    setValue(i);
		    expression.next();
		    if(check && !expression.end()) {
			throw new InvalidParamException("unrecognize", ac);
		    }
		    return;
		}
	    }
	}
	
	throw new InvalidParamException("value", 
					val.toString(), getPropertyName(), ac);
    }
    
    public CssCursorCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression, false);
    }

    /**
     * Returns a string representation of the object.
     */
    public String toString() {
	if (isInheritedValue()) {
	    return inherit.toString();
	} else {
	    int i = 0;
	    int l = getUris().size();
	    String ret = "";
	    while (i != l) {
		ret += getUris().elementAt(i++) + 
		    (new Character(COMMA)).toString() + " ";
	    }
	    ret += " " + CURSOR[getValue()];
	    return ret;
	}
    }
    
    static {
	hash_values = new int[CURSOR.length];
	for (int i=0; i<CURSOR.length; i++)
	    hash_values[i] = CURSOR[i].hashCode();
    }
}

--- NEW FILE: CssBorderBottomColorCSS21.java ---
// $Id: CssBorderBottomColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderBottomColorCSS2;
import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssBorderBottomColorCSS21<br />
 * Created: Aug 31, 2005 2:10:07 PM<br />
 */
public class CssBorderBottomColorCSS21 extends CssBorderBottomColorCSS2 {

    /**
     * Create a new CssBorderBottomColorCSS21 with an another CssBorderFaceColorCSS2
     *
     * @param another An another face.
     */
    public CssBorderBottomColorCSS21(CssBorderFaceColorCSS2 another) {
	super(another);
    }
    
    /**
     * Create a new CssBorderBottomColor
     *
     * @param expression The expression for this property.
     * @exception InvalidParamException Values are incorrect
     */
    public CssBorderBottomColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();
	setFace(new CssBorderFaceColorCSS21(ac, expression));
    }
    
    public CssBorderBottomColorCSS21(ApplContext ac, CssExpression expression) 
    throws InvalidParamException {
	this(ac, expression, false);
    }	
    
}

--- NEW FILE: CssBorderTopCSS21.java ---
// $Id: CssBorderTopCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderTopStyleCSS2;
import org.w3c.css.properties.css1.CssBorderTopWidthCSS2;
import org.w3c.css.properties.css1.CssBorderTopCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBorderTopCSS21<br />
 * Created: Aug 31, 2005 2:08:11 PM<br />
 */
public class CssBorderTopCSS21 extends CssBorderTopCSS2 {
    
    /**
     * Create a new CssBorderTopCSS21
     */
    public CssBorderTopCSS21() {
	super();
    }  
    
    /**
     * Create a new CssBorderTopCSS21
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssBorderTopCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	CssValue val = null;
	char op = SPACE;
	boolean find = true;
	
	if(check && expression.getCount() > 3) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	boolean manyValues = (expression.getCount() > 1);
	
	setByUser();
	
	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.equals(inherit)) {
		throw new InvalidParamException("unrecognize", null, null, ac);
	    }
	    
	    if (op != SPACE)
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);   
	    if (getWidth() == null) {
		try {
		    setWidth(new CssBorderTopWidthCSS2(ac, expression));		
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, style will test this value		    
		}
	    }
	    if (!find && getStyle() == null) {
		try {
		    setStyle(new CssBorderTopStyleCSS2(ac, expression));		    
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, color will test this value
		}
	    }
	    if (!find && getColor() == null) {
		// throws an exception if the value is not valid
		setColor(new CssBorderTopColorCSS21(ac, expression));
		find = true;		
	    }
	}
    }
    
    public CssBorderTopCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression,false);
    }
    
}

--- NEW FILE: CssBorderTopColorCSS21.java ---
// $Id: CssBorderTopColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderFaceColorCSS2;
import org.w3c.css.properties.css1.CssBorderTopColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssBorderTopColorCSS21<br />
 * Created: Aug 31, 2005 2:09:16 PM<br />
 */
public class CssBorderTopColorCSS21 extends CssBorderTopColorCSS2 {

    /**
     * Create a new CssBorderTopColorCSS21 with an another CssBorderFaceColorCSS2
     *
     * @param another An another face.
     */
    public CssBorderTopColorCSS21(CssBorderFaceColorCSS2 another) {
	super(another);
    }
    
    /**
     * Create a new CssBorderTopColor
     *
     * @param expression The expression for this property.
     * @exception InvalidParamException Values are incorrect
     */
    public CssBorderTopColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();
	setFace(new CssBorderFaceColorCSS21(ac, expression));
    }
    
    public CssBorderTopColorCSS21(ApplContext ac, CssExpression expression) 
    throws InvalidParamException {
	this(ac, expression, false);
    }	    
    
}

--- NEW FILE: CssBackgroundColorCSS21.java ---
// $Id: CssBackgroundColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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

/**
 * CssBackgroundColorCSS21<br />
 * Created: Aug 31, 2005 2:04:23 PM<br />
 */
public class CssBackgroundColorCSS21 extends CssBackgroundColorCSS2 {
    
    /**
     * Create a new CssBackgroundColorCSS2
     */
    public CssBackgroundColorCSS21() {
	super();
    }

    /**
     * Create a new CssBackgroundColorCSS2
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */
    public CssBackgroundColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 1) {
	    throw new InvalidParamException("unrecognize", ac);
	}

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

	if (val instanceof org.w3c.css.values.CssColor) {
	    setColor(val);
	    expression.next();
	} else if (val instanceof CssIdent) {
	    if (val.equals(transparent)) {
		setColor(transparent);
		expression.next();
	    } else if (val.equals(inherit)) {
		setColor(inherit);
		expression.next();
	    } else {
		setColor(new org.w3c.css.values.CssColorCSS21(ac, (String) val.get()));
		expression.next();
	    }
	} else {
	    throw new InvalidParamException("value", val.toString(),
					    getPropertyName(), ac);
	}
    }

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

--- NEW FILE: CssWhiteSpaceCSS21.java ---
// $Id: CssWhiteSpaceCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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

/**
 * CssWhiteSpaceCSS21<br />
 * Created: Aug 30, 2005 5:02:07 PM<br />
 */
public class CssWhiteSpaceCSS21 extends CssWhiteSpace {
    private static String[] WHITESPACE = {
	"normal", "pre", "nowrap", "pre-wrap", "pre-line", "inherit" };
    private static int[] hash_values;
    
    /**
     * Create a new CssWhiteSpace
     */
    public CssWhiteSpaceCSS21() {
	// nothing to do
    }
    
    /**
     * Create a new CssWhiteSpace
     *
     * @param expression The expression for this property
     * @exception InvalidParamException values are incorrect
     */  
    public CssWhiteSpaceCSS21(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 instanceof CssIdent) {
	    int hash = val.hashCode();
	    for (int i = 0; i < WHITESPACE.length; i++)
		if (hash_values[i] == hash) {
		    setValue(i);		    
		    expression.next();
		    return;
		}
	}
	
	throw new InvalidParamException("value", expression.getValue(), 
					getPropertyName(), ac);
    }
    
    public CssWhiteSpaceCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression, false);
    }
    
    /**
     * Returns the value of this property
     */
    public Object get() {
	return WHITESPACE[getValue()];
    }
    
    /**
     * Returns true if this property is "softly" inherited
     * e.g. his value equals inherit
     */
    public boolean isSoftlyInherited() {
	return getValue() == (WHITESPACE.length - 1);
    }
    
    /**
     * Returns a string representation of the object.
     */
    public String toString() {
	return WHITESPACE[getValue()];
    }

    static {
	hash_values = new int[WHITESPACE.length];
	for (int i = 0; i < WHITESPACE.length; i++)
	    hash_values[i] = WHITESPACE[i].hashCode();
    }
}

--- NEW FILE: CssBorderColorCSS21.java ---
// $Id: CssBorderColorCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderBottomColorCSS2;
import org.w3c.css.properties.css1.CssBorderColorCSS2;
import org.w3c.css.properties.css1.CssBorderLeftColorCSS2;
import org.w3c.css.properties.css1.CssBorderRightColorCSS2;
import org.w3c.css.properties.css1.CssBorderTopColorCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;

/**
 * CssBorderColorCSS21<br />
 * Created: Aug 31, 2005 2:09:05 PM<br />
 */
public class CssBorderColorCSS21 extends CssBorderColorCSS2 {

    /**
     * Create a new CssBorderColorCSS2 with all four sides
     */
    public CssBorderColorCSS21(CssBorderTopColorCSS2 top,
			  CssBorderBottomColorCSS2 bottom,
			  CssBorderRightColorCSS2 right,
			  CssBorderLeftColorCSS2 left) {
	super(top, bottom, right, left);
    }  
    
    /**
     * Create a new CssBorderColorCSS21
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssBorderColorCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	setByUser();
	
	switch (expression.getCount()) {
	case 1:
	    setTop(new CssBorderTopColorCSS21(ac, expression));
//	    setBottom(new CssBorderBottomColorCSS21(
//		    	(CssBorderFaceColorCSS21) getTop().get()));
//	    setRight(new CssBorderRightColorCSS21(
//		    (CssBorderFaceColorCSS21) getTop().get()));
//	    setLeft(new CssBorderLeftColorCSS21(
//		    (CssBorderFaceColorCSS21) getTop().get()));
	    break;
	case 2:	    
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()),
			ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setTop(new CssBorderTopColorCSS21(ac, expression));
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setRight(new CssBorderRightColorCSS21(ac, expression));
//	    setBottom(new CssBorderBottomColorCSS21(
//		    (CssBorderFaceColorCSS21) getTop().get()));
//	    setLeft(new CssBorderLeftColorCSS21(
//		    (CssBorderFaceColorCSS21) getRight().get()));
	    break;
	case 3:
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()), 
			ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setTop(new CssBorderTopColorCSS21(ac, expression));
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()), ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setRight(new CssBorderRightColorCSS21(ac, expression));
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setBottom(new CssBorderBottomColorCSS21(ac, expression));
//	    setLeft(new CssBorderLeftColorCSS21(
//		    (CssBorderFaceColorCSS21) getRight().get()));
	    break;
	case 4:
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()),
			ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setTop(new CssBorderTopColorCSS21(ac, expression));
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()),
			ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setRight(new CssBorderRightColorCSS21(ac, expression));
	    if (expression.getOperator() != SPACE)
		throw new InvalidParamException("operator", 
			((new Character(expression.getOperator())).toString()),
			ac);
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setBottom(new CssBorderBottomColorCSS21(ac, expression));
	    if(expression.getValue().equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setLeft(new CssBorderLeftColorCSS21(ac, expression));
	    break;
	default:
	    if(check) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	}
    }
    
    public CssBorderColorCSS21(ApplContext ac, CssExpression expression) 
	throws InvalidParamException {
	this(ac, expression, false);
    }
    
}

--- NEW FILE: CssBorderCSS21.java ---
// $Id: CssBorderCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderBottomStyleCSS2;
import org.w3c.css.properties.css1.CssBorderBottomWidthCSS2;
import org.w3c.css.properties.css1.CssBorderCSS2;
import org.w3c.css.properties.css1.CssBorderFaceStyleCSS2;
import org.w3c.css.properties.css1.CssBorderFaceWidthCSS2;
import org.w3c.css.properties.css1.CssBorderLeftStyleCSS2;
import org.w3c.css.properties.css1.CssBorderLeftWidthCSS2;
import org.w3c.css.properties.css1.CssBorderRightStyleCSS2;
import org.w3c.css.properties.css1.CssBorderRightWidthCSS2;
import org.w3c.css.properties.css1.CssBorderTopColorCSS2;
import org.w3c.css.properties.css1.CssBorderTopStyleCSS2;
import org.w3c.css.properties.css1.CssBorderTopWidthCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBorderCSS21<br />
 * Created: Aug 31, 2005 2:07:02 PM<br />
 */
public class CssBorderCSS21 extends CssBorderCSS2 {
    
    /**
     * Create a new CssBorderFaceCSS2
     */
    public CssBorderCSS21() {
	super();
    }  
    
    /**
     * Create a new CssBorderFaceCSS2
     *
     * @param value The value for this property
     * @exception InvalidParamException The value is incorrect
     */  
    public CssBorderCSS21(ApplContext ac, CssExpression value,
	    boolean check) throws InvalidParamException {
	
	if(check && value.getCount() > 3) {
	     throw new InvalidParamException("unrecognize", ac);
	}
	
	CssValue val = value.getValue();
	
	setByUser();	
	
	setTop(new CssBorderTopCSS21(ac, value));
	
	if (val == value.getValue()) {
	    throw new InvalidParamException("value", 
					    value.getValue(), 
					    getPropertyName(), ac);
	}	
	setRight(new CssBorderRightCSS21());
	setBottom(new CssBorderBottomCSS21());
	setLeft(new CssBorderLeftCSS21());
	
	CssBorderTopWidthCSS2 w = getTop().getWidth2();
	CssBorderTopStyleCSS2 s = getTop().getStyle2();
	CssBorderTopColorCSS2 c = getTop().getColor2();	
	
	if(w != null) {	    
	    getRight().setWidth( 
		new CssBorderRightWidthCSS2((CssBorderFaceWidthCSS2) w.get()));	    
	    getLeft().setWidth( 
		new CssBorderLeftWidthCSS2((CssBorderFaceWidthCSS2) w.get()));	    
	    getBottom().setWidth( 
		new CssBorderBottomWidthCSS2((CssBorderFaceWidthCSS2) w.get()));	    
	}	
	if(s != null) {
	    getRight().setStyle( 
		new CssBorderRightStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
	    getLeft().setStyle( 
		new CssBorderLeftStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
	    getBottom().setStyle( 
		new CssBorderBottomStyleCSS2((CssBorderFaceStyleCSS2) s.get()));
	}	
	if(c != null) {
	    getRight().setColor( 
		new CssBorderRightColorCSS21((CssBorderFaceColorCSS21) c.get()));
	    getLeft().setColor( 
		new CssBorderLeftColorCSS21((CssBorderFaceColorCSS21) c.get()));
	    getBottom().setColor( 
		new CssBorderBottomColorCSS21((CssBorderFaceColorCSS21) c.get()));
	}	
    }
    
    public CssBorderCSS21(ApplContext ac, CssExpression expression) 
	throws InvalidParamException {
	this(ac, expression, false);
    }
    
}

--- NEW FILE: CssBorderRightCSS21.java ---
// $Id: CssBorderRightCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBorderRightCSS2;
import org.w3c.css.properties.css1.CssBorderRightStyleCSS2;
import org.w3c.css.properties.css1.CssBorderRightWidthCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssBorderRightCSS21<br />
 * Created: Aug 31, 2005 2:08:24 PM<br />
 */
public class CssBorderRightCSS21 extends CssBorderRightCSS2 {
    
    /**
     * Create a new CssBorderRightCSS21
     */
    public CssBorderRightCSS21() {
	super();
    }  
    
    /**
     * Create a new CssBorderRightCSS21
     *
     * @param expression The expression for this property
     * @exception InvalidParamException The expression is incorrect
     */  
    public CssBorderRightCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	CssValue val = null;
	char op = SPACE;
	boolean find = true;
	
	if(check && expression.getCount() > 3) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	boolean manyValues = (expression.getCount() > 1);
	
	setByUser();
	
	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.equals(inherit)) {
		throw new InvalidParamException("unrecognize", null, null, ac);
	    }
	    
	    if (op != SPACE)
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);   
	    if (getWidth() == null) {
		try {
		    setWidth(new CssBorderRightWidthCSS2(ac, expression));		
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, style will test this value		    
		}
	    }
	    if (!find && getStyle() == null) {
		try {
		    setStyle(new CssBorderRightStyleCSS2(ac, expression));		    
		    find = true;
		} catch(InvalidParamException e){
		    // nothing to do, color will test this value
		}
	    }
	    if (!find && getColor() == null) {
		// throws an exception if the value is not valid
		setColor(new CssBorderRightColorCSS21(ac, expression));
		find = true;		
	    }
	}
    }
    
    public CssBorderRightCSS21(ApplContext ac, CssExpression expression)
	throws InvalidParamException {
	this(ac, expression,false);
    }
    
}

--- NEW FILE: CssListStyleCSS21.java ---
// $Id: CssListStyleCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssListStyleCSS2;
import org.w3c.css.properties.css1.CssListStyleImageCSS2;
import org.w3c.css.properties.css1.CssListStylePositionCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssValue;

/**
 * CssListStyleCSS21<br />
 * Created: Aug 31, 2005 12:09:48 PM<br />
 */
public class CssListStyleCSS21 extends CssListStyleCSS2 {
    /**
     * Create a new CssListStyleCSS2
     */
    public CssListStyleCSS21() {
	// nothing to do
    }  
    
    /**
     * Create a new CssListStyleCSS2
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssListStyleCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	int exprLength = expression.getCount();
	
	if(check && exprLength > 3) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	CssValue val = expression.getValue();
	char op = SPACE;
	boolean find = true;
	
	setByUser();

	if (val.equals(inherit)) {
	    if(exprLength > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setInheritedValue(true);
	    expression.next();
	    return;
	}
	
	while (find) {
	    find = false;
	    val = expression.getValue();
	    op = expression.getOperator();
	    
	    if(val != null && val.equals(inherit)) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    
	    if ((getListStyleType() == null)	&& (val != null)) {
		try {
		    setListStyleType(new CssListStyleTypeCSS21(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		}
	    }
	    if (!find && (getListStyleImage() == null) && (val != null)) {
		try {
		    setListStyleImage(new CssListStyleImageCSS2(ac, expression));
		    find = true;
		} catch (InvalidParamException e) {
		} 
	    }
	    if (!find && (val != null) && (getListStylePosition() == null)) {
		setListStylePosition(new CssListStylePositionCSS2(ac, expression));
		find = true;
	    }
	    if(val != null && !find) {		
		throw new InvalidParamException("unrecognize", ac);
	    }
	    if (op != SPACE) {
		throw new InvalidParamException("operator", 
						((new Character(op)).toString()),
						ac);
	    }
	}

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

--- NEW FILE: CssBackgroundPositionCSS21.java ---
// $Id: CssBackgroundPositionCSS21.java,v 1.1 2005/09/01 11:51:21 ylafon Exp $
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2005.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

import org.w3c.css.properties.css1.CssBackgroundPositionCSS2;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssLength;
import org.w3c.css.values.CssNumber;
import org.w3c.css.values.CssPercentage;
import org.w3c.css.values.CssValue;

/**
 * CssBackgroundPositionCSS21<br />
 * Created: Aug 31, 2005 5:45:30 PM<br />
 */
public class CssBackgroundPositionCSS21 extends CssBackgroundPositionCSS2 {

    /**
     * Create a new CssBackgroundPositionCSS2
     */
    public CssBackgroundPositionCSS21() {
	super();
    }  
    
    /**
     * Creates a new CssBackgroundPositionCSS2
     *
     * @param expression The expression for this property
     * @exception InvalidParamException Values are incorrect
     */  
    public CssBackgroundPositionCSS21(ApplContext ac, CssExpression expression,
	    boolean check) throws InvalidParamException {
	
	if(check && expression.getCount() > 2) {
	    throw new InvalidParamException("unrecognize", ac);
	}
	
	setByUser();
	CssValue val = expression.getValue();
	char op  = expression.getOperator();
	
	if (op != SPACE)
	    throw new  InvalidParamException("operator", 
					     ((new Character(op)).toString()),
					     ac);
	
	if (val.equals(inherit)) {
	    if(expression.getCount() > 1) {
		throw new InvalidParamException("unrecognize", ac);
	    }
	    setFirst(inherit);
	    setSecond(inherit);
	    expression.next();
	    return;
	}
		
	CssValue next = expression.getNextValue();	

	if(val instanceof CssIdent) {	    
	    int index1 = IndexOfIdent((String) val.get());
	    if(index1 == -1) {
		throw new InvalidParamException("value", val, "background-position", ac);
	    }
	    // two keywords
	    if(next instanceof CssIdent) {		
		int index2 = IndexOfIdent((String) next.get());
		if(index2 == -1 && check) {
		    throw new InvalidParamException("value", next, "background-position", ac);
		}
		// one is vertical, the other is vertical
		// or the two are 'center'
		if((isHorizontal(index1) && isVertical(index2)) ||
			(isHorizontal(index2) && isVertical(index1))) {
		    setFirst(val);
		    setSecond(next);		    
		}
		// both are horizontal or vertical but not 'center'
		else if(check){		    
		    throw new InvalidParamException("incompatible",
			    val, next, ac);
		}
		else {
		    setFirst(val);
		}
	    }
	    // a keyword and a percentage/length
	    else if(next instanceof CssLength || next instanceof CssPercentage
		    || next instanceof CssNumber) {
		if(isHorizontal(index1)) {
		    if(next instanceof CssNumber) {
			next = ((CssNumber) next).getLength();
		    }
		    setFirst(val);
		    setSecond(next);
		}
		// if the keyword is the first value, it can only be an 
		// horizontal one 
		else {
		    throw new InvalidParamException("incompatible",
			    val, next, ac);
		}
	    }
	    // only one value
	    else if(next == null) {
		setFirst(val);
	    }
	    // the second value is invalid
	    else if(check) {		
		throw new InvalidParamException("value", next, 
			getPropertyName(), ac);
	    }
	    else {
		setFirst(val);
	    }
	}
	else if(val instanceof CssLength || val instanceof CssPercentage ||
		val instanceof CssNumber) {
	    if(val instanceof CssNumber) {
		val = ((CssNumber) val).getLength();
	    }
	    // a percentage/length and an keyword
	    if(next instanceof CssIdent) {
		int index = IndexOfIdent((String) next.get());
		if(check && index == -1) {
		    throw new InvalidParamException("value", next, "background-position", ac);
		}
		// the keyword must be a vertical one
		if(isVertical(index)) {
		    setFirst(val);
		    setSecond(next);
		}
		else if(check) {
		    throw new InvalidParamException("incompatible",
			    val, next, ac);
		}
		else {
		    setFirst(val);
		}
	    }
	    else if(next instanceof CssLength || next instanceof CssPercentage
		    || next instanceof CssNumber) {
		if(next instanceof CssNumber) {
		    next = ((CssNumber) next).getLength();
		}
		setFirst(val);
		setSecond(next);
	    }
	    else if(next == null || !check) {
		setFirst(val);
	    }
	    else {
		throw new InvalidParamException("incompatible", val, next, ac);
	    }
	}
	else if(check){
	    throw new InvalidParamException("value", expression.getValue(), 
		    getPropertyName(), ac);
	}
	
	// we only move the cursor if we found valid values
	if(getFirst() != null) {	    
	    expression.next();	    
	}
	if(getSecond() != null) {	    
	    expression.next();	    
	}	
    }
    
    public CssBackgroundPositionCSS21(ApplContext ac, CssExpression expression) 
	throws InvalidParamException {
	this(ac, expression, false);
    }
    
}

Received on Thursday, 1 September 2005 11:51:57 UTC