W3C home > Mailing lists > Public > www-validator-cvs@w3.org > February 2009

2002/css-validator/org/w3c/css/selectors PseudoFactory.java,1.6,1.7 PseudoFunctionSelector.java,1.2,1.3

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 12 Feb 2009 21:26:38 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1LXj4w-0000Ki-1p@lionel-hutz.w3.org>

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

Modified Files:
	PseudoFactory.java PseudoFunctionSelector.java 
Log Message:
pseudo-function handling, per CSS3 selectors rules (note that some construction
forbidden by the text are ok according to the grammar, so extra checks are needed)
Initial support of namespaces.


Index: PseudoFunctionSelector.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/PseudoFunctionSelector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- PseudoFunctionSelector.java	14 Sep 2005 15:15:32 -0000	1.2
+++ PseudoFunctionSelector.java	12 Feb 2009 21:26:35 -0000	1.3
@@ -12,7 +12,7 @@
 
     private String name;
     private Object param;
-
+    private String representation = null;
     /**
      * Creates a new empty function selector
      */
@@ -70,6 +70,15 @@
      * @see Selector#toString()
      */
     public String toString() {
-	return ":" + name + "(" + param + ")";
+	if (representation == null) {
+	    StringBuffer sb = new StringBuffer();
+	    sb.append(':');
+	    sb.append(name);
+	    sb.append('(');
+	    sb.append(param);
+	    sb.append(')');
+	    representation = sb.toString();
+	}
+	return representation;
     }
 }

Index: PseudoFactory.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/PseudoFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- PseudoFactory.java	12 Feb 2009 10:55:34 -0000	1.6
+++ PseudoFactory.java	12 Feb 2009 21:26:35 -0000	1.7
@@ -4,6 +4,17 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.selectors;
 
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionContains;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionLang;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNot;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthChild;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthLastChild;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthOfType;
+import org.w3c.css.selectors.pseudofunctions.PseudoFunctionNthLastOfType;
+
 /**
  * PseudoFactory<br />
  * Created: Sep 2, 2005 2:41:09 PM<br />
@@ -142,5 +153,44 @@
 	}
 	return null;
     }
-    
+
+    /**
+     * Returns a PseudoFunctionSelector based on the name of the 
+     * selector
+     * @param name, the name of the pseudofun selector
+     * @param value, its value
+     * @throws InvalidParamException
+     */
+    public static PseudoFunctionSelector newPseudoFunction(String name, 
+					       String value, ApplContext ac) 
+	throws InvalidParamException
+    {
+	if (name == null) {
+	    throw new InvalidParamException("pseudo", 
+					    "null pseudofunction", ac);
+	}
+	if (name.equals("lang")) {
+	    return new PseudoFunctionLang(name, value);
+	}
+	if (name.equals("not")) {
+	    return new PseudoFunctionNot(name, value);
+	}
+	if (name.equals("contains")) {
+	    return new PseudoFunctionContains(name, value);
+	}
+	if (name.equals("nth-child")) {
+	    return new PseudoFunctionNthChild(name, value);
+	}
+	if (name.equals("nth-last-child")) {
+	    return new PseudoFunctionNthLastChild(name, value);
+	}
+	if (name.equals("nth-of-type")) {
+	    return new PseudoFunctionNthOfType(name, value);
+	}
+	if (name.equals("nth-last-of-type")) {
+	    return new PseudoFunctionNthLastOfType(name, value);
+	}
+	throw new InvalidParamException("pseudo", 
+					":"+name, ac);
+    }
 }
Received on Thursday, 12 February 2009 21:26:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:08 GMT