- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 12 Jul 2005 14:47:57 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser
In directory hutz:/tmp/cvs-serv17634/css/parser
Modified Files:
CssFouffa.java CssPropertyFactory.java CssSelectors.java
Log Message:
Utf8 properties (Jean-Guilhem Rouel)
Index: CssSelectors.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssSelectors.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CssSelectors.java 27 Oct 2003 09:21:33 -0000 1.10
+++ CssSelectors.java 12 Jul 2005 14:47:55 -0000 1.11
@@ -8,22 +8,21 @@
package org.w3c.css.parser;
import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
import java.util.Enumeration;
+import java.util.Hashtable;
-import org.w3c.css.util.Warnings;
-import org.w3c.css.util.Messages;
-import org.w3c.css.util.Util;
+import org.w3c.css.properties.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
+import org.w3c.css.util.Warnings;
/**
* This class manages all contextual selector.
*
- * <p>Note:<BR>
+ * <p>
+ * Note:<BR>
* Invoke a <code>set</code> function to change the selector clears all
* properties !
*
@@ -62,6 +61,7 @@
* The pseudo-class function (contains, nth-child, nth-of-type or lang)
*/
String pseudofun;
+
String pseudofunval;
char connector = DESCENDANT;
@@ -95,10 +95,11 @@
private boolean Init;
// all HTML element in HTML 4.0
- private static Properties elements = new Properties();
+ private static Utf8Properties elements = new Utf8Properties();
// special (?) HTML tag
private static final int HTMLCode = "HTML".hashCode();
+
private static final int BODYCode = "BODY".hashCode();
private String usermedium;
@@ -129,7 +130,8 @@
/**
* Create a new CssSelectors with a previous selector.
*
- * @param next the next selector
+ * @param next
+ * the next selector
*/
public CssSelectors(CssSelectors next) {
this(next.style);
@@ -139,7 +141,8 @@
/**
* Create a new CssSelectors with a previous selector.
*
- * @param next the next selector
+ * @param next
+ * the next selector
*/
public CssSelectors(ApplContext ac, CssSelectors next) {
this(ac);
@@ -147,10 +150,11 @@
}
/**
- * Set the style for all contexts.
- * Don't forget to invoke this method if you want a style !
+ * Set the style for all contexts. Don't forget to invoke this method if you
+ * want a style !
*
- * @param style0 the style
+ * @param style0
+ * the style
*/
public void setStyle(Class style0) {
Util.verbose("Style is : " + style0);
@@ -160,7 +164,8 @@
/**
* Set the attribute atRule
*
- * @param atRule the new value for the attribute
+ * @param atRule
+ * the new value for the attribute
*/
public void setAtRule(AtRule atRule) {
this.atRule = atRule;
@@ -177,6 +182,7 @@
/**
* Set the connector between simple selector
+ *
* @see CssSelectorsConstant
*/
public void setConnector(char connector) {
@@ -189,11 +195,11 @@
}
/**
- * Set the element.
- * Be careful, you should work with upper case not lower case
- * (it's more practical)
+ * Set the element. Be careful, you should work with upper case not lower
+ * case (it's more practical)
*
- * @param element the element.
+ * @param element
+ * the element.
*/
public void setElement(String element) {
if (element == null) {
@@ -206,12 +212,13 @@
}
/**
- * Set the element with verification.
- * Be careful, you should work with upper case not lower case
- * (it's more practical)
+ * Set the element with verification. Be careful, you should work with upper
+ * case not lower case (it's more practical)
*
- * @param element the element.
- * @param frame For errors and warnings.
+ * @param element
+ * the element.
+ * @param frame
+ * For errors and warnings.
*/
public void setElement(String element, ApplContext ac) {
if (element == null) {
@@ -220,34 +227,23 @@
String isHTML = elements.getProperty(element.toUpperCase());
-/*
- if (Util.fromHTMLFile) {
- if (isHTML == null) {
- ac.getFrame().addWarning("unknown-html", element);
- } else if (isHTML.equals("true")) {
- isBlock = true;
- if ((next != null)
- && (next.element != null)
- && !next.isBlock) {
- ac.getFrame().addWarning("noinside", element);
- }
- }
- }
-*/
+ /*
+ * if (Util.fromHTMLFile) { if (isHTML == null) {
+ * ac.getFrame().addWarning("unknown-html", element); } else if
+ * (isHTML.equals("true")) { isBlock = true; if ((next != null) &&
+ * (next.element != null) && !next.isBlock) {
+ * ac.getFrame().addWarning("noinside", element); } } }
+ */
this.element = element;
hashElement = element.hashCode();
-/*
- if (Util.fromHTMLFile) {
- if (hashElement == HTMLCode && next != null) {
- ac.getFrame().addWarning("html-inside");
- } else if (hashElement == BODYCode && next != null &&
- next.hashElement != 0 && next.hashElement != HTMLCode) {
- ac.getFrame().addWarning("body-inside");
- }
- }
-*/
+ /*
+ * if (Util.fromHTMLFile) { if (hashElement == HTMLCode && next != null) {
+ * ac.getFrame().addWarning("html-inside"); } else if (hashElement ==
+ * BODYCode && next != null && next.hashElement != 0 && next.hashElement !=
+ * HTMLCode) { ac.getFrame().addWarning("body-inside"); } }
+ */
verifyPseudoElement(ac);
Invalidate();
@@ -280,8 +276,8 @@
} catch (AttributeException e) {
// e.printStackTrace();
if (ac != null) {
- InvalidParamException error =
- new InvalidParamException("incompatible", old,attr,ac);
+ InvalidParamException error = new InvalidParamException(
+ "incompatible", old, attr, ac);
ac.getFrame().addError(new CssError(error));
}
}
@@ -292,8 +288,8 @@
}
/**
- * Add an attribute to this selector.
- * if the selector type is ATTRIBUTE_ANY, the value is ignored.
+ * Add an attribute to this selector. if the selector type is ATTRIBUTE_ANY,
+ * the value is ignored.
*/
public void addAttribute(String attName, String value)
throws InvalidParamException {
@@ -303,8 +299,8 @@
ac);
}
} else {
- Attribute attr =
- new AttributeExact().setValue(value).setName(attName);
+ Attribute attr = new AttributeExact().setValue(value).setName(
+ attName);
attributes.put(attName, attr);
addAttribute(attr);
@@ -313,11 +309,11 @@
}
/**
- * Add an attribute to this selector.
- * if the selector type is ATTRIBUTE_ANY, the value is ignored.
+ * Add an attribute to this selector. if the selector type is ATTRIBUTE_ANY,
+ * the value is ignored.
*/
- public void addAttribute(String attName, String value,
- int selectorType) throws InvalidParamException {
+ public void addAttribute(String attName, String value, int selectorType)
+ throws InvalidParamException {
Attribute attr = null;
@@ -325,20 +321,20 @@
if (ac.getProfile().equals("mobile")) {
if (selectorType == ATTRIBUTE_CLASS_SEL) {
- attr = new AttributeOneOf().addValue(value).setName(
- attName);
+ attr = new AttributeOneOf().addValue(value)
+ .setName(attName);
addAttribute(attr);
Invalidate();
return;
} else if (selectorType == ATTRIBUTE_EXACT) {
- attr = new AttributeExact().setValue(value).setName(
- attName);
+ attr = new AttributeExact().setValue(value)
+ .setName(attName);
addAttribute(attr);
Invalidate();
return;
} else {
throw new InvalidParamException("notformobile",
- "attributes" , ac);
+ "attributes", ac);
}
} else if (ac.getProfile().equals("tv")) {
throw new InvalidParamException("notfortv", "attributes", ac);
@@ -348,9 +344,8 @@
switch (selectorType) {
case ATTRIBUTE_ANY:
if (ac.getCssVersion().equals("css1")) {
- throw new InvalidParamException("notversion","[" +
- attName +"]",
- ac.getCssVersion(), ac);
+ throw new InvalidParamException("notversion", "[" + attName
+ + "]", ac.getCssVersion(), ac);
} else {
attr = new AttributeAny().setName(attName);
}
@@ -360,17 +355,16 @@
break;
case ATTRIBUTE_BEGIN:
if (ac.getCssVersion().equals("css1")) {
- throw new InvalidParamException("notversion","[" + attName
- + "|=" + value + "]"
- , ac.getCssVersion(), ac);
+ throw new InvalidParamException("notversion", "[" + attName
+ + "|=" + value + "]", ac.getCssVersion(), ac);
} else {
attr = new AttributeBegin().setValue(value).setName(attName);
}
break;
case ATTRIBUTE_ONE_OF:
if (value.indexOf(' ') != -1) {
- InvalidParamException error =
- new InvalidParamException("space", value, ac);
+ InvalidParamException error = new InvalidParamException(
+ "space", value, ac);
ac.getFrame().addError(new CssError(error));
return;
}
@@ -423,16 +417,15 @@
return;
}
if (ac.getProfile() != null && !"".equals(ac.getProfile())) {
- if (ac.getProfile().equals("mobile") &&
- pseudo.equals("first-child") ) {
+ if (ac.getProfile().equals("mobile")
+ && pseudo.equals("first-child")) {
throw new InvalidParamException("notformobile", pseudo, ac);
}
}
int index = getPseudoClassIndex(pseudo);
if (index != -1) {
- if ((getAtRule() != null)
- && getAtRule().toString() != null
+ if ((getAtRule() != null) && getAtRule().toString() != null
&& getAtRule().toString().equals("@media atsc-tv")) {
if (!pseudo.equals("target")) {
addPseudoClass(index);
@@ -469,7 +462,7 @@
if (ac.getProfile() != null && !"".equals(ac.getProfile())) {
if (ac.getProfile().equals("mobile")) {
- for (int i=0; i<PSEUDOCLASS_CONSTANTS_MOBILE.length; i++) {
+ for (int i = 0; i < PSEUDOCLASS_CONSTANTS_MOBILE.length; i++) {
if (pseudo.equals(PSEUDOCLASS_CONSTANTS_MOBILE[i])) {
return i;
}
@@ -481,7 +474,7 @@
}
}
} else {
- for (int i=0; i < PSEUDOCLASS_CONSTANTSCSS2.length; i++) {
+ for (int i = 0; i < PSEUDOCLASS_CONSTANTSCSS2.length; i++) {
if (pseudo.equals(PSEUDOCLASS_CONSTANTSCSS2[i])) {
return i;
}
@@ -507,25 +500,28 @@
/**
* Set the pseudoClass with verification.
*
- * Be careful, you should work with lower case not upper case
- * (it's more practical)
+ * Be careful, you should work with lower case not upper case (it's more
+ * practical)
*
- * @param pseudoClass The pseudo class.
- * @param frame For errors and warnings.
+ * @param pseudoClass
+ * The pseudo class.
+ * @param frame
+ * For errors and warnings.
* @deprecated
*/
private void addPseudoClass(int index) {
// hashPseudoClass = pseudoClass.hashCode();
this.pseudoClass[index] = true;
- //if (element != null && !element.equals("A")) {
+ // if (element != null && !element.equals("A")) {
// ac.getFrame().addWarning("pseudo-classes", pseudoClass);
- //}
+ // }
}
/**
* Get pseudo class
*
- * <p> There is no semi-colon at the beginning of the string.
+ * <p>
+ * There is no semi-colon at the beginning of the string.
*/
public Enumeration getPseudoClass() {
@@ -548,8 +544,7 @@
PSEUDOCLASS_CONSTANTSCSS2);
}
} else if (ac.getCssVersion().equals("css1")) {
- return new PseudoEnumeration(pseudoClass,
- PSEUDOCLASS_CONSTANTSCSS1);
+ return new PseudoEnumeration(pseudoClass, PSEUDOCLASS_CONSTANTSCSS1);
} else {
return new PseudoEnumeration(pseudoClass, PSEUDOCLASS_CONSTANTS);
}
@@ -560,14 +555,13 @@
if (pseudo.equals("lang")) {
if (ac.getCssVersion().equals("css1")) {
- throw new InvalidParamException("notversion", pseudo,
- ac.getCssVersion(), ac);
+ throw new InvalidParamException("notversion", pseudo, ac
+ .getCssVersion(), ac);
}
if (ac.getProfile() != null) {
if (ac.getProfile().equals("mobile")) {
- throw new InvalidParamException("notformobile", pseudo,
- ac);
+ throw new InvalidParamException("notformobile", pseudo, ac);
} else if (ac.getProfile().equals("tv")) {
throw new InvalidParamException("notfortv", pseudo, ac);
}
@@ -575,10 +569,10 @@
pseudofun = pseudo;
pseudofunval = param;
} else if (pseudo.equals("nth-child")) {
- if (ac.getCssVersion().equals("css1") ||
- ac.getCssVersion().equals("css2")) {
- throw new InvalidParamException("notversion", pseudo,
- ac.getCssVersion(), ac);
+ if (ac.getCssVersion().equals("css1")
+ || ac.getCssVersion().equals("css2")) {
+ throw new InvalidParamException("notversion", pseudo, ac
+ .getCssVersion(), ac);
}
try {
@@ -590,10 +584,10 @@
throw new InvalidParamException("pseudoval", param, ac);
}
} else if (pseudo.equals("nth-of-type")) {
- if (ac.getCssVersion().equals("css1") ||
- ac.getCssVersion().equals("css2")) {
- throw new InvalidParamException("notversion", pseudo,
- ac.getCssVersion(), ac);
+ if (ac.getCssVersion().equals("css1")
+ || ac.getCssVersion().equals("css2")) {
+ throw new InvalidParamException("notversion", pseudo, ac
+ .getCssVersion(), ac);
}
try {
@@ -605,10 +599,10 @@
throw new InvalidParamException("pseudoval", param, ac);
}
} else if (pseudo.equals("nth-last-of-type")) {
- if (ac.getCssVersion().equals("css1") ||
- ac.getCssVersion().equals("css2")) {
- throw new InvalidParamException("notversion", pseudo,
- ac.getCssVersion(), ac);
+ if (ac.getCssVersion().equals("css1")
+ || ac.getCssVersion().equals("css2")) {
+ throw new InvalidParamException("notversion", pseudo, ac
+ .getCssVersion(), ac);
}
try {
@@ -633,9 +627,8 @@
pseudofunval = param;
return;
} else {
- CssErrorToken e =
- new CssErrorToken(0, ac.getMsg().getErrorString("pseudo"),
- new String[0]);
+ CssErrorToken e = new CssErrorToken(0, ac.getMsg().getErrorString(
+ "pseudo"), new String[0]);
e.skippedString = pseudo;
ac.getFrame().addError(e);
}
@@ -646,8 +639,7 @@
}
private int getPseudoElementIndex(String pseudo)
- throws InvalidParamException
- {
+ throws InvalidParamException {
if (ac.getCssVersion().equals("css3")) {
for (int i = 0; i < PSEUDOELEMENT_CONSTANTS.length; i++) {
if (pseudo.equals(PSEUDOELEMENT_CONSTANTS[i])) {
@@ -657,10 +649,9 @@
} else if (ac.getCssVersion().equals("css2")) {
if (ac.getProfile() != null) {
if (ac.getProfile().equals("mobile")) {
- throw new InvalidParamException("notformobile", pseudo,
- ac);
+ throw new InvalidParamException("notformobile", pseudo, ac);
} else {
- for (int i=0; i<PSEUDOELEMENT_CONSTANTSCSS2.length; i++) {
+ for (int i = 0; i < PSEUDOELEMENT_CONSTANTSCSS2.length; i++) {
if (pseudo.equals(PSEUDOELEMENT_CONSTANTSCSS2[i])) {
return i;
}
@@ -684,12 +675,13 @@
}
/**
- * Set the pseudoElement.
- * Be careful, you should work with lower case not upper case
- * (it's more practical)
+ * Set the pseudoElement. Be careful, you should work with lower case not
+ * upper case (it's more practical)
*
- * @param pseudoElement the pseudo element
- * @param frame For errors and warnings.
+ * @param pseudoElement
+ * the pseudo element
+ * @param frame
+ * For errors and warnings.
* @deprecated
*/
private void addPseudoElement(int index) {
@@ -704,12 +696,12 @@
/**
* Get the pseudoElement.
*
- * <p> There is no semi-colon at the beginning of the string.
+ * <p>
+ * There is no semi-colon at the beginning of the string.
*/
public Enumeration getPseudoElement() {
if (ac.getCssVersion().equals("css3")) {
- return new PseudoEnumeration(pseudoElement,
- PSEUDOELEMENT_CONSTANTS);
+ return new PseudoEnumeration(pseudoElement, PSEUDOELEMENT_CONSTANTS);
} else if (ac.getCssVersion().equals("css2")) {
return new PseudoEnumeration(pseudoElement,
PSEUDOELEMENT_CONSTANTSCSS2);
@@ -717,24 +709,25 @@
return new PseudoEnumeration(pseudoElement,
PSEUDOELEMENT_CONSTANTSCSS1);
} else {
- return new PseudoEnumeration(pseudoElement,
- PSEUDOELEMENT_CONSTANTS);
+ return new PseudoEnumeration(pseudoElement, PSEUDOELEMENT_CONSTANTS);
}
}
/**
* Adds a property to this selector.
*
- * @param property The property.
- * @param warnings For warning report.
+ * @param property
+ * The property.
+ * @param warnings
+ * For warning report.
*/
public void addProperty(CssProperty property, Warnings warnings) {
Init = true;
if (properties != null) {
properties.setProperty(ac, property, warnings);
} else {
- System.err.println("[ERROR] Invalid state in "+
- "org.w3c.css.parser.CssSelectors#addProperty");
+ System.err.println("[ERROR] Invalid state in "
+ + "org.w3c.css.parser.CssSelectors#addProperty");
System.err.println("[ERROR] Please report BUG");
}
}
@@ -769,7 +762,7 @@
}
}
Enumeration e;
- for (e = getPseudoClass(); e.hasMoreElements();e.nextElement() ) {
+ for (e = getPseudoClass(); e.hasMoreElements(); e.nextElement()) {
specificity += 100;
}
}
@@ -812,14 +805,14 @@
local.append(pseudofunval);
local.append(')');
}
- if (ac.getCssVersion().equals("css1") ||
- ac.getCssVersion().equals("css2")) {
- for (Enumeration e = getPseudoElement();e.hasMoreElements();) {
+ if (ac.getCssVersion().equals("css1")
+ || ac.getCssVersion().equals("css2")) {
+ for (Enumeration e = getPseudoElement(); e.hasMoreElements();) {
local.append(':');
local.append(e.nextElement().toString());
}
} else {
- for (Enumeration e = getPseudoElement();e.hasMoreElements();) {
+ for (Enumeration e = getPseudoElement(); e.hasMoreElements();) {
local.append(':');
local.append(':');
local.append(e.nextElement().toString());
@@ -861,7 +854,8 @@
/**
* Returns <code>true</code> if the selector is equals to an another.
*
- * @param selector The selector to compare
+ * @param selector
+ * The selector to compare
*/
public boolean equals(Object selector) {
if ((selector == null) || !(selector instanceof CssSelectors)) {
@@ -887,7 +881,8 @@
/**
* Set the previous selector.
*
- * @param next the previous selector.
+ * @param next
+ * the previous selector.
*/
public void setNext(CssSelectors next) {
this.next = next;
@@ -906,8 +901,7 @@
if (attrs.size() > 0) {
for (Enumeration e = attrs.elements(); e.hasMoreElements();) {
Attribute attr = (Attribute) e.nextElement();
- Attribute other =
- (Attribute) attrs2.get(attr.getName());
+ Attribute other = (Attribute) attrs2.get(attr.getName());
if (other != null) {
if (!attr.canApply(other)) {
return false;
@@ -924,22 +918,26 @@
/**
* Returns <code>true</code> if the selector can matched this selector.
*
- * <p>Examples:<br>
+ * <p>
+ * Examples:<br>
* <OL>
* <LI><code>H1.canApply(HTML BODY H1)</code> returns <code>true</code>
- * <LI><code>H1.canApply(HTML BODY H1 EM)</code> returns <code>false</code>
+ * <LI><code>H1.canApply(HTML BODY H1 EM)</code> returns
+ * <code>false</code>
* <LI><code>(H1 EM).canApply(HTML BODY H2 EM)</code> returns
* <code>false</code>
* <LI><code>(HTML EM).canApply(HTML BODY H2 EM)</code> returns
* <code>true</code>
* </OL>
*
- * <p> Note:<BR>
+ * <p>
+ * Note:<BR>
* In principle, if you work with a HTML document, your selector should
* start with HTML BODY. Because you are always in this context when you
* parse the text in a HTML document.
*
- * @param selector the selector to match
+ * @param selector
+ * the selector to match
* @see org.w3c.css.css.CssCascadingOrder#order
*/
public boolean canApply(CssSelectors selector) {
@@ -951,9 +949,9 @@
// current work - don't touch
Util.verbose(getSpecificity() + " canApply this " + this
+ " selector: " + selector);
- Util.verbose( "connector " + connector);
- Util.verbose( attributes.toString() );
- Util.verbose( selector.attributes.toString() );
+ Util.verbose("connector " + connector);
+ Util.verbose(attributes.toString());
+ Util.verbose(selector.attributes.toString());
Util.verbose("canApply for attributes :" + result);
if ((hashElement != selector.hashElement) && hashElement != 0) {
@@ -980,19 +978,20 @@
}
/**
- * Returns true if the selector can matched an another selector.
- * called by canApply
+ * Returns true if the selector can matched an another selector. called by
+ * canApply
*
- * @param selector The selector to compare
+ * @param selector
+ * The selector to compare
*/
private boolean canMatched(CssSelectors selector) {
boolean result = canApply(attributes, selector.attributes);
// current work
Util.verbose("canMatched this " + this + " selector: " + selector);
- Util.verbose( "connector " + connector);
- Util.verbose( attributes.toString() );
- Util.verbose( selector.attributes.toString() );
- Util.verbose( "canMatched for attributes :" + result);
+ Util.verbose("connector " + connector);
+ Util.verbose(attributes.toString());
+ Util.verbose(selector.attributes.toString());
+ Util.verbose("canMatched for attributes :" + result);
if ((hashElement != selector.hashElement) && hashElement != 0) {
if ((connector == DESCENDANT) && (selector.next != null)) {
@@ -1032,37 +1031,23 @@
void verifyPseudoElement(ApplContext ac) {
/*
- if (next != null && next.pseudoElement != null) {
- // eliminate this error
- if (frame != null) {
- InvalidParamException error =
- new InvalidParamException("pseudo"-element",
- next.pseudoElement,
- this.toString());
- ac.getFrame().addError(new CssError(error));
- }
- next.pseudoElement = null;
- next.verifyPseudoElement(frame);
- next.Invalidate();
- }
+ * if (next != null && next.pseudoElement != null) { // eliminate this
+ * error if (frame != null) { InvalidParamException error = new
+ * InvalidParamException("pseudo"-element", next.pseudoElement,
+ * this.toString()); ac.getFrame().addError(new CssError(error)); }
+ * next.pseudoElement = null; next.verifyPseudoElement(frame);
+ * next.Invalidate(); }
*/
}
void verifyPseudoClass(ApplContext ac) {
/*
- if (next != null && next.pseudoClass != null) {
- // eliminate this error
- if (frame != null) {
- InvalidParamException error =
- new InvalidParamException("pseudo-class",
- next.pseudoClass,
- this.toString());
- ac.getFrame().addError(new CssError(error));
- }
- next.pseudoClass = null;
- next.verifyPseudoClass(frame);
- next.Invalidate();
- }
+ * if (next != null && next.pseudoClass != null) { // eliminate this
+ * error if (frame != null) { InvalidParamException error = new
+ * InvalidParamException("pseudo-class", next.pseudoClass,
+ * this.toString()); ac.getFrame().addError(new CssError(error)); }
+ * next.pseudoClass = null; next.verifyPseudoClass(frame);
+ * next.Invalidate(); }
*/
}
@@ -1096,27 +1081,26 @@
f.close();
}
} catch (Exception e) {
- System.err.println("org.w3c.css.properties.CssSelectors: "+
- "couldn't load properties");
- System.err.println(" " + e.toString() );
+ System.err.println("org.w3c.css.properties.CssSelectors: "
+ + "couldn't load properties");
+ System.err.println(" " + e.toString());
}
}
}
-
-
-
class PseudoEnumeration implements Enumeration {
boolean[] classes;
+
String[] values;
+
int current = -1;
PseudoEnumeration(boolean[] classes, String[] values) {
this.classes = classes;
this.values = values;
- while ((++current < classes.length)
- && !classes[current]) /*nothing*/;
+ while ((++current < classes.length) && !classes[current])
+ /* nothing */;
}
public boolean hasMoreElements() {
@@ -1125,8 +1109,8 @@
public Object nextElement() {
String v = values[current];
- while ((++current < classes.length)
- && !classes[current]) /*nothing*/;
+ while ((++current < classes.length) && !classes[current])
+ /* nothing */;
return v;
}
}
Index: CssPropertyFactory.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssPropertyFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CssPropertyFactory.java 20 Nov 2004 19:02:47 -0000 1.9
+++ CssPropertyFactory.java 12 Jul 2005 14:47:55 -0000 1.10
@@ -7,30 +7,31 @@
package org.w3c.css.parser;
+import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
-import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.ApplContext;
-import java.util.StringTokenizer;
-import java.util.Vector;
/**
* @version $Revision$
- * @author Philippe Le Hégaret
+ * @author Philippe Le H�garet
*/
public class CssPropertyFactory implements Cloneable {
// all recognized properties are here.
- private Properties properties;
- private Properties allprops;
+ private Utf8Properties properties;
+
+ private Utf8Properties allprops;
private String usermedium;
@@ -47,7 +48,7 @@
* Create a new CssPropertyFactory
*/
public CssPropertyFactory(URL url, URL allprop_url) {
- properties = new Properties();
+ properties = new Utf8Properties();
InputStream f = null;
try {
f = url.openStream();
@@ -63,8 +64,8 @@
} // ignore
}
- //list of all properties
- allprops = new Properties();
+ // list of all properties
+ allprops = new Utf8Properties();
InputStream f_all = null;
try {
f_all = allprop_url.openStream();
@@ -103,11 +104,8 @@
this.usermedium = usermedium;
}
- public synchronized CssProperty createMediaFeature (
- ApplContext ac,
- AtRule atRule,
- String property,
- CssExpression expression)
+ public synchronized CssProperty createMediaFeature(ApplContext ac,
+ AtRule atRule, String property, CssExpression expression)
throws Exception {
String result = "ok";
@@ -135,22 +133,21 @@
String classname = properties.getProperty("mediafeature" + "."
+ property);
- if (classname == null ) {
+ if (classname == null) {
if (atRule instanceof AtRuleMedia && (!media.equals("all"))) {
// I don't know this property
- //throw new InvalidParamException("noexistence-media",
+ // 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);
+ throw new InvalidParamException("noexistence", property, media,
+ ac);
}
}
-
try {
// create an instance of your property class
Class expressionclass = new CssExpression().getClass();
@@ -158,8 +155,8 @@
expressionclass = expression.getClass();
}
Class[] parametersType = { ac.getClass(), expressionclass };
- Constructor constructor =
- Class.forName(classname).getConstructor(parametersType);
+ Constructor constructor = Class.forName(classname).getConstructor(
+ parametersType);
Object[] parameters = { ac, expression };
// invoke the constructor
return (CssProperty) constructor.newInstance(parameters);
@@ -172,11 +169,8 @@
}
-
public synchronized CssProperty createProperty(ApplContext ac,
- AtRule atRule,
- String property,
- CssExpression expression)
+ AtRule atRule, String property, CssExpression expression)
throws Exception {
String result = "ok";
@@ -208,30 +202,30 @@
classname = properties.getProperty(property);
} else {
for (int i = 0; i < list.size() - 1; i++) {
- String medium = (String)list.elementAt(i);
- String name = properties.getProperty(medium +
- "." + property);
+ String medium = (String) list.elementAt(i);
+ String name = properties.getProperty(medium + "."
+ + property);
if (name == null) {
result = medium;
}
}
if (result.equals("ok")) {
- classname = properties.getProperty(
- (String)list.firstElement() + "." + property);
- }
- else {
+ classname = properties.getProperty((String) list
+ .firstElement()
+ + "." + property);
+ } else {
classname = null;
}
}
} else {
- classname = properties.getProperty("@" + atRule.keyword()
- + "." + property);
+ classname = properties.getProperty("@" + atRule.keyword() + "."
+ + property);
}
CssProperty prop = null;
- //System.out.println(allprops.getProperty(property));
+ // System.out.println(allprops.getProperty(property));
if (classname == null && usermedium != null) {
if (atRule instanceof AtRuleMedia) {
@@ -239,9 +233,8 @@
if (!media.equals("all"))
ac.getFrame().addWarning("notforusermedium", property);
classname = properties.getProperty(property);
- }
- else {
- //NEW
+ } else {
+ // NEW
if (allprops.getProperty(property) == null) {
// I don't know this property
throw new InvalidParamException("noexistence", property,
@@ -251,23 +244,22 @@
classname = allprops.getProperty(property);
}
}
- } else
- if (classname == null ) { // && CssFouffa.usermedium == null)
+ } else if (classname == null) { // && CssFouffa.usermedium == null)
if (atRule instanceof AtRuleMedia && (!media.equals("all"))) {
// I don't know this property
- /*throw new InvalidParamException("noexistence-media",
- property,
- media, ac);*/
+ /*
+ * 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
- //NEW
+ // NEW
if (allprops.getProperty(property) == null) {
// I don't know this property
- throw new InvalidParamException("noexistence",
- property,
+ throw new InvalidParamException("noexistence", property,
media, ac);
} else {
ac.getFrame().addWarning("otherprofile", property);
@@ -278,14 +270,14 @@
CssIdent initial = new CssIdent("initial");
- if (expression.getValue().equals(initial) &&
- ac.getCssVersion().equals("css3")) {
+ if (expression.getValue().equals(initial)
+ && ac.getCssVersion().equals("css3")) {
try {
// create an instance of your property class
- Class[] parametersType = { };
- Constructor constructor =
- Class.forName(classname).getConstructor(parametersType);
- Object[] parameters = { };
+ Class[] parametersType = {};
+ Constructor constructor = Class.forName(classname)
+ .getConstructor(parametersType);
+ Object[] parameters = {};
// invoke the constructor
return (CssProperty) constructor.newInstance(parameters);
} catch (InvocationTargetException e) {
@@ -298,10 +290,9 @@
try {
// create an instance of your property class
- Class[] parametersType = { ac.getClass(),
- expression.getClass() };
- Constructor constructor =
- Class.forName(classname).getConstructor(parametersType);
+ Class[] parametersType = { ac.getClass(), expression.getClass() };
+ Constructor constructor = Class.forName(classname)
+ .getConstructor(parametersType);
Object[] parameters = { ac, expression };
// invoke the constructor
return (CssProperty) constructor.newInstance(parameters);
Index: CssFouffa.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/parser/CssFouffa.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- CssFouffa.java 30 May 2004 05:06:52 -0000 1.26
+++ CssFouffa.java 12 Jul 2005 14:47:55 -0000 1.27
@@ -5,42 +5,37 @@
// (c) COPYRIGHT MIT, ERCIM and Keio, 2003.
// Please first read the full copyright statement in file COPYRIGHT.html
/*
-This class is the front end of the CSS parser
+ This class is the front end of the CSS parser
*/
package org.w3c.css.parser;
-import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
-import java.net.HttpURLConnection;
-// import org.w3c.www.protocol.http.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.util.Vector;
-import java.util.Hashtable;
import java.util.Enumeration;
-import java.util.Properties;
+import java.util.Vector;
-import org.w3c.css.properties.CssProperty;
+import org.w3c.css.css.StyleSheetOrigin;
import org.w3c.css.parser.analyzer.CssParser;
-import org.w3c.css.parser.analyzer.ParseException;
import org.w3c.css.parser.analyzer.CssParserTokenManager;
-import org.w3c.css.values.CssExpression;
-import org.w3c.css.values.CssValue;
-import org.w3c.css.css.StyleSheetOrigin;
+import org.w3c.css.parser.analyzer.ParseException;
+import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.HTTPURL;
import org.w3c.css.util.InvalidParamException;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
-import org.w3c.css.util.HTTPURL;
-import org.w3c.css.util.ApplContext;
-import org.w3c.css.parser.AtRule;
-import org.w3c.css.css.StyleSheetCom;
+import org.w3c.css.values.CssExpression;
/**
* This class is a front end of the CSS1 parser.
*
- * <p> Example:<br>
+ * <p>
+ * Example:<br>
* <code>
* CssFouffa parser =
* new CssFouffa(new URL("http://www.w3.org/drafts.css"));<BR>
@@ -56,22 +51,35 @@
// all properties
CssPropertyFactory properties = null;
+
static CssPropertyFactory __s_nullprop = null;
+
static CssPropertyFactory __s_css1prop = null;
+
static CssPropertyFactory __s_asc_tvprop = null;
+
static CssPropertyFactory __s_css2prop = null;
+
static CssPropertyFactory __s_css2mobileprop = null;
+
static CssPropertyFactory __s_css2tvprop = null;
+
static CssPropertyFactory __s_css3prop = null;
+
static CssPropertyFactory __s_svgprop = null;
+
static CssPropertyFactory __s_svgtinyprop = null;
+
static CssPropertyFactory __s_svgbasicprop = null;
- static private Properties config = null;
+ static private Utf8Properties config = null;
+
// all listeners
Vector listeners;
+
// all errors
Errors errors;
+
// origin of the style sheet
int origin;
@@ -80,14 +88,16 @@
/**
* Create a new CssFouffa with a data input and a begin line number.
*
- * @param input data input
- * @param file The source file (use for errors, warnings and import)
- * @param beginLine The begin line number in the file.
- * (used for HTML for example)
- * @exception IOException if an I/O error occurs.
+ * @param input
+ * data input
+ * @param file
+ * The source file (use for errors, warnings and import)
+ * @param beginLine
+ * The begin line number in the file. (used for HTML for example)
+ * @exception IOException
+ * if an I/O error occurs.
*/
- public CssFouffa(ApplContext ac, InputStream input,
- URL file, int beginLine)
+ public CssFouffa(ApplContext ac, InputStream input, URL file, int beginLine)
throws IOException {
super(input);
if (ac.getOrigin() == -1) {
@@ -99,30 +109,19 @@
setApplContext(ac);
// @@this is a default media ...
/*
- AtRuleMedia media = new AtRuleMedia();
-
- if (ac.getMedium() == null) {
- try {
- media.addMedia("all", ac);
- } catch (InvalidParamException e) {} //ignore
- } else {
- try {
- media.addMedia(ac.getMedium(), ac);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- try {
- media.addMedia("all", ac);
- } catch (InvalidParamException ex) {} //ignore
- }
- }
- setAtRule(media);
+ * AtRuleMedia media = new AtRuleMedia();
+ *
+ * if (ac.getMedium() == null) { try { media.addMedia("all", ac); }
+ * catch (InvalidParamException e) {} //ignore } else { try {
+ * media.addMedia(ac.getMedium(), ac); } catch (Exception e) {
+ * System.err.println(e.getMessage()); try { media.addMedia("all", ac); }
+ * catch (InvalidParamException ex) {} //ignore } } setAtRule(media);
*/
setURL(file);
if (Util.onDebug) {
- System.err.println( "[DEBUG] CSS version " + ac.getCssVersion()
- + " medium " + ac.getMedium()
- + " at-rule " + getAtRule()
- + " profile " + ac.getProfile() );
+ System.err.println("[DEBUG] CSS version " + ac.getCssVersion()
+ + " medium " + ac.getMedium() + " at-rule " + getAtRule()
+ + " profile " + ac.getProfile());
}
loadConfig(ac.getCssVersion(), ac.getProfile());
listeners = new Vector();
@@ -131,22 +130,26 @@
/**
* Create a new CssFouffa with a data input.
*
- * @param input data input
- * @param file The source file (use for errors, warnings and import)
- * @exception IOException if an I/O error occurs.
+ * @param input
+ * data input
+ * @param file
+ * The source file (use for errors, warnings and import)
+ * @exception IOException
+ * if an I/O error occurs.
*/
public CssFouffa(ApplContext ac, InputStream input, URL file)
- throws IOException
- {
+ throws IOException {
this(ac, input, file, 0);
}
/**
* Create a new CssFouffa.
*
- * @param file The source file
- * (use for data input, errors, warnings and import)
- * @exception IOException if an I/O error occurs.
+ * @param file
+ * The source file (use for data input, errors, warnings and
+ * import)
+ * @exception IOException
+ * if an I/O error occurs.
*/
public CssFouffa(ApplContext ac, URL file) throws IOException {
this(ac, HTTPURL.getConnection(file, ac));
@@ -154,13 +157,11 @@
}
/**
- * Create a new CssFouffa.
- * internal, to get the URLCOnnection and fill the URL with the relevant
- * one */
+ * Create a new CssFouffa. internal, to get the URLCOnnection and fill the
+ * URL with the relevant one
+ */
- private CssFouffa(ApplContext ac, URLConnection uco)
- throws IOException
- {
+ private CssFouffa(ApplContext ac, URLConnection uco) throws IOException {
this(ac, uco.getInputStream(), uco.getURL(), 0);
String httpCL = uco.getHeaderField("Content-Location");
if (httpCL != null) {
@@ -171,17 +172,17 @@
/**
* Create a new CssFouffa. Used by handleImport.
*
- * @param file The source file
- * (use for data input, errors, warnings and import)
- * @param listeners Works with this listeners
- * @exception IOException if an I/O error occurs.
+ * @param file
+ * The source file (use for data input, errors, warnings and
+ * import)
+ * @param listeners
+ * Works with this listeners
+ * @exception IOException
+ * if an I/O error occurs.
*/
private CssFouffa(ApplContext ac, InputStream in, URL url,
- Vector listeners, Vector urlvisited,
- CssPropertyFactory cssfactory,
- boolean mode)
- throws IOException
- {
+ Vector listeners, Vector urlvisited, CssPropertyFactory cssfactory,
+ boolean mode) throws IOException {
this(ac, in, url, 0);
this.visited = urlvisited;
setURL(url);
@@ -192,8 +193,7 @@
this.mode = mode;
}
- private void ReInit(ApplContext ac, InputStream input,
- URL file, Frame frame) {
+ private void ReInit(ApplContext ac, InputStream input, URL file, Frame frame) {
// reinitialize the parser with a new data input
// and a new frame for errors and warnings
super.ReInit(input, ac);
@@ -207,27 +207,17 @@
media = new AtRuleMediaCSS2();
}
/*
- if (ac.getMedium() == null) {
- try {
- media.addMedia("all", ac);
- } catch (InvalidParamException e) {} //ignore
- } else {
- try {
- media.addMedia(ac.getMedium(), ac);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- try {
- media.addMedia("all", ac);
- } catch (InvalidParamException ex) {} //ignore
- }
- }
- setAtRule(media);
+ * if (ac.getMedium() == null) { try { media.addMedia("all", ac); }
+ * catch (InvalidParamException e) {} //ignore } else { try {
+ * media.addMedia(ac.getMedium(), ac); } catch (Exception e) {
+ * System.err.println(e.getMessage()); try { media.addMedia("all", ac); }
+ * catch (InvalidParamException ex) {} //ignore } } setAtRule(media);
*/
setURL(file);
if (Util.onDebug) {
- System.err.println( "[DEBUG] CSS version " + ac.getCssVersion()
- + " medium " + ac.getMedium()
- + " profile " + ac.getProfile() );
+ System.err.println("[DEBUG] CSS version " + ac.getCssVersion()
+ + " medium " + ac.getMedium() + " profile "
+ + ac.getProfile());
}
loadConfig(ac.getCssVersion(), ac.getProfile());
@@ -236,15 +226,17 @@
/**
* Reinitializes a new CssFouffa with a data input and a begin line number.
*
- * @param input data input
- * @param file The source file (use for errors, warnings and import)
- * @param beginLine The begin line number in the file.
- * (used for HTML for example)
- * @exception IOException if an I/O error occurs.
+ * @param input
+ * data input
+ * @param file
+ * The source file (use for errors, warnings and import)
+ * @param beginLine
+ * The begin line number in the file. (used for HTML for example)
+ * @exception IOException
+ * if an I/O error occurs.
*/
- public void ReInit(ApplContext ac, InputStream input,
- URL file, int beginLine)
- throws IOException {
+ public void ReInit(ApplContext ac, InputStream input, URL file,
+ int beginLine) throws IOException {
Frame f = new Frame(this, file.toString(), beginLine);
ac.setFrame(f);
ReInit(ac, input, file, f);
@@ -253,9 +245,12 @@
/**
* Reinitializes a new CssFouffa with a data input.
*
- * @param input data input
- * @param file The source file (use for errors, warnings and import)
- * @exception IOException if an I/O error occurs.
+ * @param input
+ * data input
+ * @param file
+ * The source file (use for errors, warnings and import)
+ * @exception IOException
+ * if an I/O error occurs.
*/
public void ReInit(ApplContext ac, InputStream input, URL file)
throws IOException {
@@ -267,9 +262,11 @@
/**
* Reinitializes a new CssFouffa.
*
- * @param file The source file
- * (use for data input, errors, warnings and import)
- * @exception IOException if an I/O error occurs.
+ * @param file
+ * The source file (use for data input, errors, warnings and
+ * import)
+ * @exception IOException
+ * if an I/O error occurs.
*/
public void ReInit(ApplContext ac, URL file) throws IOException {
Frame f = new Frame(this, file.toString());
@@ -281,7 +278,8 @@
/**
* Set the attribute origin
*
- * @param origin the new value for the attribute
+ * @param origin
+ * the new value for the attribute
*/
private final void setOrigin(int origin) {
this.origin = origin;
@@ -299,7 +297,8 @@
/**
* Adds a listener to the parser.
*
- * @param listener The listener
+ * @param listener
+ * The listener
* @see org.w3c.css.parser.CssValidatorListener
*/
public final void addListener(CssValidatorListener listener) {
@@ -309,7 +308,8 @@
/**
* Removes a listener from the parser
*
- * @param listener The listener
+ * @param listener
+ * The listener
* @see org.w3c.css.parser.CssValidatorListener
*/
public final void removeListener(CssValidatorListener listener) {
@@ -319,7 +319,8 @@
/**
* Parse the style sheet. This is the main function of this parser.
*
- * <p> Example:<br>
+ * <p>
+ * Example:<br>
* <code>
* CssFouffa parser = new CssFouffa(new
* URL("http://www.w3.org/drafts.css"));<BR>
@@ -328,6 +329,7 @@
* parser.addListener(myListener);<BR>
* parser.parseStyle();<BR>
* </code>
+ *
* @see org.w3c.css.parser.CssFouffa#addListener
*/
public void parseStyle() {
@@ -354,8 +356,10 @@
/**
* Call by the import statement.
*
- * @param url The style sheet where this import statement appears.
- * @param file the file name in the import statement
+ * @param url
+ * The style sheet where this import statement appears.
+ * @param file
+ * the file name in the import statement
*/
public void handleImport(URL url, String file, AtRuleMedia media) {
CssError cssError = null;
@@ -371,14 +375,12 @@
// number of imports is not exploding
if (visited.contains(surl)) {
CssError cerr = new CssError(new Exception("Import loop"
- +" detected in "
- +surl));
+ + " detected in " + surl));
ac.getFrame().addError(cerr);
return;
} else if (visited.size() > 42) {
CssError cerr = new CssError(new Exception("Maximum number"
- +" of imports "
- +"reached"));
+ + " of imports " + "reached"));
ac.getFrame().addError(cerr);
return;
}
@@ -386,8 +388,8 @@
visited.addElement(surl);
if (Util.importSecurity) {
- throw new FileNotFoundException("[SECURITY] You can't "+
- "import URL sorry.");
+ throw new FileNotFoundException("[SECURITY] You can't "
+ + "import URL sorry.");
}
URLConnection importURL = HTTPURL.getConnection(importedURL, ac);
@@ -400,16 +402,14 @@
}
String mtype = httpURL.getContentType();
if (mtype.toLowerCase().indexOf("text/html") != -1) {
- throw new FileNotFoundException(importURL.getURL() +
- ": You can't import"+
- " an HTML document");
+ throw new FileNotFoundException(importURL.getURL()
+ + ": You can't import" + " an HTML document");
}
}
Frame f = ac.getFrame();
try {
- CssFouffa cssFouffa
- = new CssFouffa(ac, importURL.getInputStream(),
- importedURL, listeners, visited,
+ CssFouffa cssFouffa = new CssFouffa(ac, importURL
+ .getInputStream(), importedURL, listeners, visited,
properties, mode);
cssFouffa.setOrigin(getOrigin());
if (!media.isEmpty()) {
@@ -431,22 +431,24 @@
/**
* Call by the at-rule statement.
*
- * @param ident The ident for this at-rule (for example: 'font-face')
- * @param string The string representation of this at-rule
+ * @param ident
+ * The ident for this at-rule (for example: 'font-face')
+ * @param string
+ * The string representation of this at-rule
*/
public void handleAtRule(String ident, String string) {
if (mode) {
Enumeration e = listeners.elements();
while (e.hasMoreElements()) {
- CssValidatorListener listener =
- (CssValidatorListener) e.nextElement();
+ CssValidatorListener listener = (CssValidatorListener) e
+ .nextElement();
listener.handleAtRule(ac, ident, string);
}
} else {
if (!Util.noErrorTrace) {
// only @import <string>; or @import <url>; are valids in CSS1
- ParseException error =
- new ParseException("at-rules are not implemented in CSS1");
+ ParseException error = new ParseException(
+ "at-rules are not implemented in CSS1");
ac.getFrame().addError(new CssError(error));
}
}
@@ -457,33 +459,34 @@
* with <code>property</code> and assign to it the expression with the
* importance.
*
- * @param property the name of the property
- * @param expression The expression representation of expression
- * @param important true if expression id important
- * @param InvalidParamException An error appears during the property
- * creation.
+ * @param property
+ * the name of the property
+ * @param expression
+ * The expression representation of expression
+ * @param important
+ * true if expression id important
+ * @param InvalidParamException
+ * An error appears during the property creation.
* @return a CssProperty
*/
public CssProperty handleDeclaration(String property,
- CssExpression expression,
- boolean important)
+ CssExpression expression, boolean important)
throws InvalidParamException {
CssProperty prop;
if (Util.onDebug) {
- System.err.println( "Creating " + property
- + ": " + expression );
+ System.err.println("Creating " + property + ": " + expression);
}
try {
- if (getMediaDeclaration().equals("on") &&
- (getAtRule() instanceof AtRuleMedia)) {
- prop = properties.createMediaFeature(ac, getAtRule(),
- property, expression);
+ if (getMediaDeclaration().equals("on")
+ && (getAtRule() instanceof AtRuleMedia)) {
+ prop = properties.createMediaFeature(ac, getAtRule(), property,
+ expression);
} else {
- prop = properties.createProperty(ac, getAtRule(),
- property, expression);
+ prop = properties.createProperty(ac, getAtRule(), property,
+ expression);
}
} catch (InvalidParamException e) {
@@ -513,7 +516,8 @@
* Parse only a list of declarations. This is useful to parse the
* <code>STYLE</code> attribute in a HTML document.
*
- * <p> Example:<br>
+ * <p>
+ * Example:<br>
* <code>
* CssFouffa parser =
* new CssFouffa(new URL("http://www.w3.org/drafts.css"));<BR>
@@ -525,7 +529,8 @@
* parser.parseDeclarations(selector);<BR>
* </code>
*
- * @param context The current context
+ * @param context
+ * The current context
* @see org.w3c.css.parser.CssFouffa#addListener
* @see org.w3c.css.parser.CssSelectors#setElement
*/
@@ -549,10 +554,9 @@
}
if (!Util.noErrorTrace) {
- for (Enumeration e = listeners.elements();
- e.hasMoreElements();) {
- CssValidatorListener listener =
- (CssValidatorListener) e.nextElement();
+ for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
+ CssValidatorListener listener = (CssValidatorListener) e
+ .nextElement();
listener.notifyErrors(ac.getFrame().getErrors());
listener.notifyWarnings(ac.getFrame().getWarnings());
}
@@ -561,8 +565,11 @@
/**
* used for the output of the stylesheet
- * @param atRule the @rule that just has been found by the parser in the
- stylesheet, it is added to the storage for the output
+ *
+ * @param atRule
+ * the
+ * @rule that just has been found by the parser in the stylesheet, it is
+ * added to the storage for the output
*/
public void newAtRule(AtRule atRule) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -572,7 +579,10 @@
/**
* used for the output of the stylesheet
- * @param charset the @charset rule that has been found by the parser
+ *
+ * @param charset
+ * the
+ * @charset rule that has been found by the parser
*/
public void addCharSet(String charset) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -581,9 +591,10 @@
}
/**
- * used for the output of the stylesheet
- * the @rule that had been found before is closed here after the content
- that's in it.
+ * used for the output of the stylesheet the
+ *
+ * @rule that had been found before is closed here after the content that's
+ * in it.
*/
public void endOfAtRule() {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -593,8 +604,9 @@
/**
* used for the output of the stylesheet
- * @param important true if the rule was declared important in the
- * stylesheet
+ *
+ * @param important
+ * true if the rule was declared important in the stylesheet
*/
public void setImportant(boolean important) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -604,20 +616,24 @@
/**
* used for the output of the stylesheet
- * @param selectors a list of one or more selectors to be added to the
- * output stylesheet
+ *
+ * @param selectors
+ * a list of one or more selectors to be added to the output
+ * stylesheet
*/
public void setSelectorList(Vector selectors) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
- ((CssValidatorListener) e.nextElement()).setSelectorList(
- selectors);
+ ((CssValidatorListener) e.nextElement()).setSelectorList(selectors);
}
}
/**
* used for the output of the stylesheet
- * @param properties A list of properties that are following eachother in
- * the stylesheet (for example: all properties in an @rule)
+ *
+ * @param properties
+ * A list of properties that are following eachother in the
+ * stylesheet (for example: all properties in an
+ * @rule)
*/
public void addProperty(Vector properties) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -626,8 +642,8 @@
}
/**
- * used for the output of the stylesheet
- * used to close a rule when it has been read by the parser
+ * used for the output of the stylesheet used to close a rule when it has
+ * been read by the parser
*/
public void endOfRule() {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -636,9 +652,9 @@
}
/**
- * used for the output of the stylesheet
- * if an error is found this function is used to remove the whole stylerule
- from the memorystructure so that it won't appear on the screen
+ * used for the output of the stylesheet if an error is found this function
+ * is used to remove the whole stylerule from the memorystructure so that it
+ * won't appear on the screen
*/
public void removeThisRule() {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -647,9 +663,10 @@
}
/**
- * used for the output of the stylesheet
- * if an error is found this function is used to remove the whole @rule
- from the memorystructure so that it won't appear on the screen
+ * used for the output of the stylesheet if an error is found this function
+ * is used to remove the whole
+ *
+ * @rule from the memorystructure so that it won't appear on the screen
*/
public void removeThisAtRule() {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -660,8 +677,10 @@
/**
* Adds a vector of properties to a selector.
*
- * @param selector the selector
- * @param declarations Properties to associate with contexts
+ * @param selector
+ * the selector
+ * @param declarations
+ * Properties to associate with contexts
*/
public void handleRule(CssSelectors selector, Vector declarations) {
for (Enumeration e = listeners.elements(); e.hasMoreElements();) {
@@ -673,9 +692,9 @@
/**
* Return the class name for a property
*
- * @param property the property name ('font-size' for example)
- * @return the class name ('org.w3c.css.properties.CssFontSize'
- * for example)
+ * @param property
+ * the property name ('font-size' for example)
+ * @return the class name ('org.w3c.css.properties.CssFontSize' for example)
*/
public String getProperty(String property) {
return properties.getProperty(property);
@@ -691,9 +710,11 @@
/**
* Load the parser properties configuration.
*
- * <p>By default, the parser is configure for cascading style sheet 1.
+ * <p>
+ * By default, the parser is configure for cascading style sheet 1.
*
- * <OL>You have three parser properties :
+ * <OL>
+ * You have three parser properties :
* <LI> style: the class name of your CssStyle.
* <LI> properties: the file name where the parser can find all CSS
* properties names.
@@ -720,8 +741,7 @@
if (mode0 != null) {
mode = mode0.equals("true");
}
- }
- else if (version.equals("css1")) {
+ } else if (version.equals("css1")) {
// load the CssStyle
String classStyle = config.getProperty("style1");
Class style = Class.forName(classStyle);
@@ -852,7 +872,7 @@
} catch (Exception e) {
System.err.println("org.w3c.css.parser.CssFouffa: couldn't"
- +" load the style");
+ + " load the style");
e.printStackTrace();
}
}
@@ -860,7 +880,7 @@
/* config by default! */
static {
try {
- config = new Properties();
+ config = new Utf8Properties();
URL url = CssFouffa.class.getResource("Config.properties");
java.io.InputStream f = url.openStream();
config.load(f);
@@ -873,15 +893,15 @@
__s_nullprop = new CssPropertyFactory(url, allprops);
// css2
-// classStyle = config.getProperty("style2");
-// style = Class.forName(classStyle);
-// url = style.getResource(config.getProperty("properties2"));
-// __s_css2prop = new CssPropertyFactory(url, allprops);
+ // classStyle = config.getProperty("style2");
+ // style = Class.forName(classStyle);
+ // url = style.getResource(config.getProperty("properties2"));
+ // __s_css2prop = new CssPropertyFactory(url, allprops);
__s_css2prop = __s_nullprop;
} catch (Exception e) {
System.err.println("org.w3c.css.parser.CssFouffa: couldn't"
- +" load the config");
+ + " load the config");
e.printStackTrace();
}
}
@@ -901,6 +921,4 @@
loadConfig("css2", null);
}
-
-
}
Received on Tuesday, 12 July 2005 14:48:10 UTC