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

2002/css-validator/org/w3c/css/properties/css1 CssTextTransform.java,1.4,1.5

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 31 Aug 2012 12:24:59 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T7QHT-0005YX-U3@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv21305/css1

Modified Files:
	CssTextTransform.java 
Log Message:
text-transform per relevant spec

Index: CssTextTransform.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssTextTransform.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssTextTransform.java	5 Jan 2010 13:49:45 -0000	1.4
+++ CssTextTransform.java	31 Aug 2012 12:24:57 -0000	1.5
@@ -1,178 +1,83 @@
-//
 // $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
+// Author: Yves Lafon <ylafon@w3.org>
 //
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css1;
 
-import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.values.CssExpression;
 import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssTypes;
 import org.w3c.css.values.CssValue;
 
 /**
- *   <H4>
- *     <A NAME="text-transform">5.4.5 &nbsp;&nbsp; 'text-transform'</A>
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> capitalize | uppercase | lowercase | none<BR>
- *   <EM>Initial:</EM> none<BR>
- *   <EM>Applies to:</EM> all elements<BR>
- *   <EM>Inherited:</EM> yes<BR>
- *   <EM>Percentage values:</EM> N/A<BR>
- *   <DL>
- *     <DT>
- *       'capitalize'
- *     <DD>
- *       uppercases the first character of each word
- *     <DT>
- *       'uppercase'
- *     <DD>
- *       uppercases all letters of the element
- *     <DT>
- *       'lowercase'
- *     <DD>
- *       lowercases all letters of the element
- *     <DT>
- *       'none'
- *     <DD>
- *       neutralizes inherited value.
- *   </DL>
- *   <P>
- *   The actual transformation in each case is human language dependent. See
- *   <A href="#ref4">[4]</A> for ways to find the language of an element.
- *   <PRE>
- *   H1 { text-transform: uppercase }
- * </PRE>
- *   <P>
- *   The example above would put 'H1' elements in uppercase text.
- *
- * <P>
- * <A NAME="ref4">[4]</A> F Yergeau, G Nicol, G Adams, M D&uuml;rst:
- * "<A HREF="ftp://ietf.org/internet-drafts/draft-ietf-html-i18n-05.txt">Internationalization
- * of the Hypertext Markup Language</A>"
- * (ftp://ietf.org/internet-drafts/draft-ietf-html-i18n-05.txt).
- *
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#text-transform
  */
-public class CssTextTransform extends CssProperty
-        implements CssTextPropertiesConstants {
-
-    /**
-     * Create a new CssTextTransform
-     */
-    public CssTextTransform() {
-    }
+public class CssTextTransform extends org.w3c.css.properties.css.CssTextTransform {
 
-    /**
-     * Create a new CssTextTransform
-     *
-     * @param expression The expression for this property
-     * @exception InvalidParamException The value is incorrect
-     */
-    public CssTextTransform(ApplContext ac, CssExpression expression, boolean check)
-	throws InvalidParamException {
+	private static CssIdent[] allowed_values;
 
-	if(check && expression.getCount() > 1) {
-	    throw new InvalidParamException("unrecognize", ac);
+	static {
+		String id_values[] = {"capitalize", "uppercase", "lowercase", "none"};
+		allowed_values = new CssIdent[id_values.length];
+		int i = 0;
+		for (String s : id_values) {
+			allowed_values[i++] = CssIdent.getIdent(s);
+		}
 	}
 
-	CssValue val = expression.getValue();
-	int hash = val.hashCode();
-
-	if (val instanceof CssIdent) {
-	    for (int i = 0; i < TEXTTRANSFORM.length; i++) {
-		if (hash_values[i] == hash) {
-		    value = i;
-		    expression.next();
-		    return;
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
 		}
-	    }
+		return null;
 	}
-	throw new InvalidParamException("value", val.toString(), getPropertyName(), ac);
-    }
 
-    public CssTextTransform(ApplContext ac, CssExpression expression)
-	throws InvalidParamException {
-	this(ac, expression, false);
-    }
-
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-	return TEXTTRANSFORM[value];
-    }
-
-    /**
-     * Returns the name of this property
-     */
-    public String getPropertyName() {
-	return "text-transform";
-    }
-
-    /**
-     * Returns true if this property is "softly" inherited
-     * e.g. his value equals inherit
-     */
-    public boolean isSoftlyInherited() {
-	return value == (TEXTTRANSFORM.length - 1);
-    }
-
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-	return TEXTTRANSFORM[value];
-    }
-
-    /**
-     * Add this property to the CssStyle.
-     *
-     * @param style The CssStyle
-     */
-    public void addToStyle(ApplContext ac, CssStyle style) {
-	Css1Style style0 = (Css1Style) style;
-	if (style0.cssTextTransform != null)
-	    style0.addRedefinitionWarning(ac, this);
-	style0.cssTextTransform = 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).getTextTransform();
-	} else {
-	    return ((Css1Style) style).cssTextTransform;
+	/**
+	 * Create a new CssTextTransform
+	 */
+	public CssTextTransform() {
+		value = initial;
 	}
-    }
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param value The other property.
-     */
-    public boolean equals(CssProperty property) {
-	return (property instanceof CssTextTransform &&
-		value == ((CssTextTransform) property).value);
-    }
+	/**
+	 * Creates a new CssTextTransform
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Expressions are incorrect
+	 */
+	public CssTextTransform(ApplContext ac, CssExpression expression, boolean check)
+			throws InvalidParamException {
+		setByUser();
+		CssValue val = expression.getValue();
 
-    private int value;
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    private static int[] hash_values;
+		if (val.getType() != CssTypes.CSS_IDENT) {
+			throw new InvalidParamException("value",
+					expression.getValue(),
+					getPropertyName(), ac);
+		}
+		val = getMatchingIdent((CssIdent) val);
+		if (val == null) {
+			throw new InvalidParamException("value",
+					expression.getValue(),
+					getPropertyName(), ac);
+		}
+		value = val;
+		expression.next();
+	}
 
-    static {
-	hash_values = new int[TEXTTRANSFORM.length];
-	for (int i=0; i<TEXTTRANSFORM.length; i++)
-	    hash_values[i] = TEXTTRANSFORM[i].hashCode();
-    }
+	public CssTextTransform(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 }
+
Received on Friday, 31 August 2012 12:25:05 UTC

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