W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2011

2002/css-validator/org/w3c/css/parser AtRuleMedia.java,1.14,1.15 AtRuleMediaCSS2.java,1.6,1.7

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 07 Oct 2011 09:33:21 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1RC6nx-0002U5-Ae@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/parser
In directory hutz:/tmp/cvs-serv9480/org/w3c/css/parser

Modified Files:
	AtRuleMedia.java AtRuleMediaCSS2.java 
Log Message:
spec version and @since info in properties, finished css3-color <http://www.w3.org/TR/2011/REC-css3-color-20110607/>

Index: AtRuleMedia.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/AtRuleMedia.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- AtRuleMedia.java	5 Jan 2010 13:49:33 -0000	1.14
+++ AtRuleMedia.java	7 Oct 2011 09:33:18 -0000	1.15
@@ -10,24 +10,24 @@
  */
 package org.w3c.css.parser;
 
-import java.util.Enumeration;
-import java.util.Vector;
-
 import org.w3c.css.properties.css.CssProperty;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
 
+import java.util.Enumeration;
+import java.util.Vector;
+
 /**
  * This class manages all media defines by CSS2
  *
+ * @author Philippe Le Hegaret
  * @version $Revision$
- * @author  Philippe Le Hegaret
  */
 public class AtRuleMedia extends AtRule {
 
     static final String[] mediaCSS3 = {
-	"all", "aural", "braille", "embossed", "handheld", "print",
-	"projection", "screen", "tty", "tv", "presentation", "atsc-tv"
+            "all", "aural", "braille", "embossed", "handheld", "print",
+            "projection", "screen", "tty", "tv", "presentation", "atsc-tv"
     };
 
     String restrictor = new String();
@@ -41,158 +41,158 @@
     /**
      * Adds a medium.
      *
-     * @exception InvalidParamException the medium doesn't exist
+     * @throws InvalidParamException the medium doesn't exist
      */
     public AtRuleMedia addMedia(String medium,
-				ApplContext ac) throws InvalidParamException {
+                                ApplContext ac) throws InvalidParamException {
 
-	//This medium didn't exist for CSS2
-	// if ((!cssversion.equals("css3")) && medium.equals("presentation")) {
-	// throw new InvalidParamException("media", medium, ac);
-	//}
+        //This medium didn't exist for CSS2
+        // if ((!cssversion.equals("css3")) && medium.equals("presentation")) {
+        // throw new InvalidParamException("media", medium, ac);
+        //}
 
-	for (int i = 0; i < mediaCSS3.length; i++) {
-	    if (medium.toLowerCase().equals(mediaCSS3[i])) {
-		media[i] = mediaCSS3[i];
+        for (int i = 0; i < mediaCSS3.length; i++) {
+            if (medium.toLowerCase().equals(mediaCSS3[i])) {
+                media[i] = mediaCSS3[i];
                 originalMedia[i] = medium;
-		empty = false;
-		return this;
-	    }
-	}
+                empty = false;
+                return this;
+            }
+        }
 
-	throw new InvalidParamException("media", medium, ac);
+        throw new InvalidParamException("media", medium, ac);
     }
 
     public void addMediaRestrictor(String restrictor, ApplContext ac) {
-	if (restrictor.toUpperCase().equals("ONLY") ||
-	    restrictor.toUpperCase().equals("NOT")) {
-	    this.restrictor = restrictor;
-	}
+        if (restrictor.toUpperCase().equals("ONLY") ||
+                restrictor.toUpperCase().equals("NOT")) {
+            this.restrictor = restrictor;
+        }
     }
 
     public void addMediaFeature(CssProperty prop) {
-	if (prop != null) {
-	    StringBuilder expression = new StringBuilder(prop.getPropertyName());
-	    String propval = prop.toString();
-	    if (propval != null) {
-		expression.append(" : ").append(propval);
-	    }
-	    mediafeatures.addElement(expression.toString());
-	}
+        if (prop != null) {
+            StringBuilder expression = new StringBuilder(prop.getPropertyName());
+            String propval = prop.toString();
+            if (propval != null) {
+                expression.append(" : ").append(propval);
+            }
+            mediafeatures.addElement(expression.toString());
+        }
     }
 
     /**
      * Returns the at rule keyword
      */
     public String keyword() {
-	return "media";
+        return "media";
     }
 
     public boolean isEmpty() {
-	return empty;
+        return empty;
     }
 
     /**
      * The second must be exactly the same of this one
      */
     public boolean canApply(AtRule atRule) {
-	if (atRule instanceof AtRuleMedia) {
-	    AtRuleMedia second = (AtRuleMedia) atRule;
+        if (atRule instanceof AtRuleMedia) {
+            AtRuleMedia second = (AtRuleMedia) atRule;
 
-	    for (int i = 0; i < media.length; i++) {
-		// strings are exactly the same so I don't have to use equals
-		if (media[i] != second.media[i]) {
-		    return false;
-		}
-	    }
-	    return true;
-	} else {
-	    return false;
-	}
+            for (int i = 0; i < media.length; i++) {
+                // strings are exactly the same so I don't have to use equals
+                if (media[i] != second.media[i]) {
+                    return false;
+                }
+            }
+            return true;
+        } else {
+            return false;
+        }
     }
 
     /**
      * The second must only match this one
      */
     public boolean canMatched(AtRule atRule) {
-	if (atRule instanceof AtRuleMedia) {
-	    AtRuleMedia second = (AtRuleMedia) atRule;
+        if (atRule instanceof AtRuleMedia) {
+            AtRuleMedia second = (AtRuleMedia) atRule;
 
-	    for (int i = 0; i < media.length; i++) {
-		// strings are exactly the same so I don't have to use equals
-		if (media[i] == second.media[i]) {
-		    return true;
-		}
-	    }
-	    return false;
-	} else {
-	    return false;
-	}
+            for (int i = 0; i < media.length; i++) {
+                // strings are exactly the same so I don't have to use equals
+                if (media[i] == second.media[i]) {
+                    return true;
+                }
+            }
+            return false;
+        } else {
+            return false;
+        }
     }
 
     public Enumeration elements() {
-	return new MediaEnumeration(this);
+        return new MediaEnumeration(this);
     }
 
     /**
      * Returns a string representation of the object.
      */
     public String toString() {
-	StringBuilder ret  = new StringBuilder();
+        StringBuilder ret = new StringBuilder();
 
-	ret.append('@');
-	ret.append(keyword());
-	ret.append(' ');
-	if (!restrictor.equals("")) {
-	    ret.append(restrictor);
-	    ret.append(' ');
-	}
-	boolean f = true;
-	for (int i = 0; i < media.length; i++) {
-	    if (originalMedia[i] != null) {
-		if (!f) {
-		    ret.append(',');
-		    ret.append(' ');
-		} else {
-		    f = false;
-		}
-		ret.append(originalMedia[i]);
-	    }
-	}
+        ret.append('@');
+        ret.append(keyword());
+        ret.append(' ');
+        if (!restrictor.equals("")) {
+            ret.append(restrictor);
+            ret.append(' ');
+        }
+        boolean f = true;
+        for (int i = 0; i < media.length; i++) {
+            if (originalMedia[i] != null) {
+                if (!f) {
+                    ret.append(',');
+                    ret.append(' ');
+                } else {
+                    f = false;
+                }
+                ret.append(originalMedia[i]);
+            }
+        }
 
-	for (int i = 0; i < mediafeatures.size(); i++) {
-	    ret.append(" and (");
-	    ret.append(mediafeatures.elementAt(i));
-	    ret.append(')');
-	}
-	return ret.toString();
+        for (int i = 0; i < mediafeatures.size(); i++) {
+            ret.append(" and (");
+            ret.append(mediafeatures.elementAt(i));
+            ret.append(')');
+        }
+        return ret.toString();
     }
 
     public String getValueString() {
-	StringBuilder ret  = new StringBuilder();
-	if (!restrictor.equals("")) {
-	    ret.append(restrictor);
-	    ret.append(' ');
-	}
-	boolean f = true;
-	for (int i = 0; i < media.length; i++) {
-	    if (originalMedia[i] != null) {
-		if (!f) {
-		    ret.append(',');
-		    ret.append(' ');
-		} else {
-		    f = false;
-		}
-		ret.append(originalMedia[i]);
-	    }
-	}
+        StringBuilder ret = new StringBuilder();
+        if (!restrictor.equals("")) {
+            ret.append(restrictor);
+            ret.append(' ');
+        }
+        boolean f = true;
+        for (int i = 0; i < media.length; i++) {
+            if (originalMedia[i] != null) {
+                if (!f) {
+                    ret.append(',');
+                    ret.append(' ');
+                } else {
+                    f = false;
+                }
+                ret.append(originalMedia[i]);
+            }
+        }
 
-	for (int i = 0; i < mediafeatures.size(); i++) {
-	    ret.append(" and (");
-	    ret.append(mediafeatures.elementAt(i));
-	    ret.append(')');
-	}
-	return ret.toString();
+        for (int i = 0; i < mediafeatures.size(); i++) {
+            ret.append(" and (");
+            ret.append(mediafeatures.elementAt(i));
+            ret.append(')');
+        }
+        return ret.toString();
     }
 }
 

Index: AtRuleMediaCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/AtRuleMediaCSS2.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- AtRuleMediaCSS2.java	5 Jan 2010 13:49:33 -0000	1.6
+++ AtRuleMediaCSS2.java	7 Oct 2011 09:33:19 -0000	1.7
@@ -95,7 +95,7 @@
 
             for (int i = 0; i < media.length; i++) {
                 // strings are exactly the same so I don't have to use equals
-                if (media[i] == second.media[i]) {
+                if ((media[i] != null) && (media[i] == second.media[i])) {
                     return true;
                 }
             }
Received on Friday, 7 October 2011 09:33:24 UTC

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