W3C home > Mailing lists > Public > www-validator-cvs@w3.org > November 2012

2002/css-validator/org/w3c/css/properties/css21 CssListStyle.java,NONE,1.1 CssListStyleImage.java,NONE,1.1 CssListStylePosition.java,NONE,1.1 CssListStyleType.java,NONE,1.1 CssListStyleCSS21.java,1.2,NONE CssListStyleTypeCSS21.java,1.2,NONE

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 07 Nov 2012 11:35:01 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1TW3uP-0004c9-3B@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css21
In directory hutz:/tmp/cvs-serv17598/css21

Added Files:
	CssListStyle.java CssListStyleImage.java 
	CssListStylePosition.java CssListStyleType.java 
Removed Files:
	CssListStyleCSS21.java CssListStyleTypeCSS21.java 
Log Message:
list-style-* per css1/2/21/3/tv plus cleanup of multiple property depending on the level in css1style

--- NEW FILE: CssListStyleType.java ---
// $Id: CssListStyleType.java,v 1.1 2012/11/07 11:34:58 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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;

/**
 * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#propdef-list-style-type
 */
public class CssListStyleType extends org.w3c.css.properties.css.CssListStyleType {

	public static final CssIdent[] allowed_values;

	static {
		String[] _allowed_values = {"none", "disc", "circle", "square", "decimal",
				"decimal-leading-zero", "lower-roman", "upper-roman", "lower-greek",
				"lower-latin", "upper-latin", "armenian", "georgian", "lower-alpha",
				"upper-alpha"};
		int i = 0;
		allowed_values = new CssIdent[_allowed_values.length];
		for (String s : _allowed_values) {
			allowed_values[i++] = CssIdent.getIdent(s);
		}
	}

	public static final CssIdent getAllowedIdent(CssIdent ident) {
		for (CssIdent id : allowed_values) {
			if (id.equals(ident)) {
				return id;
			}
		}
		return null;
	}

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


	/**
	 * Set the value of the property<br/>
	 * Does not check the number of values
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyleType(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Set the value of the property
	 *
	 * @param expression The expression for this property
	 * @param check      set it to true to check the number of values
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyleType(ApplContext ac, CssExpression expression,
							boolean check) throws InvalidParamException {
		if (check && expression.getCount() > 1) {
			throw new InvalidParamException("unrecognize", ac);
		}
		setByUser();

		CssValue val;
		char op;

		val = expression.getValue();
		op = expression.getOperator();

		if (val.getType() != CssTypes.CSS_IDENT) {
			throw new InvalidParamException("value", val,
					getPropertyName(), ac);
		}
		CssIdent id = (CssIdent) val;
		if (inherit.equals(id)) {
			value = inherit;
		} else {
			value = getAllowedIdent(id);
			if (value == null) {
				throw new InvalidParamException("value",
						val.toString(),
						getPropertyName(), ac);
			}
		}
		expression.next();
	}

}

--- NEW FILE: CssListStyleImage.java ---
// $Id: CssListStyleImage.java,v 1.1 2012/11/07 11:34:58 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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;

/**
 * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#propdef-list-style-image
 */
public class CssListStyleImage extends org.w3c.css.properties.css.CssListStyleImage {

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


	/**
	 * Set the value of the property<br/>
	 * Does not check the number of values
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyleImage(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Set the value of the property
	 *
	 * @param expression The expression for this property
	 * @param check      set it to true to check the number of values
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyleImage(ApplContext ac, CssExpression expression,
							 boolean check) throws InvalidParamException {
		if (check && expression.getCount() > 1) {
			throw new InvalidParamException("unrecognize", ac);
		}
		setByUser();

		CssValue val;
		char op;

		val = expression.getValue();
		op = expression.getOperator();

		switch (val.getType()) {
			case CssTypes.CSS_URL:
				value = val;
				break;
			case CssTypes.CSS_IDENT:
				if (inherit.equals(val)) {
					value = inherit;
					break;
				}
				if (none.equals(val)) {
					value = none;
					break;
				}
			default:
				throw new InvalidParamException("value",
						val.toString(),
						getPropertyName(), ac);
		}
		expression.next();
	}
}

--- NEW FILE: CssListStylePosition.java ---
// $Id: CssListStylePosition.java,v 1.1 2012/11/07 11:34:58 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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;

/**
 * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#propdef-list-style-position
 */
public class CssListStylePosition extends org.w3c.css.properties.css.CssListStylePosition {

	public static final CssIdent[] allowed_values;

	static {
		String[] _allowed_values = {"inside", "outside"};
		int i = 0;
		allowed_values = new CssIdent[_allowed_values.length];
		for (String s : _allowed_values) {
			allowed_values[i++] = CssIdent.getIdent(s);
		}
	}

	public static final CssIdent getAllowedIdent(CssIdent ident) {
		for (CssIdent id : allowed_values) {
			if (id.equals(ident)) {
				return id;
			}
		}
		return null;
	}

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


	/**
	 * Set the value of the property<br/>
	 * Does not check the number of values
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStylePosition(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Set the value of the property
	 *
	 * @param expression The expression for this property
	 * @param check      set it to true to check the number of values
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStylePosition(ApplContext ac, CssExpression expression,
								boolean check) throws InvalidParamException {
		if (check && expression.getCount() > 1) {
			throw new InvalidParamException("unrecognize", ac);
		}
		setByUser();

		CssValue val;
		char op;

		val = expression.getValue();
		op = expression.getOperator();

		if (val.getType() != CssTypes.CSS_IDENT) {
			throw new InvalidParamException("value", val,
					getPropertyName(), ac);
		}
		CssIdent id = (CssIdent) val;
		if (inherit.equals(id)) {
			value = inherit;
		} else {
			value = getAllowedIdent(id);
			if (value == null) {
				throw new InvalidParamException("value",
						val.toString(),
						getPropertyName(), ac);
			}
		}
		expression.next();
	}

}

--- CssListStyleCSS21.java DELETED ---

--- CssListStyleTypeCSS21.java DELETED ---

--- NEW FILE: CssListStyle.java ---
// $Id: CssListStyle.java,v 1.1 2012/11/07 11:34:57 ylafon Exp $
// Author: Yves Lafon <ylafon@w3.org>
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css21;

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 static org.w3c.css.values.CssOperator.SPACE;

/**
 * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#propdef-list-style
 */
public class CssListStyle extends org.w3c.css.properties.css.CssListStyle {

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


	/**
	 * Set the value of the property<br/>
	 * Does not check the number of values
	 *
	 * @param expression The expression for this property
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyle(ApplContext ac, CssExpression expression)
			throws InvalidParamException {
		this(ac, expression, false);
	}

	/**
	 * Set the value of the property
	 *
	 * @param expression The expression for this property
	 * @param check      set it to true to check the number of values
	 * @throws org.w3c.css.util.InvalidParamException
	 *          The expression is incorrect
	 */
	public CssListStyle(ApplContext ac, CssExpression expression,
						boolean check) throws InvalidParamException {
		if (check && expression.getCount() > 3) {
			throw new InvalidParamException("unrecognize", ac);
		}
		setByUser();

		CssValue val;
		char op;
		CssValue imageVal = null;
		CssValue positionVal = null;
		CssValue typeVal = null;
		int nbnone = 0;

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

			switch (val.getType()) {
				case CssTypes.CSS_URL:
					if (imageVal != null) {
						throw new InvalidParamException("value", val,
								getPropertyName(), ac);
					}
					imageVal = val;
					break;
				case CssTypes.CSS_IDENT:
					if (inherit.equals(val)) {
						if (expression.getCount() > 1) {
							throw new InvalidParamException("unrecognize", ac);
						}
						value = inherit;
						imageVal = inherit;
						positionVal = inherit;
						typeVal = inherit;
						break;
					}
					if (none.equals(val)) {
						nbnone++;
						break;
					}
					// now we go to other values...
					CssIdent id = (CssIdent) val;
					if (positionVal == null) {
						positionVal = CssListStylePosition.getAllowedIdent(id);
						if (positionVal != null) {
							break;
						}
					}
					if (typeVal == null) {
						typeVal = CssListStyleType.getAllowedIdent(id);
						if (typeVal != null) {
							break;
						}
					}
					// unrecognized ident.. fail!
				default:
					throw new InvalidParamException("value", val,
							getPropertyName(), ac);
			}
			if (op != SPACE) {
				throw new InvalidParamException("operator",
						((new Character(op)).toString()), ac);
			}
			expression.next();
		}
		// some postprocessing...
		if (nbnone > 0) {
			switch (nbnone) {
				case 1:
					// we set the value ot the non-specified by the shorthand
					// values...
					if (imageVal != null && typeVal != null) {
						// TODO duplicate value error
						throw new InvalidParamException("value", none,
								getPropertyName(), ac);
					}
					if (typeVal == null) {
						typeVal = none;
					}
					if (imageVal == null) {
						imageVal = none;
					}
					break;
				case 2:
					if (imageVal != null || typeVal != null) {
						// TODO duplicate value error
						throw new InvalidParamException("value", none,
								getPropertyName(), ac);
					}
					typeVal = none;
					imageVal = none;
					break;
				default:
					throw new InvalidParamException("value", none,
							getPropertyName(), ac);
			}
		}

		// set the value
		if (value != inherit) {
			ArrayList<CssValue> v = new ArrayList<CssValue>();
			if (typeVal != null) {
				v.add(typeVal);
			}
			if (positionVal != null) {
				v.add(positionVal);
			}
			if (imageVal != null) {
				v.add(imageVal);
			}
			value = (v.size() == 1) ? v.get(0) : new CssValueList(v);
		}
		// then the shorthand values
		cssListStyleType = new CssListStyleType();
		cssListStyleType.value = typeVal;
		cssListStylePosition = new CssListStylePosition();
		cssListStylePosition.value = positionVal;
		cssListStyleImage = new CssListStyleImage();
		cssListStyleImage.value = imageVal;
	}
}
Received on Wednesday, 7 November 2012 11:35:05 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:53 UTC