2002/css-validator/org/w3c/css/parser AtRulePage.java,1.4,1.5 CssFouffa.java,1.53,1.54 CssParseException.java,1.5,1.6 CssPropertyFactory.java,1.25,1.26 CssValidatorListener.java,1.6,1.7 Frame.java,1.11,1.12

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

Modified Files:
	AtRulePage.java CssFouffa.java CssParseException.java 
	CssPropertyFactory.java CssValidatorListener.java Frame.java 
Log Message:
genericity + updated code to 5.0 stds

Index: Frame.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/Frame.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Frame.java	14 Feb 2009 09:05:03 -0000	1.11
+++ Frame.java	29 Aug 2011 07:21:00 -0000	1.12
@@ -16,7 +16,7 @@
  */
 public class Frame {
 
-    public  ApplContext ac;
+    public ApplContext ac;
     private Errors errors;
     private Warnings warnings;
     private CssFouffa cssFouffa;
@@ -31,10 +31,10 @@
      * @param sourceFile The name of the source file.
      */
     public Frame(CssFouffa cssFouffa, String sourceFile, int warningLevel) {
-    	this.sourceFile = sourceFile;
-    	this.cssFouffa = cssFouffa;
-    	errors = new Errors();
-    	warnings = new Warnings(warningLevel);
+        this.sourceFile = sourceFile;
+        this.cssFouffa = cssFouffa;
+        errors = new Errors();
+        warnings = new Warnings(warningLevel);
     }
 
     /**
@@ -45,10 +45,9 @@
      * @param beginLine  The begin line
      */
     public Frame(CssFouffa cssFouffa, String sourceFile, int beginLine,
-		 int warningLevel)
-    {
-    	this(cssFouffa, sourceFile, warningLevel);
-    	line = beginLine;
+                 int warningLevel) {
+        this(cssFouffa, sourceFile, warningLevel);
+        line = beginLine;
     }
 
     /**
@@ -57,16 +56,16 @@
      * @param error The new error.
      */
     public void addError(CssError error) {
-	error.sourceFile = getSourceFile();
-	error.line = getLine();
-	errors.addError(error);
+        error.sourceFile = getSourceFile();
+        error.line = getLine();
+        errors.addError(error);
     }
 
     /**
      * Returns all errors.
      */
     public Errors getErrors() {
-	return errors;
+        return errors;
     }
 
     /**
@@ -74,11 +73,11 @@
      *
      * @param warningMessage the warning message
      *                       (see org.w3c.css.util.Messages.properties).
-     * @see                  org.w3c.css.util.Warning
+     * @see org.w3c.css.util.Warning
      */
     public void addWarning(String warningMessage) {
-	warnings.addWarning(new Warning(getSourceFile(), getLine(),
-					warningMessage, 0, ac));
+        warnings.addWarning(new Warning(getSourceFile(), getLine(),
+                warningMessage, 0, ac));
     }
 
     /**
@@ -87,12 +86,12 @@
      * @param warningMessage the warning message
      *                       (see org.w3c.css.util.Messages.properties).
      * @param message        An add-on message.
-     * @see                  org.w3c.css.util.Warning
+     * @see org.w3c.css.util.Warning
      */
     public void addWarning(String warningMessage, String message) {
-	warnings.addWarning(new Warning(getSourceFile(), getLine(),
-					warningMessage, 0, 
-					new String[] { message }, ac));
+        warnings.addWarning(new Warning(getSourceFile(), getLine(),
+                warningMessage, 0,
+                new String[]{message}, ac));
     }
 
     /**
@@ -101,40 +100,40 @@
      * @param warningMessage the warning message
      *                       (see org.w3c.css.util.Messages.properties).
      * @param messages       Some add-on messages.
-     * @see                  org.w3c.css.util.Warning
+     * @see org.w3c.css.util.Warning
      */
     public void addWarning(String warningMessage, String[] messages) {
-	warnings.addWarning(new Warning(getSourceFile(), getLine(),
-					warningMessage, 0, messages, ac));
+        warnings.addWarning(new Warning(getSourceFile(), getLine(),
+                warningMessage, 0, messages, ac));
     }
 
     /**
      * Get all warnings.
      */
     public Warnings getWarnings() {
-	return warnings;
+        return warnings;
     }
 
     /**
      * Get the name of the source file.
      */
     public String getSourceFile() {
-	return sourceFile;
+        return sourceFile;
     }
 
     /**
      * Get the begin line.
      */
     public int getBeginLine() {
-	return line;
+        return line;
     }
 
     /**
      * Get the current line.
      */
     public int getLine() {
-	//return line; //+ cssFouffa.token.beginLine;
-	return line + cssFouffa.token.beginLine;
+        //return line; //+ cssFouffa.token.beginLine;
+        return line + cssFouffa.token.beginLine;
     }
 
     /**
@@ -143,8 +142,8 @@
      * @param frame The other frame for merging.
      */
     public void join(Frame frame) {
-	errors.addErrors(frame.errors);
-	warnings.addWarnings(frame.warnings);
+        errors.addErrors(frame.errors);
+        warnings.addWarnings(frame.warnings);
     }
 }
 

Index: CssPropertyFactory.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssPropertyFactory.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- CssPropertyFactory.java	12 Jan 2011 15:01:56 -0000	1.25
+++ CssPropertyFactory.java	29 Aug 2011 07:21:00 -0000	1.26
@@ -11,8 +11,8 @@
 import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.WarningParamException;
 import org.w3c.css.util.Utf8Properties;
+import org.w3c.css.util.WarningParamException;
 import org.w3c.css.values.CssExpression;
 import org.w3c.css.values.CssIdent;
 
@@ -23,14 +23,14 @@
 import java.util.Vector;
 
 /**
- * @version $Revision$
  * @author Philippe Le Hegaret
+ * @version $Revision$
  */
 public class CssPropertyFactory implements Cloneable {
 
     // all recognized properties are here.
     private Utf8Properties properties;
-	
+
     //all used profiles are here (in the priority order)
     private static String[] SORTEDPROFILES = PropertiesLoader.getProfiles();
 
@@ -40,12 +40,12 @@
     // private String usermedium;
 
     public CssPropertyFactory getClone() {
-	try {
-	    return (CssPropertyFactory) clone();
-	} catch (CloneNotSupportedException ex) {
-	    ex.printStackTrace();
-	    return null;
-	}
+        try {
+            return (CssPropertyFactory) clone();
+        } catch (CloneNotSupportedException ex) {
+            ex.printStackTrace();
+            return null;
+        }
     }
 
     /**
@@ -63,31 +63,30 @@
      * finally { try { if (f_all != null) f_all.close(); } catch (Exception e) {
      * e.printStackTrace(); } // ignore } }
      */
-
     public CssPropertyFactory(String profile) {
-	properties = PropertiesLoader.getProfile(profile);
-	// It's not good to have null properties :-/
-	if (properties == null) {
-	    throw new NullPointerException();
-	}
+        properties = PropertiesLoader.getProfile(profile);
+        // It's not good to have null properties :-/
+        if (properties == null) {
+            throw new NullPointerException();
+        }
     }
 
     public String getProperty(String name) {
-	return properties.getProperty(name);
+        return properties.getProperty(name);
     }
 
     private Vector<String> getVector(String media) {
-	Vector<String> list = new Vector<String>(4);
-	String medium = new String();
-	StringTokenizer tok = new StringTokenizer(media, ",");
+        Vector<String> list = new Vector<String>(4);
+        String medium = new String();
+        StringTokenizer tok = new StringTokenizer(media, ",");
 
-	while (tok.hasMoreTokens()) {
-	    medium = tok.nextToken();
-	    medium = medium.trim();
-	    list.addElement(medium);
-	}
+        while (tok.hasMoreTokens()) {
+            medium = tok.nextToken();
+            medium = medium.trim();
+            list.addElement(medium);
+        }
 
-	return list;
+        return list;
     }
 
     // public void setUserMedium(String usermedium) {
@@ -101,176 +100,173 @@
     // }
     // }
     public synchronized CssProperty createMediaFeature(ApplContext ac, AtRule atRule, String property,
-						       CssExpression expression) throws Exception {
-	// String result = "ok";
-	String media = atRule.toString();
-	int pos = -1;
-	int pos2 = media.toUpperCase().indexOf("AND");
-
-	if (pos2 == -1) {
-	    pos2 = media.length();
-	}
+                                                       CssExpression expression) throws Exception {
+        // String result = "ok";
+        String media = atRule.toString();
+        String upmedia = media.toUpperCase();
+        int pos = -1;
+        int pos2 = media.toUpperCase().indexOf("AND");
 
-	if (media.toUpperCase().indexOf("NOT") != -1) {
-	    pos = media.toUpperCase().indexOf("NOT");
-	    media = media.substring(pos + 4, pos2);
-	} else if (media.toUpperCase().indexOf("ONLY") != -1) {
-	    pos = media.toUpperCase().indexOf("ONLY");
-	    media = media.substring(pos + 4, pos2);
-	} else {
-	    pos = media.indexOf(" ");
-	    media = media.substring(pos + 1, pos2);
-	}
+        if (pos2 == -1) {
+            pos2 = media.length();
+        }
+        pos = upmedia.indexOf("NOT");
+        if (pos != -1) {
+            media = media.substring(pos + 4, pos2);
+        } else if ((pos = upmedia.indexOf("ONLY")) != -1) {
+            media = media.substring(pos + 4, pos2);
+        } else {
+            pos = media.indexOf(" ");
+            media = media.substring(pos + 1, pos2);
+        }
 
-	media = media.trim();
+        media = media.trim();
 
-	String classname = properties.getProperty("mediafeature" + "." + property);
+        String classname = properties.getProperty("mediafeature" + "." + property);
 
-	if (classname == null) {
-	    if (atRule instanceof AtRuleMedia && (!media.equals("all"))) {
-		// I don't know this property
-		throw new InvalidParamException("noexistence-media", property, media, ac);
-		// ac.getFrame().addWarning("noexistence-media", property);
-		// classname = allprops.getProperty(property);
-	    } else {
-		// I don't know this property
-		throw new InvalidParamException("noexistence", property, media, ac);
-	    }
-	}
+        if (classname == null) {
+            if (atRule instanceof AtRuleMedia && (!media.equals("all"))) {
+                // I don't know this property
+                throw new InvalidParamException("noexistence-media", property, media, ac);
+                // ac.getFrame().addWarning("noexistence-media", property);
+                // classname = allprops.getProperty(property);
+            } else {
+                // I don't know this property
+                throw new InvalidParamException("noexistence", property, media, ac);
+            }
+        }
 
-	try {
-	    // create an instance of your property class
-	    Class expressionclass = CssExpression.class;
-	    if (expression != null) {
-		expressionclass = expression.getClass();
-	    }
-	    // Maybe it will be necessary to add the check parameter as for
-	    // create property, so... FIXME
-	    Class[] parametersType = { ac.getClass(), expressionclass };
-	    Constructor constructor = Class.forName(classname).getConstructor(parametersType);
-	    Object[] parameters = { ac, expression };
-	    // invoke the constructor
-	    return (CssProperty) constructor.newInstance(parameters);
-	} catch (InvocationTargetException e) {
-	    // catch InvalidParamException
-	    InvocationTargetException iv = e;
-	    Exception ex = (Exception) iv.getTargetException();
-	    throw ex;
-	}
+        try {
+            // create an instance of your property class
+            Class expressionclass = CssExpression.class;
+            if (expression != null) {
+                expressionclass = expression.getClass();
+            }
+            // Maybe it will be necessary to add the check parameter as for
+            // create property, so... FIXME
+            Class[] parametersType = {ac.getClass(), expressionclass};
+            Constructor constructor = Class.forName(classname).getConstructor(parametersType);
+            Object[] parameters = {ac, expression};
+            // invoke the constructor
+            return (CssProperty) constructor.newInstance(parameters);
+        } catch (InvocationTargetException e) {
+            // catch InvalidParamException
+            Exception ex = (Exception) e.getTargetException();
+            throw ex;
+        }
 
     }
 
     public synchronized CssProperty createProperty(ApplContext ac, AtRule atRule, String property,
-						   CssExpression expression) throws Exception {
-	String classname = null;
-	String media = atRule.toString();
-	int pos = -1;
-	String upperMedia = media.toUpperCase();
-	int pos2 = upperMedia.indexOf("AND ");
+                                                   CssExpression expression) throws Exception {
+        String classname = null;
+        String media = atRule.toString();
+        int pos = -1;
+        String upperMedia = media.toUpperCase();
+        int pos2 = upperMedia.indexOf("AND ");
 
-	if (pos2 == -1) {
-	    pos2 = media.length();
-	}
+        if (pos2 == -1) {
+            pos2 = media.length();
+        }
 
-	if ((pos = upperMedia.indexOf("NOT")) != -1) {
-	    media = media.substring(pos + 4, pos2);
-	} else if ((pos = upperMedia.indexOf("ONLY")) != -1) {
-	    media = media.substring(pos + 4, pos2);
-	} else {
-	    pos = media.indexOf(' ');
-	    media = media.substring(pos + 1, pos2);
-	}
+        if ((pos = upperMedia.indexOf("NOT")) != -1) {
+            media = media.substring(pos + 4, pos2);
+        } else if ((pos = upperMedia.indexOf("ONLY")) != -1) {
+            media = media.substring(pos + 4, pos2);
+        } else {
+            pos = media.indexOf(' ');
+            media = media.substring(pos + 1, pos2);
+        }
 
-	media = media.trim();
+        media = media.trim();
 
-	classname = setClassName(atRule, media, ac, property);
-		
-	// the property does not exist in this profile
-	// this is an error... or a warning if it exists in another profile
-	if (classname == null) {
+        classname = setClassName(atRule, media, ac, property);
+
+        // the property does not exist in this profile
+        // this is an error... or a warning if it exists in another profile
+        if (classname == null) {
             if (ac.getTreatVendorExtensionsAsWarnings() &&
-                isVendorExtension(property)) {
+                    isVendorExtension(property)) {
                 throw new WarningParamException("vendor-extension", property);
             }
-	    ArrayList<String> pfsOk = new ArrayList<String>();
-			
-	    for (int i=0; i<SORTEDPROFILES.length; ++i) {
-		String p = String.valueOf(SORTEDPROFILES[i]);
-		if (!p.equals(ac.getCssVersion()) && PropertiesLoader.getProfile(p).containsKey(property)) {
-		    pfsOk.add(p);
-		}
-	    }
-			
-	    if (pfsOk.size() > 0) {
-		/*
-		// This should be uncommented when no-profile in enabled
-		if (ac.getProfile().equals("none")) {
-		// the last one should be the best one to use
-		String	pf = (String) pfsOk.get(pfsOk.size()-1),
-		old_pf = ac.getCssVersion();
-		ac.setCssVersion(pf);
-		ac.getFrame().addWarning("noexistence", new String[] { property, ac.getMsg().getString(old_pf), pfsOk.toString() });
-		classname = setClassName(atRule, media, ac, property);
-		ac.setCssVersion(old_pf);
-		}
-		else
-		*/
-		throw new InvalidParamException("noexistence", new String[] { property, ac.getMsg().getString(ac.getCssVersion()), pfsOk.toString() }, ac);
-	    } else {
-		throw new InvalidParamException("noexistence-at-all", property, ac);
-	    }
-	}
+            ArrayList<String> pfsOk = new ArrayList<String>();
 
-	CssIdent initial = new CssIdent("initial");
+            for (int i = 0; i < SORTEDPROFILES.length; ++i) {
+                String p = String.valueOf(SORTEDPROFILES[i]);
+                if (!p.equals(ac.getCssVersion()) && PropertiesLoader.getProfile(p).containsKey(property)) {
+                    pfsOk.add(p);
+                }
+            }
 
-	try {
-	    if (expression.getValue().equals(initial) && ac.getCssVersion().equals("css3")) {
-		// create an instance of your property class
-		Class[] parametersType = {};
-		Constructor constructor = Class.forName(classname).getConstructor(parametersType);
-		Object[] parameters = {};
-		// invoke the constructor
-		return (CssProperty) constructor.newInstance(parameters);
-	    } else {
-		// create an instance of your property class
-		Class[] parametersType = { ac.getClass(), expression.getClass(), boolean.class };
-		Constructor constructor = Class.forName(classname).getConstructor(parametersType);
-		Object[] parameters = { ac, expression, Boolean.TRUE};
-		// invoke the constructor
-		return (CssProperty) constructor.newInstance(parameters);
-			
-	    }
-	} catch (InvocationTargetException e) {
-	    // catch InvalidParamException
-	    InvocationTargetException iv = e;
-	    Exception ex = (Exception) iv.getTargetException();
-	    throw ex;
-	}
+            if (pfsOk.size() > 0) {
+                /*
+            // This should be uncommented when no-profile in enabled
+            if (ac.getProfile().equals("none")) {
+            // the last one should be the best one to use
+            String	pf = (String) pfsOk.get(pfsOk.size()-1),
+            old_pf = ac.getCssVersion();
+            ac.setCssVersion(pf);
+            ac.getFrame().addWarning("noexistence", new String[] { property, ac.getMsg().getString(old_pf), pfsOk.toString() });
+            classname = setClassName(atRule, media, ac, property);
+            ac.setCssVersion(old_pf);
+            }
+            else
+            */
+                throw new InvalidParamException("noexistence", new String[]{property, ac.getMsg().getString(ac.getCssVersion()), pfsOk.toString()}, ac);
+            } else {
+                throw new InvalidParamException("noexistence-at-all", property, ac);
+            }
+        }
+
+        CssIdent initial = new CssIdent("initial");
+
+        try {
+            if (expression.getValue().equals(initial) && ac.getCssVersion().equals("css3")) {
+                // create an instance of your property class
+                Class[] parametersType = {};
+                Constructor constructor = Class.forName(classname).getConstructor(parametersType);
+                Object[] parameters = {};
+                // invoke the constructor
+                return (CssProperty) constructor.newInstance(parameters);
+            } else {
+                // create an instance of your property class
+                Class[] parametersType = {ac.getClass(), expression.getClass(), boolean.class};
+                Constructor constructor = Class.forName(classname).getConstructor(parametersType);
+                Object[] parameters = {ac, expression, Boolean.TRUE};
+                // invoke the constructor
+                return (CssProperty) constructor.newInstance(parameters);
+
+            }
+        } catch (InvocationTargetException e) {
+            // catch InvalidParamException
+            Exception ex = (Exception) e.getTargetException();
+            throw ex;
+        }
     }
 
     private String setClassName(AtRule atRule, String media, ApplContext ac, String property) {
-	String className;
-	Vector<String> list = new Vector<String>(getVector(media));
-	if (atRule instanceof AtRuleMedia) {
-	    className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty(property);
-	    // a list of media has been specified
-	    if (className != null && !media.equals("all")) {
-		String propMedia = PropertiesLoader.mediaProperties.getProperty(property);
-		for (int i = 0; i < list.size(); i++) {
-		    String medium = list.elementAt(i);
-		    if (propMedia.indexOf(medium.toLowerCase()) == -1 && !propMedia.equals("all")) {
-			ac.getFrame().addWarning("noexistence-media", new String[] { property, medium + " (" + propMedia + ")" });
-		    }
-		}
-	    }
-	} else {
-	    className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty("@" + atRule.keyword() + "." + property);
-	}
-	return className;
+        String className;
+        Vector<String> list = new Vector<String>(getVector(media));
+        if (atRule instanceof AtRuleMedia) {
+            className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty(property);
+            // a list of media has been specified
+            if (className != null && !media.equals("all")) {
+                String propMedia = PropertiesLoader.mediaProperties.getProperty(property);
+                for (int i = 0; i < list.size(); i++) {
+                    String medium = list.elementAt(i);
+                    if (propMedia.indexOf(medium.toLowerCase()) == -1 && !propMedia.equals("all")) {
+                        ac.getFrame().addWarning("noexistence-media", new String[]{property, medium + " (" + propMedia + ")"});
+                    }
+                }
+            }
+        } else {
+            className = PropertiesLoader.getProfile(ac.getCssVersion()).getProperty("@" + atRule.keyword() + "." + property);
+        }
+        return className;
     }
 
     private boolean isVendorExtension(String property) {
-      return property.length() > 0 &&
-          (property.charAt(0) == '-' || property.charAt(0) == '_');
+        return property.length() > 0 &&
+                (property.charAt(0) == '-' || property.charAt(0) == '_');
     }
 }

Index: AtRulePage.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/AtRulePage.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- AtRulePage.java	14 Sep 2005 15:14:18 -0000	1.4
+++ AtRulePage.java	29 Aug 2011 07:21:00 -0000	1.5
@@ -17,13 +17,13 @@
 /**
  * This class manages all media defines by CSS2
  *
+ * @author Philippe Le H�garet
  * @version $Revision$
- * @author  Philippe Le H�garet
  */
 public class AtRulePage extends AtRule {
 
     static final String[] pseudo = {
-	":left", ":right", ":first"
+            ":left", ":right", ":first"
     };
 
     String name;
@@ -34,7 +34,7 @@
      * Returns the at rule keyword
      */
     public String keyword() {
-	return "page";
+        return "page";
     }
 
     /**
@@ -43,122 +43,131 @@
      * or a random name without semi-colon at the beginning
      */
     public AtRulePage setName(String name, ApplContext ac)
-	     throws InvalidParamException {
-	if (name.charAt(0) == ':') {
-	    for (int i = 0; i < pseudo.length; i++) {
-		if (name.equals(pseudo[i])) {
-		    this.name = pseudo[i];
-		    return this;
-		}
-	    }
-	    throw new InvalidParamException("page", name, ac);
-	} else {
-	    this.name = name;
-	}
+            throws InvalidParamException {
+        if (name.charAt(0) == ':') {
+            for (int i = 0; i < pseudo.length; i++) {
+                if (name.equals(pseudo[i])) {
+                    this.name = pseudo[i];
+                    return this;
+                }
+            }
+            throw new InvalidParamException("page", name, ac);
+        } else {
+            this.name = name;
+        }
 
-	return this;
+        return this;
     }
 
     public AtRulePage setIdent(String ident) {
-	this.ident = ident;
-	return this;
+        this.ident = ident;
+        return this;
     }
 
     public String getIdent() {
-	return ident;
+        return ident;
     }
 
     /**
      * Return true if atRule is exactly the same as current
      */
     public boolean equals(Object atRule) {
-	if (atRule instanceof AtRulePage) {
-	    AtRulePage other = (AtRulePage) atRule;
-	    boolean res = true;
-	    if ((name != null) && (other.name != null)) {
-		res = res &&  name.equals(other.name);
-	    } else {
-		if ((name != null) || (other.name != null)) {
-		    return false;
-		}
-	    }
-	    if ((ident != null) && (other.ident != null)) {
-		res = res &&  ident.equals(((AtRulePage) atRule).ident);
-	    } else {
-		if ((ident != null) || (other.ident != null)) {
-		    return false;
-		}
-	    }
-	    return res;
-	} else {
-	    return false;
-	}
+        AtRulePage other;
+        try {
+            other = (AtRulePage) atRule;
+        } catch (ClassCastException cce) {
+            // not an AtRulePage, fail
+            return false;
+        }
+        if ((name != null) && (other.name != null)) {
+            if (!name.equals(other.name)) {
+                return false;
+            }
+        } else {
+            if ((name != null) || (other.name != null)) {
+                return false;
+            }
+        }
+        if ((ident != null) && (other.ident != null)) {
+            return ident.equals(((AtRulePage) atRule).ident);
+        } else {
+            if ((ident != null) || (other.ident != null)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     /**
      * The second must be exactly the same of this one
      */
     public boolean canApply(AtRule atRule) {
-	if (atRule instanceof AtRulePage) {
-	    AtRulePage other = (AtRulePage) atRule;
-	    boolean res = true;
-	    if ((name != null) && (other.name != null)) {
-		res = res &&  name.equals(other.name);
-	    } else {
-		if ((name != null) || (other.name != null)) {
-		    return false;
-		}
-	    }
-	    if ((ident != null) && (other.ident != null)) {
-		res = res &&  ident.equals(((AtRulePage) atRule).ident);
-	    } else {
-		if ((ident != null) || (other.ident != null)) {
-		    return false;
-		}
-	    }
-	    return res;
-	} else {
-	    return false;
-	}
+        AtRulePage other;
+        try {
+            other = (AtRulePage) atRule;
+        } catch (ClassCastException cce) {
+            // not an AtRulePage, fail
+            return false;
+        }
+        if ((name != null) && (other.name != null)) {
+            if (!name.equals(other.name)) {
+                return false;
+            }
+        } else {
+            if ((name != null) || (other.name != null)) {
+                return false;
+            }
+        }
+        if ((ident != null) && (other.ident != null)) {
+            return ident.equals(((AtRulePage) atRule).ident);
+        } else {
+            if ((ident != null) || (other.ident != null)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     /**
      * The second must only match this one
      */
     public boolean canMatched(AtRule atRule) {
-	if (atRule instanceof AtRulePage) {
-	    boolean res = true;
-	    if (name != null) {
-		res = res &&  name.equals(((AtRulePage) atRule).name);
-	    }
-	    if (ident != null) {
-		res = res &&  ident.equals(((AtRulePage) atRule).ident);
-	    }
-	    return res;
-	} else {
-	    return false;
-	}
+        AtRulePage atRulePage;
+        try {
+            atRulePage = (AtRulePage) atRule;
+        } catch (ClassCastException cce) {
+            // not an AtRulePage, fail
+            return false;
+        }
+        if ((name != null) && !name.equals(atRulePage.name)) {
+            return false;
+        }
+        if ((ident != null) && !ident.equals(atRulePage.ident)) {
+            return false;
+        }
+        return true;
     }
 
 
     public String getName() {
-	return name;
+        return name;
     }
 
     /**
      * Returns a string representation of the object.
      */
     public String toString() {
-	String ret = "@" + keyword() ;
-	if (ident!=null) {
-	    ret += " " + ident;
-	    if (name!=null) {
-		ret += name;
-	    }
-	} else if (name != null) {
-	    ret += " " + name;
-	}
-	return ret;
+        StringBuilder ret = new StringBuilder();
+        ret.append('@').append(keyword());
+        if (ident != null) {
+            ret.append(' ').append(ident);
+            if (name != null) {
+                ret.append(name);
+            }
+        } else if (name != null) {
+            ret.append(' ').append(name);
+        }
+        return ret.toString();
     }
 
 }

Index: CssParseException.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssParseException.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssParseException.java	14 Sep 2005 15:14:18 -0000	1.5
+++ CssParseException.java	29 Aug 2011 07:21:00 -0000	1.6
@@ -7,11 +7,11 @@
 
 package org.w3c.css.parser;
 
-import java.util.Vector;
-
 import org.w3c.css.parser.analyzer.ParseException;
 import org.w3c.css.values.CssExpression;
 
+import java.util.ArrayList;
+
 /**
  * @version $Revision$
  */
@@ -20,7 +20,7 @@
     /**
      * The list of context when the error appears
      */
-    Vector contexts;
+    ArrayList<CssSelectors> contexts;
 
     /**
      * the property name
@@ -48,32 +48,32 @@
      * Create a new CssParseException
      */
     public CssParseException(Exception exc) {
-	parseException = exc;
-	if (parseException instanceof ParseException) {
-	    ParseException e = (ParseException) exc;
-	    error = (e.currentToken != null
-		     && e.expectedTokenSequences != null
-		     && e.tokenImage != null);
-	}
+        parseException = exc;
+        if (parseException instanceof ParseException) {
+            ParseException e = (ParseException) exc;
+            error = (e.currentToken != null
+                    && e.expectedTokenSequences != null
+                    && e.tokenImage != null);
+        }
     }
 
     public Exception getException() {
-	return parseException;
+        return parseException;
     }
 
     public boolean isParseException() {
-	return (parseException instanceof ParseException);
+        return (parseException instanceof ParseException);
     }
 
     /**
      * Get the exception message
      */
     public String getMessage() {
-	if (!error) {
-	    return parseException.getMessage();
-	} else {
-	    return null;
-	}
+        if (!error) {
+            return parseException.getMessage();
+        } else {
+            return null;
+        }
     }
 
     /**
@@ -81,7 +81,7 @@
      *
      * @param contexts the new value for the attribute
      */
-    public void setContexts(Vector contexts) {
+    public void setContexts(ArrayList<CssSelectors> contexts) {
         this.contexts = contexts;
     }
 
@@ -90,7 +90,7 @@
      *
      * @return the value of the attribute
      */
-    public Vector getContexts() {
+    public ArrayList<CssSelectors> getContexts() {
         return contexts;
     }
 

Index: CssFouffa.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssFouffa.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- CssFouffa.java	5 Jan 2010 13:49:33 -0000	1.53
+++ CssFouffa.java	29 Aug 2011 07:21:00 -0000	1.54
@@ -21,6 +21,8 @@
 import org.w3c.css.util.HTTPURL;
 import org.w3c.css.util.InvalidParamException;
 import org.w3c.css.util.Util;
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
 import org.w3c.css.values.CssExpression;
 
 import java.io.FileNotFoundException;
@@ -31,6 +33,7 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.Charset;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -56,7 +59,7 @@
     CssPropertyFactory properties = null;
 
     // all listeners
-    Vector<CssValidatorListener> listeners;
+    ArrayList<CssValidatorListener> listeners;
 
     // all errors
     Errors errors;
@@ -64,7 +67,7 @@
     // origin of the style sheet
     int origin;
 
-    Vector<String> visited = null;
+    ArrayList<String> visited = null;
 
     /**
      * Create a new CssFouffa with a data input and a begin line number.
@@ -127,7 +130,7 @@
         }
 
         properties = new CssPropertyFactory(profile);
-        listeners = new Vector<CssValidatorListener>();
+        listeners = new ArrayList<CssValidatorListener>();
     }
 
     /**
@@ -173,13 +176,13 @@
      * Create a new CssFouffa. Used by handleImport.
      *
      * @param in        The source input stream (use for data input, errors,
-     *       warnings and import)
+     *                  warnings and import)
      * @param listeners Works with this listeners
      * @throws IOException if an I/O error occurs.
      */
     private CssFouffa(ApplContext ac, InputStream in, URL url,
-                      Vector<CssValidatorListener> listeners,
-                      Vector<String> urlvisited,
+                      ArrayList<CssValidatorListener> listeners,
+                      ArrayList<String> urlvisited,
                       CssPropertyFactory cssfactory, boolean mode)
             throws IOException {
         this(ac, in, ac.getCharsetForURL(url), url, 0);
@@ -324,7 +327,7 @@
      * @see org.w3c.css.parser.CssValidatorListener
      */
     public final void addListener(CssValidatorListener listener) {
-        listeners.addElement(listener);
+        listeners.add(listener);
     }
 
     /**
@@ -334,7 +337,7 @@
      * @see org.w3c.css.parser.CssValidatorListener
      */
     public final void removeListener(CssValidatorListener listener) {
-        listeners.removeElement(listener);
+        listeners.remove(listener);
     }
 
     /**
@@ -367,13 +370,12 @@
             throw (ne);
         }
 
+        Errors errors = ac.getFrame().getErrors();
+        Warnings warnings = ac.getFrame().getWarnings();
         // That's all folks, notify all errors and warnings
-        for (Enumeration<CssValidatorListener> e = listeners.elements();
-             e.hasMoreElements();) {
-            CssValidatorListener listener;
-            listener = e.nextElement();
-            listener.notifyErrors(ac.getFrame().getErrors());
-            listener.notifyWarnings(ac.getFrame().getWarnings());
+        for (CssValidatorListener listener : listeners) {
+            listener.notifyErrors(errors);
+            listener.notifyWarnings(warnings);
         }
     }
 
@@ -419,7 +421,7 @@
             String surl = importedURL.toString();
 
             if (visited == null) {
-                visited = new Vector<String>(2);
+                visited = new ArrayList<String>();
             } else {
                 // check that we didn't already got this URL, or that the
                 // number of imports is not exploding
@@ -437,8 +439,8 @@
                     return;
                 }
             }
-            Vector<String> newVisited = new Vector<String>(visited);
-            newVisited.addElement(surl);
+            ArrayList<String> newVisited = new ArrayList<String>(visited);
+            newVisited.add(surl);
 
             if (Util.importSecurity) {
                 throw new FileNotFoundException("[SECURITY] You can't " +
@@ -497,10 +499,9 @@
      */
     public void handleAtRule(String ident, String string) {
         if (mode) {
-            Enumeration<CssValidatorListener> e = listeners.elements();
-            while (e.hasMoreElements()) {
-                CssValidatorListener listener = e.nextElement();
+            for (CssValidatorListener listener : listeners) {
                 listener.handleAtRule(ac, ident, string);
+
             }
         } else {
             if (!Util.noErrorTrace) {
@@ -583,7 +584,7 @@
     public void parseDeclarations(CssSelectors context) {
         // here we have an example for reusing the parser.
         try {
-            Vector properties = declarations();
+            ArrayList<CssProperty> properties = declarations();
 
             if (properties != null && properties.size() != 0) {
                 handleRule(context, properties);
@@ -600,10 +601,12 @@
         }
 
         if (!Util.noErrorTrace) {
-            for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-                CssValidatorListener listener = e.nextElement();
-                listener.notifyErrors(ac.getFrame().getErrors());
-                listener.notifyWarnings(ac.getFrame().getWarnings());
+            Errors errors = ac.getFrame().getErrors();
+            Warnings warnings = ac.getFrame().getWarnings();
+
+            for (CssValidatorListener listener : listeners) {
+                listener.notifyErrors(errors);
+                listener.notifyWarnings(warnings);
             }
         }
     }
@@ -616,9 +619,8 @@
      * added to the storage for the output
      */
     public void newAtRule(AtRule atRule) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements();
-             e.hasMoreElements();) {
-            e.nextElement().newAtRule(atRule);
+        for (CssValidatorListener listener : listeners) {
+            listener.newAtRule(atRule);
         }
     }
 
@@ -629,10 +631,10 @@
      * @charset rule that has been found by the parser
      */
     public void addCharSet(String charset) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements();
-             e.hasMoreElements();) {
-            e.nextElement().addCharSet(charset);
+        for (CssValidatorListener listener : listeners) {
+            listener.addCharSet(charset);
         }
+
         Charset c = null;
         try {
             c = Charset.forName(charset);
@@ -662,9 +664,8 @@
      * in it.
      */
     public void endOfAtRule() {
-        for (Enumeration<CssValidatorListener> e = listeners.elements();
-             e.hasMoreElements();) {
-            e.nextElement().endOfAtRule();
+        for (CssValidatorListener listener : listeners) {
+            listener.endOfAtRule();
         }
     }
 
@@ -674,9 +675,8 @@
      * @param important true if the rule was declared important in the stylesheet
      */
     public void setImportant(boolean important) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements();
-             e.hasMoreElements();) {
-            e.nextElement().setImportant(important);
+        for (CssValidatorListener listener : listeners) {
+            listener.setImportant(important);
         }
     }
 
@@ -686,9 +686,9 @@
      * @param selectors a list of one or more selectors to be added to the output
      *                  stylesheet
      */
-    public void setSelectorList(Vector selectors) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().setSelectorList(selectors);
+    public void setSelectorList(ArrayList<CssSelectors> selectors) {
+        for (CssValidatorListener listener : listeners) {
+            listener.setSelectorList(selectors);
         }
     }
 
@@ -699,9 +699,9 @@
      *                   stylesheet (for example: all properties in an
      * @rule)
      */
-    public void addProperty(Vector properties) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().setProperty(properties);
+    public void addProperty(ArrayList<CssProperty> properties) {
+        for (CssValidatorListener listener : listeners) {
+            listener.setProperty(properties);
         }
     }
 
@@ -710,8 +710,8 @@
      * been read by the parser
      */
     public void endOfRule() {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().endOfRule();
+        for (CssValidatorListener listener : listeners) {
+            listener.endOfRule();
         }
     }
 
@@ -721,8 +721,8 @@
      * won't appear on the screen
      */
     public void removeThisRule() {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().removeThisRule();
+        for (CssValidatorListener listener : listeners) {
+            listener.removeThisRule();
         }
     }
 
@@ -733,8 +733,8 @@
      * @rule from the memorystructure so that it won't appear on the screen
      */
     public void removeThisAtRule() {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().removeThisAtRule();
+        for (CssValidatorListener listener : listeners) {
+            listener.removeThisAtRule();
         }
     }
 
@@ -744,9 +744,9 @@
      * @param selector     the selector
      * @param declarations Properties to associate with contexts
      */
-    public void handleRule(CssSelectors selector, Vector declarations) {
-        for (Enumeration<CssValidatorListener> e = listeners.elements(); e.hasMoreElements();) {
-            e.nextElement().handleRule(ac, selector, declarations);
+    public void handleRule(CssSelectors selector, ArrayList<CssProperty> declarations) {
+        for (CssValidatorListener listener : listeners) {
+            listener.handleRule(ac, selector, declarations);
         }
     }
 

Index: CssValidatorListener.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssValidatorListener.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssValidatorListener.java	14 Sep 2005 15:14:18 -0000	1.6
+++ CssValidatorListener.java	29 Aug 2011 07:21:00 -0000	1.7
@@ -7,11 +7,12 @@
 
 package org.w3c.css.parser;
 
-import java.util.Vector;
-
+import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.Warnings;
 
+import java.util.ArrayList;
+
 /**
  * Implements this interface if you want to use the CSS1 parser.
  *
@@ -23,10 +24,10 @@
    * Adds a vector of properties to a selector.
    *
    * @param selector     the selector
-   * @param declarations Properties to associate with contexts
+   * @param properties Properties to associate with contexts
    */
   public void handleRule(ApplContext ac, CssSelectors selector,
-			 Vector declarations);
+			 ArrayList<CssProperty> properties);
 
   /**
    * Handles an at-rule.
@@ -45,14 +46,13 @@
    * @param value The string representation of this at-rule
    * @see         org.w3c.css.parser.analyzer.Couple
    */
-  public void handleAtRule(ApplContext ac, String ident, String string);
+  public void handleAtRule(ApplContext ac, String ident, String value);
 
   /**
    * Notify all errors
    *
    * @param errors All errors in the style sheet
    * @see CssError
-   * @see CssErrorDeclaration
    * @see CssErrorToken
    */
   public void notifyErrors(Errors errors);
@@ -73,9 +73,9 @@
 
     public void setImportant(boolean important);
 
-    public void setSelectorList(Vector selectors);
+    public void setSelectorList(ArrayList<CssSelectors> selectors);
 
-    public void setProperty(Vector properties);
+    public void setProperty(ArrayList<CssProperty> properties);
 
     public void endOfRule();
 

Received on Monday, 29 August 2011 07:21:05 UTC