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

2002/css-validator/org/w3c/css/values CssIdent.java,1.7,1.8

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 17 Dec 2009 16:09:47 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1NLIvD-0007ql-2r@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/values
In directory hutz:/tmp/cvs-serv30157/org/w3c/css/values

Modified Files:
	CssIdent.java 
Log Message:
ident caching of some values + static accessors

Index: CssIdent.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssIdent.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssIdent.java	25 Mar 2008 18:30:11 -0000	1.7
+++ CssIdent.java	17 Dec 2009 16:09:44 -0000	1.8
@@ -6,6 +6,8 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.values;
 
+import java.util.HashMap;
+
 import org.w3c.css.util.ApplContext;
 
 /**
@@ -13,6 +15,27 @@
  */
 public class CssIdent extends CssValue {
 
+    public static HashMap<String,CssIdent> allowedvalues;
+    static {
+	allowedvalues = new HashMap<String,CssIdent>();
+	allowedvalues.put("inherit", new CssIdent("inherit"));
+	allowedvalues.put("none", new CssIdent("inherit"));
+    }
+    /**
+     * Get a cached CssIdent, useful for common values like "inherit"
+     * @param name, the ident name
+     * @return a CssIdent
+     */
+    public static CssIdent getIdent(String name) {
+	CssIdent val = allowedvalues.get(name);
+	if (val != null) {
+	    return val;
+	}
+	val = new CssIdent(name);
+	allowedvalues.put(name, val);
+	return val;
+    }
+
     public static final int type = CssTypes.CSS_IDENT;
     
     private int hashcode = 0;
Received on Thursday, 17 December 2009 16:09:48 GMT

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