2002/css-validator/org/w3c/css/properties/css3 CssListStyle.java,NONE,1.1 CssListStyleImage.java,NONE,1.1 CssListStylePosition.java,NONE,1.1 CssListStyleType.java,NONE,1.1

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

Added Files:
	CssListStyle.java CssListStyleImage.java 
	CssListStylePosition.java CssListStyleType.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:59 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.css3;

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.Arrays;

/**
 * @spec http://www.w3.org/TR/2011/WD-css3-lists-20110524/#list-style-type
 */
public class CssListStyleType extends org.w3c.css.properties.css.CssListStyleType {

	public static final CssIdent[] allowed_values;

	static {
		String[] _allowed_values = {"none", "inline", "ethiopic-numeric",
				"triangle", "trinary", "go", "fixed-decimal", "unary",
				"box-corner", "dice", "box", "check", "circle", "diamond",
				"disc", "dash", "square", "arabic-indic", "bengali",
				"binary", "burmese", "cambodian", "cjk-decimal", "decimal",
				"devanagari", "eastern-nagari", "fullwidth-decimal",
				"gujarati", "gurmukhi", "kannada", "khmer",
				"lower-hexadecimal", "lao", "lepcha", "malayalam", "marathi",
				"mongolian", "myanmar", "new-base-60", "octal", "oriya",
				"persian", "super-decimal", "tamil", "telugu", "tibetan",
				"thai", "upper-hexadecimal", "afar", "agaw", "ari", "blin",
				"cjk-earthly-branch", "cjk-heavenly-stem", "dizi",
				"fullwidth-lower-alpha", "fullwidth-upper-alpha",
				"gedeo", "gumuz", "hadiyya", "harari", "hindi",
				"hiragana-iroha", "hiragana", "kaffa", "katakana-iroha",
				"katakana", "kebena", "kembata", "konso", "korean-consonant",
				"korean-syllable", "kunama", "lower-alpha",
				"lower-belorussian", "lower-bulgarian", "lower-greek",
				"lower-macedonian", "lower-oromo-qubee", "lower-russian",
				"lower-russian-full", "lower-serbo-croatian",
				"lower-ukrainian", "lower-ukrainian-full",
				"meen", "oromo", "saho", "sidama", "silti",
				"thai-alphabetic", "tigre", "upper-alpha", "upper-belorussian",
				"upper-bulgarian", "upper-macedonian", "upper-oromo-qubee",
				"upper-russian", "upper-russian-full", "upper-serbo-croatian",
				"upper-ukrainian", "upper-ukrainian-full", "wolaita",
				"yemsa", "asterisks", "footnotes", "lower-alpha-symbolic",
				"upper-alpha-symbolic", "circled-decimal",
				"circled-lower-latin", "circled-upper-latin", "circled-korean-consonants",
				"circled-korean-syllables", "decimal-leading-zero",
				"dotted-decimal", "double-circled-decimal",
				"filled-circled-decimal", "fullwidth-upper-roman",
				"fullwidth-lower-roman", "parenthesized-decimal",
				"parenthesized-lower-latin", "parenthesized-hangul-consonants",
				"parenthesized-hangul-syllable", "persian-abjad",
				"persian-alphabetic", "hebrew", "simple-upper-roman",
				"simple-lower-roman", "upper-roman", "lower-roman",
				"lower-armenian", "upper-armenian", "armenian", "georgian",
				"ancient-tamil", "japanese-informal", "japanese-formal",
				"korean-hangul-formal", "korean-hanja-informal",
				"korean-hanja-formal", "greek"};
		int i = 0;
		allowed_values = new CssIdent[_allowed_values.length];
		for (String s : _allowed_values) {
			allowed_values[i++] = CssIdent.getIdent(s);
		}
		Arrays.sort(allowed_values);
	}

	public static final CssIdent getAllowedIdent(CssIdent ident) {
		int idx = Arrays.binarySearch(allowed_values, ident);
		return (idx < 0) ? null : allowed_values[idx];
	}

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

		switch (val.getType()) {
			case CssTypes.CSS_STRING:
				value = val;
				break;
			case CssTypes.CSS_IDENT:
				CssIdent id = (CssIdent) val;
				if (inherit.equals(id)) {
					value = inherit;
					break;
				} else {
					value = getAllowedIdent(id);
					if (value == null) {
						// it's still acceptable
						// but the name should be listed in a
						// @counter-style rule
						value = val;
						// TODO check counter-style
						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:59 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.css3;

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/WD-css3-lists-20110524/#list-style-position
 */
public class CssListStylePosition extends org.w3c.css.properties.css.CssListStylePosition {

	public static final CssIdent[] allowed_values;

	static {
		String[] _allowed_values = {"inside", "hanging", "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() {
		value = initial;
	}


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

}

--- NEW FILE: CssListStyleImage.java ---
// $Id: CssListStyleImage.java,v 1.1 2012/11/07 11:34:59 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.css3;

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/WD-css3-lists-20110524/#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_FUNCTION:
				// TODO check gradient, image
				// perhaps using val.getImage(); ?
			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: CssListStyle.java ---
// $Id: CssListStyle.java,v 1.1 2012/11/07 11:34:59 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.css3;

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/WD-css3-lists-20110524/#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_FUNCTION:
					//TODO gradient/image
				case CssTypes.CSS_URL:
					if (imageVal != null) {
						throw new InvalidParamException("value", val,
								getPropertyName(), ac);
					}
					imageVal = val;
					break;
				case CssTypes.CSS_STRING:
					if (typeVal != null) {
						// TODO duplicate value error
						throw new InvalidParamException("value", none,
								getPropertyName(), ac);
					}
					typeVal = 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) {
							// TODO check the @counter-style
							typeVal = val;
							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:08 UTC