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

2002/css-validator/org/w3c/css/selectors/attributes AttributeBegin.java,1.4,1.5 AttributeExact.java,1.10,1.11 AttributeOneOf.java,1.5,1.6 AttributeStart.java,1.3,1.4 AttributeSubstr.java,1.3,1.4 AttributeSuffix.java,1.3,1.4

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 03 May 2012 09:04:11 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1SPrxL-0002vS-EK@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/selectors/attributes
In directory hutz:/tmp/cvs-serv11232/org/w3c/css/selectors/attributes

Modified Files:
	AttributeBegin.java AttributeExact.java AttributeOneOf.java 
	AttributeStart.java AttributeSubstr.java AttributeSuffix.java 
Log Message:
using stringbuilder...

Index: AttributeOneOf.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeOneOf.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- AttributeOneOf.java	14 May 2008 10:13:09 -0000	1.5
+++ AttributeOneOf.java	3 May 2012 09:04:08 -0000	1.6
@@ -14,142 +14,144 @@
  */
 public class AttributeOneOf extends AttributeSelector {
 
-    String   value;
-    String[] values;
+	String value;
+	String[] values;
 
-    public AttributeOneOf(String name, String value) {
-	setName(name);
-	this.value = value;
-	this.values = null;
-    }
+	public AttributeOneOf(String name, String value) {
+		setName(name);
+		this.value = value;
+		this.values = null;
+	}
 
-    /**
-     * @return Returns the value.
-     */
-    public String getValue() {
-        return value;
-    }
+	/**
+	 * @return Returns the value.
+	 */
+	public String getValue() {
+		return value;
+	}
 
-    /**
-     * @param value The value to set.
-     */
-    public void setValue(String value) {
-        this.value = value;
-	values = null;
-    }
+	/**
+	 * @param value The value to set.
+	 */
+	public void setValue(String value) {
+		this.value = value;
+		values = null;
+	}
 
-    public boolean canApply(Selector other) {
-	if (other instanceof AttributeAny) {
-	    // [lang~=fr][lang]
-	    // return [lang~=fr]
-	    return true;
-	} else if (other instanceof AttributeExact) {
-	    String exact = ((AttributeExact) other).getValue();
-	    // [lang~=fr][lang=fr]
-	    if(value.equals(exact)) {
-		// [lang~=fr][lang=fr]
-		return true;
-	    }
-	    // [lang~=en][lang=fr]
-	    return false;
-	} else if (other instanceof AttributeOneOf) {
-	    return true;
-	} else if (other instanceof AttributeBegin) {
-	    // [lang=~fr][lang|=fr]
-	    return true;
+	public boolean canApply(Selector other) {
+		if (other instanceof AttributeAny) {
+			// [lang~=fr][lang]
+			// return [lang~=fr]
+			return true;
+		} else if (other instanceof AttributeExact) {
+			String exact = ((AttributeExact) other).getValue();
+			// [lang~=fr][lang=fr]
+			if (value.equals(exact)) {
+				// [lang~=fr][lang=fr]
+				return true;
+			}
+			// [lang~=en][lang=fr]
+			return false;
+		} else if (other instanceof AttributeOneOf) {
+			return true;
+		} else if (other instanceof AttributeBegin) {
+			// [lang=~fr][lang|=fr]
+			return true;
+		}
+		return false;
 	}
-	return false;
-    }
 
-    public String toString() {
-	return "[" + getName() + "~=\"" + value + "\"]";
-    }
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("~=\"").append(value).append("\"]");
+		return sb.toString();
+	}
 
-    private String[] computeValues() {
-	values = value.split("\\s");
-	return values;
-    }
+	private String[] computeValues() {
+		values = value.split("\\s");
+		return values;
+	}
 
-    public void applyAttribute(ApplContext ac, AttributeSelector attr) {
-	String name = getName();
-	int i;
-	String val;
-	boolean ok;
+	public void applyAttribute(ApplContext ac, AttributeSelector attr) {
+		String name = getName();
+		int i;
+		String val;
+		boolean ok;
 
-	if (name.equals(attr.getName())) {
-	    if (values == null) {
-		computeValues();
-	    }
-	    if (attr instanceof AttributeExact) {
-		val = ((AttributeExact) attr).getValue();
-		ok = false;
-		for (i=0;!ok && i<values.length; i++) {
-		    ok = val.equals(values[i]);
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
-		}
-	    } else if (attr instanceof AttributeBegin) {
-		val = ((AttributeBegin) attr).getValue();
-		ok = false;
-		String pval = val + '-';
-		for (i=0;!ok && i<values.length; i++) {
-		    ok = values[i].equals(val) || values[i].startsWith(pval);
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
-		}
-	    } else if (attr instanceof AttributeStart) {
-		val = ((AttributeStart) attr).getValue();
-		ok = false;
-		for (i=0;!ok && i<values.length; i++) {
-		    ok = values[i].startsWith(val);
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
-		}
-	    } else if (attr instanceof AttributeSubstr) {
-		val = ((AttributeSubstr) attr).getValue();
-		ok = false;
-		for (i=0;!ok && i<values.length; i++) {
-		    ok = (values[i].indexOf(val) >= 0);
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
-		}
-	    } else if (attr instanceof AttributeSuffix) {
-		val = ((AttributeSuffix) attr).getValue();
-		ok = false;
-		for (i=0;!ok && i<values.length; i++) {
-		    ok = values[i].endsWith(val);
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
-		}
-	    } else if (attr instanceof AttributeOneOf) {
-		AttributeOneOf otherattr = (AttributeOneOf) attr;
-		String[] othervalues = otherattr.values;
-		int j;
-		if (othervalues == null) {
-		    othervalues = otherattr.computeValues();
-		}
-		ok = false;
-		for (i=0;!ok && i<values.length; i++) {
-		    for(j=0;!ok && j<othervalues.length; j++) {
-			ok = values[i].equals(othervalues[j]);
-		    }
-		}
-		if (!ok) {
-		    ac.getFrame().addWarning("incompatible", 
-				  new String[] { toString(), attr.toString() });
+		if (name.equals(attr.getName())) {
+			if (values == null) {
+				computeValues();
+			}
+			if (attr instanceof AttributeExact) {
+				val = ((AttributeExact) attr).getValue();
+				ok = false;
+				for (i = 0; !ok && i < values.length; i++) {
+					ok = val.equals(values[i]);
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			} else if (attr instanceof AttributeBegin) {
+				val = ((AttributeBegin) attr).getValue();
+				ok = false;
+				String pval = val + '-';
+				for (i = 0; !ok && i < values.length; i++) {
+					ok = values[i].equals(val) || values[i].startsWith(pval);
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			} else if (attr instanceof AttributeStart) {
+				val = ((AttributeStart) attr).getValue();
+				ok = false;
+				for (i = 0; !ok && i < values.length; i++) {
+					ok = values[i].startsWith(val);
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			} else if (attr instanceof AttributeSubstr) {
+				val = ((AttributeSubstr) attr).getValue();
+				ok = false;
+				for (i = 0; !ok && i < values.length; i++) {
+					ok = (values[i].indexOf(val) >= 0);
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			} else if (attr instanceof AttributeSuffix) {
+				val = ((AttributeSuffix) attr).getValue();
+				ok = false;
+				for (i = 0; !ok && i < values.length; i++) {
+					ok = values[i].endsWith(val);
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			} else if (attr instanceof AttributeOneOf) {
+				AttributeOneOf otherattr = (AttributeOneOf) attr;
+				String[] othervalues = otherattr.values;
+				int j;
+				if (othervalues == null) {
+					othervalues = otherattr.computeValues();
+				}
+				ok = false;
+				for (i = 0; !ok && i < values.length; i++) {
+					for (j = 0; !ok && j < othervalues.length; j++) {
+						ok = values[i].equals(othervalues[j]);
+					}
+				}
+				if (!ok) {
+					ac.getFrame().addWarning("incompatible",
+							new String[]{toString(), attr.toString()});
+				}
+			}
 		}
-	    }
 	}
-    }
 
 }

Index: AttributeBegin.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeBegin.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- AttributeBegin.java	14 May 2008 10:13:09 -0000	1.4
+++ AttributeBegin.java	3 May 2012 09:04:08 -0000	1.5
@@ -94,7 +94,9 @@
     }
 
     public String toString() {
-	return "[" + getName() + "|=\"" + value + "\"]";
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("|=\"").append(value).append("\"]");
+		return sb.toString();
     }
 
 }

Index: AttributeExact.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeExact.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- AttributeExact.java	14 May 2008 10:13:09 -0000	1.10
+++ AttributeExact.java	3 May 2012 09:04:08 -0000	1.11
@@ -106,7 +106,9 @@
     }
 
     public String toString() {
-	return "[" + getName() + "=\"" + value + "\"]";
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("=\"").append(value).append("\"]");
+		return sb.toString();
     }
 
 }

Index: AttributeStart.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeStart.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- AttributeStart.java	14 May 2008 10:13:09 -0000	1.3
+++ AttributeStart.java	3 May 2012 09:04:09 -0000	1.4
@@ -40,7 +40,9 @@
     }
 
     public String toString() {
-	return "[" + getName() + "^=\"" + value + "\"]";
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("^=\"").append(value).append("\"]");
+		return sb.toString();
     }
 
     public void applyAttribute(ApplContext ac, AttributeSelector attr) {

Index: AttributeSuffix.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeSuffix.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- AttributeSuffix.java	14 May 2008 10:13:09 -0000	1.3
+++ AttributeSuffix.java	3 May 2012 09:04:09 -0000	1.4
@@ -40,7 +40,9 @@
     }
 
     public String toString() {
-	return "[" + getName() + "$=\"" + value + "\"]";
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("$=\"").append(value).append("\"]");
+		return sb.toString();
     }
 
     public void applyAttribute(ApplContext ac, AttributeSelector attr) {

Index: AttributeSubstr.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/selectors/attributes/AttributeSubstr.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- AttributeSubstr.java	14 May 2008 10:13:09 -0000	1.3
+++ AttributeSubstr.java	3 May 2012 09:04:09 -0000	1.4
@@ -40,7 +40,9 @@
     }
 
     public String toString() {
-	return "[" + getName() + "*=\"" + value + "\"]";
+		StringBuilder sb = new StringBuilder();
+		sb.append('[').append(getName()).append("*=\"").append(value).append("\"]");
+		return sb.toString();
     }
 
     public void applyAttribute(ApplContext ac, AttributeSelector attr) {
Received on Thursday, 3 May 2012 09:04:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 3 May 2012 09:04:20 GMT