- 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/css
In directory hutz:/tmp/cvs-serv17634/css/css
Modified Files:
StyleSheetGenerator.java StyleSheetGenerator2.java
StyleSheetGeneratorHTML.java StyleSheetGeneratorHTML2.java
Log Message:
Utf8 properties (Jean-Guilhem Rouel)
Index: StyleSheetGeneratorHTML.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGeneratorHTML.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- StyleSheetGeneratorHTML.java 19 May 2002 04:16:31 -0000 1.2
+++ StyleSheetGeneratorHTML.java 12 Jul 2005 14:47:55 -0000 1.3
@@ -6,6 +6,9 @@
// Please first read the full copyright statement in file COPYRIGHT.html
/*
* $Log$
+ * Revision 1.3 2005/07/12 14:47:55 ylafon
+ * Utf8 properties (Jean-Guilhem Rouel)
+ *
* Revision 1.2 2002/05/19 04:16:31 plehegar
* Replaced the email address
*
@@ -17,38 +20,31 @@
*/
package org.w3c.css.css;
-import java.io.PrintWriter;
-import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
+import java.text.DateFormat;
import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Locale;
-import java.text.DateFormat;
+import java.util.StringTokenizer;
-import org.w3c.css.parser.analyzer.ParseException;
-import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.Errors;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
-import org.w3c.css.parser.CssFouffa;
+import org.w3c.css.parser.CssParseException;
import org.w3c.css.parser.CssPrinterStyle;
import org.w3c.css.parser.CssSelectors;
-import org.w3c.css.parser.CssSelectorsConstant;
-import org.w3c.css.parser.AtRule;
-import org.w3c.css.parser.AtRulePage;
-import org.w3c.css.parser.AtRuleMedia;
-import org.w3c.css.parser.AtRuleFontFace;
+import org.w3c.css.parser.Errors;
import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.util.SortedHashtable;
-import org.w3c.css.util.Warnings;
-import org.w3c.css.util.Warning;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
-import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
/**
* @version $Revision$
@@ -56,56 +52,63 @@
public final class StyleSheetGeneratorHTML implements CssPrinterStyle {
StyleSheet style;
+
SortedHashtable items;
+
Warnings warnings;
+
Errors errors;
+
ApplContext ac;
private CssSelectors selector;
+
private CssProperty property;
+
private PrintWriter out;
+
private int warningLevel;
- private Properties general;
- private static Properties availableFormat;
- private static Properties availablePropertiesURL;
+ private Utf8Properties general;
+
+ private static Utf8Properties availableFormat;
+
+ private static Utf8Properties availablePropertiesURL;
+
private static Hashtable formats = new Hashtable();
/**
* Create a new StyleSheetGenerator
*
- * @param title The title for the generated document
- * @param style The style sheet
- * @param document The name of the source file
- * @param warningLevel If you want to reduce warning output.
- * (-1 means no warnings)
+ * @param title
+ * The title for the generated document
+ * @param style
+ * The style sheet
+ * @param document
+ * The name of the source file
+ * @param warningLevel
+ * If you want to reduce warning output. (-1 means no warnings)
*/
- public StyleSheetGeneratorHTML(ApplContext ac,
- String title,
- StyleSheet style,
- String document,
- int warningLevel) {
+ public StyleSheetGeneratorHTML(ApplContext ac, String title,
+ StyleSheet style, String document, int warningLevel) {
this.ac = ac;
this.style = style;
- general = new Properties(setDocumentBase(getDocumentName(ac, document)));
+ general = new Utf8Properties(setDocumentBase(getDocumentName(ac, document)));
general.put("file-title", title);
warnings = style.getWarnings();
errors = style.getErrors();
items = (SortedHashtable) style.getRules();
this.warningLevel = warningLevel;
- general.put("errors-count",
- Integer.toString(errors.getErrorCount()));
- general.put("warnings-count",
- Integer.toString(warnings.getWarningCount()));
- general.put("rules-count",
- Integer.toString(items.size()));
+ general.put("errors-count", Integer.toString(errors.getErrorCount()));
+ general.put("warnings-count", Integer.toString(warnings
+ .getWarningCount()));
+ general.put("rules-count", Integer.toString(items.size()));
if (errors.getErrorCount() == 0) {
desactivateError();
}
- if ((errors.getErrorCount() != 0)
- || (!title.startsWith("http://"))) {
+ if ((errors.getErrorCount() != 0) || (!title.startsWith("http://"))) {
general.put("no-errors", "");
}
@@ -126,21 +129,19 @@
general.put("no-error-or-warning", "");
}
- if (Util.onDebug) general.list(System.err);
+ if (Util.onDebug)
+ general.list(System.err);
DateFormat df = null;
if (ac.getLang() != null) {
try {
- df = DateFormat
- .getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL,
- new Locale(ac.getLang().substring(0, 2),
- "US"));
+ df = DateFormat.getDateTimeInstance(DateFormat.FULL,
+ DateFormat.FULL, new Locale(ac.getLang()
+ .substring(0, 2), "US"));
} catch (Exception e) {
df = DateFormat.getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL,
- Locale.US);
+ DateFormat.FULL, Locale.US);
}
}
if (df != null) {
@@ -189,7 +190,7 @@
}
public void print(CssProperty property) {
- Properties prop = new Properties(general);
+ Utf8Properties prop = new Utf8Properties(general);
prop.put("property-name", property.getPropertyName().toString());
prop.put("property-value", property.toString());
@@ -199,12 +200,11 @@
out.print(processStyle(prop.getProperty("declaration"), prop));
}
- public void produceParseException(CssParseException error,
- StringBuffer ret) {
+ public void produceParseException(CssParseException error, StringBuffer ret) {
if (error.getContexts() != null && error.getContexts().size() != 0) {
StringBuffer buf = new StringBuffer();
- for (Enumeration e = error.getContexts().elements();
- e.hasMoreElements();) {
+ for (Enumeration e = error.getContexts().elements(); e
+ .hasMoreElements();) {
Object t = e.nextElement();
if (t != null) {
buf.append(t);
@@ -233,7 +233,9 @@
} else {
Exception ex = error.getException();
if (ex instanceof NumberFormatException) {
- ret.append(ac.getMsg().getGeneratorString("invalid-number"));
+ ret
+ .append(ac.getMsg().getGeneratorString(
+ "invalid-number"));
} else {
ret.append(queryReplace(ex.getMessage()));
}
@@ -267,15 +269,14 @@
if (errors.getErrorCount() != 0) {
int i = 0;
ret.append("\n<UL>");
- for (CssError[] error = errors.getErrors();
- i < error.length; i++) {
+ for (CssError[] error = errors.getErrors(); i < error.length; i++) {
Exception ex = error[i].getException();
String file = error[i].getSourceFile();
if (!file.equals(oldSourceFile)) {
oldSourceFile = file;
- /* if (i != 0) {
- ret.append("</DL>");
- }*/
+ /*
+ * if (i != 0) { ret.append("</DL>"); }
+ */
ret.append("\n<LI><DL> URI : "
+ "<A TARGET=\"workspace\" HREF=\"");
ret.append(file).append("\">");
@@ -340,8 +341,7 @@
int i = 0;
warnings.sort();
ret.append("\n<UL>");
- for (Warning[] warning = warnings.getWarnings();
- i < warning.length; i++) {
+ for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
Warning warn = warning[i];
if (warn.getLevel() <= warningLevel) {
@@ -355,8 +355,8 @@
ret.append(oldSourceFile).append("\">");
ret.append(oldSourceFile).append("</A>");
}
- if (warn.getLine() != oldLine ||
- !warn.getWarningMessage().equals(oldMessage)) {
+ if (warn.getLine() != oldLine
+ || !warn.getWarningMessage().equals(oldMessage)) {
oldLine = warn.getLine();
oldMessage = warn.getWarningMessage();
ret.append("\n<DD><STRONG> Line : ");
@@ -409,17 +409,16 @@
return processStyle(general.getProperty(s), general);
}
- private String processStyle(String str, Properties prop) {
+ private String processStyle(String str, Utf8Properties prop) {
try {
int i = 0;
while ((i = str.indexOf("<!-- #", i)) >= 0) {
int lastIndexOfEntity = str.indexOf("-->", i);
- String entity =
- str.substring(i+6,
- lastIndexOfEntity - 1).toLowerCase();
+ String entity = str.substring(i + 6, lastIndexOfEntity - 1)
+ .toLowerCase();
if (entity.equals("rule")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceRule();
} else if (entity.equals("selectors")) {
@@ -427,40 +426,40 @@
// contextuals selectors
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
} else {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceSelector(selector);
}
} else if (entity.equals("selector")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceSelector(selector);
} else if (entity.equals("declaration")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceDeclaration();
} else if (entity.equals("warning")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceWarning();
} else if (entity.equals("error")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceError();
} else if (entity.equals("hook-html-validator")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
if (style.getType().equals("text/html")) {
out.println(ac.getMsg().getGeneratorString("doc-html",
@@ -471,8 +470,8 @@
} else {
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
@@ -488,37 +487,37 @@
public final static void printAvailableFormat(PrintWriter out) {
Enumeration e = availableFormat.propertyNames();
- out.println( " -- listing available output format --" );
+ out.println(" -- listing available output format --");
while (e.hasMoreElements()) {
String key = ((String) e.nextElement()).toLowerCase();
- out.println( "Format : " + key );
- out.println( " File : " + getDocumentName(null, key) );
+ out.println("Format : " + key);
+ out.println(" File : " + getDocumentName(null, key));
}
out.flush();
}
- private Properties setDocumentBase(String document) {
- Properties properties = (Properties) formats.get(document);
+ private Utf8Properties setDocumentBase(String document) {
+ Utf8Properties properties = (Utf8Properties) formats.get(document);
if (properties == null) {
URL url;
- properties = new Properties();
+ properties = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource(document);
java.io.InputStream f = url.openStream();
properties.load(f);
f.close();
- properties.put("author","www-validator-css");
+ properties.put("author", "www-validator-css");
properties.put("author-email", "Email.html");
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load properties " + document);
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
printAvailableFormat(new PrintWriter(System.err));
}
formats.put(document, properties);
}
- return new Properties(properties);
+ return new Utf8Properties(properties);
}
private final static String getDocumentName(ApplContext ac,
@@ -538,8 +537,8 @@
if (minusIndex != -1) {
// suppressed -cn in zh-cn (example)
l = l.substring(0, minusIndex);
- document = availableFormat.getProperty(documentName
- + "." + l);
+ document = availableFormat.getProperty(documentName + "."
+ + l);
}
if (document != null) {
break;
@@ -550,8 +549,8 @@
document = availableFormat.getProperty(documentName);
}
if (document == null) {
- System.err.println( "Unable to find " +
- documentName + " output format" );
+ System.err.println("Unable to find " + documentName
+ + " output format");
return documentName;
} else {
return document;
@@ -564,7 +563,7 @@
static {
URL url;
- availableFormat = new Properties();
+ availableFormat = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("format.properties");
java.io.InputStream f = url.openStream();
@@ -573,10 +572,10 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load format properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
- availablePropertiesURL = new Properties();
+ availablePropertiesURL = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("urls.properties");
java.io.InputStream f = url.openStream();
@@ -585,7 +584,7 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load URLs properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
}
}
Index: StyleSheetGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- StyleSheetGenerator.java 8 Apr 2002 21:16:38 -0000 1.2
+++ StyleSheetGenerator.java 12 Jul 2005 14:47:55 -0000 1.3
@@ -6,6 +6,9 @@
// Please first read the full copyright statement in file COPYRIGHT.html
/*
* $Log$
+ * Revision 1.3 2005/07/12 14:47:55 ylafon
+ * Utf8 properties (Jean-Guilhem Rouel)
+ *
* Revision 1.2 2002/04/08 21:16:38 plehegar
* New
*
@@ -42,35 +45,26 @@
*/
package org.w3c.css.css;
-import java.io.PrintWriter;
-import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
import java.util.Enumeration;
-import org.w3c.css.util.Date;
+import java.util.Hashtable;
-import org.w3c.css.parser.analyzer.ParseException;
-import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.AtRule;
-import org.w3c.css.parser.AtRulePage;
-import org.w3c.css.parser.AtRuleMedia;
-import org.w3c.css.parser.AtRuleFontFace;
-import org.w3c.css.parser.Errors;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
-import org.w3c.css.parser.CssFouffa;
+import org.w3c.css.parser.CssParseException;
import org.w3c.css.parser.CssPrinterStyle;
-import org.w3c.css.parser.CssSelectorsConstant;
import org.w3c.css.parser.CssSelectors;
+import org.w3c.css.parser.Errors;
import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.Date;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.SortedHashtable;
-import org.w3c.css.util.Warnings;
-import org.w3c.css.util.Warning;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
-
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
/**
* @version $Revision$
@@ -79,48 +73,54 @@
// SortedHashtable items;
Hashtable items;
+
Warnings warnings;
+
Errors errors;
private CssSelectors selector;
+
private CssProperty property;
+
private PrintWriter out;
+
private int warningLevel;
- private Properties general;
- private static Properties availableFormat;
+ private Utf8Properties general;
+
+ private static Utf8Properties availableFormat;
+
private static Hashtable formats = new Hashtable();
/**
* Create a new StyleSheetGenerator
*
- * @param title The title for the generated document
- * @param style The style sheet
- * @param document The name of the source file
- * @param warningLevel If you want to reduce warning output.
- * (-1 means no warnings)
+ * @param title
+ * The title for the generated document
+ * @param style
+ * The style sheet
+ * @param document
+ * The name of the source file
+ * @param warningLevel
+ * If you want to reduce warning output. (-1 means no warnings)
*/
- public StyleSheetGenerator(String title,
- StyleSheet style,
- String document,
+ public StyleSheetGenerator(String title, StyleSheet style, String document,
int warningLevel) {
- general = new Properties(setDocumentBase(getDocumentName(document)));
+ general = new Utf8Properties(setDocumentBase(getDocumentName(document)));
general.put("file-title", title);
general.put("today", new Date().toString());
warnings = style.getWarnings();
errors = style.getErrors();
- //items = (SortedHashtable) style.getRules();
+ // items = (SortedHashtable) style.getRules();
items = style.getRules();
this.warningLevel = warningLevel;
- general.put("errors-count",
- Integer.toString(errors.getErrorCount()));
- general.put("warnings-count",
- Integer.toString(warnings.getWarningCount()));
- general.put("rules-count",
- Integer.toString(items.size()));
+ general.put("errors-count", Integer.toString(errors.getErrorCount()));
+ general.put("warnings-count", Integer.toString(warnings
+ .getWarningCount()));
+ general.put("rules-count", Integer.toString(items.size()));
if (errors.getErrorCount() == 0) {
desactivateError();
@@ -141,7 +141,8 @@
general.put("no-error-or-warning", "");
}
- if (Util.onDebug) general.list(System.err);
+ if (Util.onDebug)
+ general.list(System.err);
}
public void desactivateError() {
@@ -161,15 +162,14 @@
out.println("An error occurred during the output "
+ "of your style sheet.");
out.println("Please correct your request ");
- out.println(" or send a mail to "
- + " www-validator-css@w3.org");
+ out.println(" or send a mail to " + " www-validator-css@w3.org");
}
out.flush();
}
public void produceRule() {
- //Object[] array = items.getSortedArray();
+ // Object[] array = items.getSortedArray();
int i = 0;
Object array[] = new Object[items.size()];
for (Enumeration e = items.elements(); e.hasMoreElements(); i++) {
@@ -194,7 +194,7 @@
}
public void print(CssProperty property) {
- Properties prop = new Properties(general);
+ Utf8Properties prop = new Utf8Properties(general);
prop.put("property-name", property.getPropertyName().toString());
prop.put("property-value", property.toString());
@@ -207,8 +207,8 @@
void produceParseException(CssParseException error, StringBuffer ret) {
if (error.getContexts() != null && error.getContexts().size() != 0) {
StringBuffer buf = new StringBuffer();
- for (Enumeration e = error.getContexts().elements();
- e.hasMoreElements();) {
+ for (Enumeration e = error.getContexts().elements(); e
+ .hasMoreElements();) {
Object t = e.nextElement();
if (t != null) {
buf.append(t);
@@ -262,8 +262,7 @@
try {
if (errors.getErrorCount() != 0) {
int i = 0;
- for (CssError[] error = errors.getErrors();
- i < error.length; i++) {
+ for (CssError[] error = errors.getErrors(); i < error.length; i++) {
Exception ex = error[i].getException();
if (!error[i].getSourceFile().equals(oldSourceFile)) {
oldSourceFile = error[i].getSourceFile();
@@ -322,8 +321,7 @@
if (warnings.getWarningCount() != 0) {
int i = 0;
warnings.sort();
- for (Warning[] warning = warnings.getWarnings();
- i < warning.length; i++) {
+ for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
Warning warn = warning[i];
if (warn.getLevel() <= warningLevel) {
@@ -332,8 +330,8 @@
ret.append("\n URI : ");
ret.append(oldSourceFile).append('\n');
}
- if (warn.getLine() != oldLine ||
- !warn.getWarningMessage().equals(oldMessage)) {
+ if (warn.getLine() != oldLine
+ || !warn.getWarningMessage().equals(oldMessage)) {
oldLine = warn.getLine();
oldMessage = warn.getWarningMessage();
ret.append("Line : ").append(oldLine);
@@ -372,7 +370,7 @@
return processStyle(general.getProperty(s), general);
}
- private String processStyle(String str, Properties prop) {
+ private String processStyle(String str, Utf8Properties prop) {
if (str == null) {
return "";
}
@@ -381,12 +379,11 @@
int i = 0;
while ((i = str.indexOf("<!-- #", i)) >= 0) {
int lastIndexOfEntity = str.indexOf("-->", i);
- String entity =
- str.substring(i+6,
- lastIndexOfEntity - 1).toLowerCase();
+ String entity = str.substring(i + 6, lastIndexOfEntity - 1)
+ .toLowerCase();
if (entity.equals("rule")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceRule();
} else if (entity.equals("selectors")) {
@@ -395,44 +392,44 @@
// contextuals selectors
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
} else {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceSelector(selector);
}
out.print("}\n");
} else if (entity.equals("selector")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceSelector(selector);
} else if (entity.equals("declaration")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceDeclaration();
} else if (entity.equals("warning")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceWarning();
} else if (entity.equals("error")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceError();
} else {
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
@@ -448,47 +445,45 @@
public final static void printAvailableFormat(PrintWriter out) {
Enumeration e = availableFormat.propertyNames();
- out.println( " -- listing available output format --" );
+ out.println(" -- listing available output format --");
while (e.hasMoreElements()) {
String key = ((String) e.nextElement()).toLowerCase();
- out.println( "Format : " + key );
- out.println( " File : " + getDocumentName(key) );
+ out.println("Format : " + key);
+ out.println(" File : " + getDocumentName(key));
}
out.flush();
}
- private Properties setDocumentBase(String document) {
- Properties properties = (Properties) formats.get(document);
+ private Utf8Properties setDocumentBase(String document) {
+ Utf8Properties properties = (Utf8Properties) formats.get(document);
if (properties == null) {
URL url;
- properties = new Properties();
+ properties = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource(document);
java.io.InputStream f = url.openStream();
properties.load(f);
f.close();
- properties.put("author","Philippe Le Hegaret");
- properties.put("author-email",
- "www-validator-css@w3.org");
+ properties.put("author", "Philippe Le Hegaret");
+ properties.put("author-email", "www-validator-css@w3.org");
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load properties " + document);
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
printAvailableFormat(new PrintWriter(System.err));
}
formats.put(document, properties);
}
- return new Properties(properties);
+ return new Utf8Properties(properties);
}
private final static String getDocumentName(String documentName) {
- String document =
- availableFormat.getProperty(documentName.toLowerCase());
+ String document = availableFormat.getProperty(documentName
+ .toLowerCase());
if (document == null) {
- System.err.println( "Unable to find " +
- documentName.toLowerCase() +
- " output format" );
+ System.err.println("Unable to find " + documentName.toLowerCase()
+ + " output format");
return documentName;
} else {
return document;
@@ -497,7 +492,7 @@
static {
URL url;
- availableFormat = new Properties();
+ availableFormat = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("format.properties");
java.io.InputStream f = url.openStream();
@@ -506,7 +501,7 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load format properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
}
}
Index: StyleSheetGeneratorHTML2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGeneratorHTML2.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- StyleSheetGeneratorHTML2.java 17 Jan 2005 02:46:33 -0000 1.12
+++ StyleSheetGeneratorHTML2.java 12 Jul 2005 14:47:55 -0000 1.13
@@ -7,88 +7,90 @@
package org.w3c.css.css;
-import java.io.PrintWriter;
-import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
+import java.text.DateFormat;
import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Locale;
-import java.text.DateFormat;
+import java.util.StringTokenizer;
import java.util.Vector;
-import org.w3c.css.parser.analyzer.ParseException;
-import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.Errors;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
-import org.w3c.css.parser.CssFouffa;
+import org.w3c.css.parser.CssParseException;
import org.w3c.css.parser.CssPrinterStyle;
import org.w3c.css.parser.CssSelectors;
-import org.w3c.css.parser.CssSelectorsConstant;
-import org.w3c.css.parser.AtRule;
-import org.w3c.css.parser.AtRulePage;
-import org.w3c.css.parser.AtRuleMedia;
-import org.w3c.css.parser.AtRuleFontFace;
+import org.w3c.css.parser.Errors;
import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.SortedHashtable;
-import org.w3c.css.util.Warnings;
-import org.w3c.css.util.Warning;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
-import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
/**
* @version $Revision$
*/
-public final class StyleSheetGeneratorHTML2 extends StyleReport
- implements CssPrinterStyle {
+public final class StyleSheetGeneratorHTML2 extends StyleReport implements
+ CssPrinterStyle {
StyleSheet style;
+
Vector items;
+
Warnings warnings;
+
Errors errors;
+
ApplContext ac;
private CssSelectors selector;
+
private CssProperty property;
+
private PrintWriter out;
+
private int warningLevel;
- private Properties general;
- private static Properties availableFormat;
- private static Properties availablePropertiesURL;
+ private Utf8Properties general;
+
+ private static Utf8Properties availableFormat;
+
+ private static Utf8Properties availablePropertiesURL;
+
private static Hashtable formats = new Hashtable();
+
int counter = 0;
/**
* Create a new StyleSheetGenerator
*
- * @param title The title for the generated document
- * @param style The style sheet
- * @param document The name of the source file
- * @param warningLevel If you want to reduce warning output.
- * (-1 means no warnings)
+ * @param title
+ * The title for the generated document
+ * @param style
+ * The style sheet
+ * @param document
+ * The name of the source file
+ * @param warningLevel
+ * If you want to reduce warning output. (-1 means no warnings)
*/
- public StyleSheetGeneratorHTML2(ApplContext ac,
- String title,
- StyleSheet style,
- String document,
- int warningLevel) {
-
+ public StyleSheetGeneratorHTML2(ApplContext ac, String title,
+ StyleSheet style, String document, int warningLevel) {
if (document == null) {
document = "html.en";
}
if (Util.onDebug) {
- System.err.println( "document format is " + document );
+ System.err.println("document format is " + document);
}
this.ac = ac;
this.style = style;
- general = new Properties(setDocumentBase(getDocumentName(ac, document)));
+ general = new Utf8Properties(setDocumentBase(getDocumentName(ac, document)));
general.put("file-title", title);
warnings = style.getWarnings();
errors = style.getErrors();
@@ -96,18 +98,15 @@
this.warningLevel = warningLevel;
- general.put("errors-count",
- Integer.toString(errors.getErrorCount()));
- general.put("warnings-count",
- Integer.toString(warnings.getWarningCount()));
- general.put("rules-count",
- Integer.toString(items.size()));
+ general.put("errors-count", Integer.toString(errors.getErrorCount()));
+ general.put("warnings-count", Integer.toString(warnings
+ .getWarningCount()));
+ general.put("rules-count", Integer.toString(items.size()));
if (errors.getErrorCount() == 0) {
desactivateError();
}
- if ((errors.getErrorCount() != 0)
- || (!title.startsWith("http://"))) {
+ if ((errors.getErrorCount() != 0) || (!title.startsWith("http://"))) {
general.put("no-errors", "");
}
if (style.charset == null) {
@@ -130,21 +129,19 @@
general.put("no-error-or-warning", "");
}
- if (Util.onDebug) general.list(System.err);
+ if (Util.onDebug)
+ general.list(System.err);
DateFormat df = null;
if (ac.getLang() != null) {
try {
- df = DateFormat
- .getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL,
- new Locale(ac.getLang().substring(0, 2),
- "US"));
+ df = DateFormat.getDateTimeInstance(DateFormat.FULL,
+ DateFormat.FULL, new Locale(ac.getLang()
+ .substring(0, 2), "US"));
} catch (Exception e) {
df = DateFormat.getDateTimeInstance(DateFormat.FULL,
- DateFormat.FULL,
- Locale.US);
+ DateFormat.FULL, Locale.US);
}
}
if (df != null) {
@@ -179,14 +176,14 @@
Vector atRules = style.newGetRules();
for (int idx = 0; idx < atRules.size(); idx++) {
-// out.print(((CssRuleList)atRules.elementAt(idx)).toHTML());
- ((CssRuleList)atRules.elementAt(idx)).toHTML(out);
+ // out.print(((CssRuleList)atRules.elementAt(idx)).toHTML());
+ ((CssRuleList) atRules.elementAt(idx)).toHTML(out);
out.print("\n");
}
}
public void print(CssProperty property) {
- Properties prop = new Properties(general);
+ Utf8Properties prop = new Utf8Properties(general);
prop.put("property-name", property.getPropertyName().toString());
prop.put("property-value", property.toString());
@@ -196,13 +193,12 @@
out.print(processStyle(prop.getProperty("declaration"), prop));
}
- public void produceParseException(CssParseException error,
- StringBuffer ret) {
+ public void produceParseException(CssParseException error, StringBuffer ret) {
ret.append(' ');
if (error.getContexts() != null && error.getContexts().size() != 0) {
StringBuffer buf = new StringBuffer();
- for (Enumeration e = error.getContexts().elements();
- e.hasMoreElements();) {
+ for (Enumeration e = error.getContexts().elements(); e
+ .hasMoreElements();) {
Object t = e.nextElement();
if (t != null) {
buf.append(t);
@@ -231,7 +227,9 @@
} else {
Exception ex = error.getException();
if (ex instanceof NumberFormatException) {
- ret.append(ac.getMsg().getGeneratorString("invalid-number"));
+ ret
+ .append(ac.getMsg().getGeneratorString(
+ "invalid-number"));
} else {
ret.append(queryReplace(ex.getMessage()));
}
@@ -264,8 +262,7 @@
try {
if (errors.getErrorCount() != 0) {
int i = 0;
- for (CssError[] error = errors.getErrors();
- i < error.length; i++) {
+ for (CssError[] error = errors.getErrors(); i < error.length; i++) {
Exception ex = error[i].getException();
String file = error[i].getSourceFile();
if (!file.equals(oldSourceFile)) {
@@ -273,8 +270,7 @@
if (open) {
ret.append("</ul>\n</div>");
}
- ret.append("\n<div><h3>URI : "
- + "<a href=\"");
+ ret.append("\n<div><h3>URI : " + "<a href=\"");
ret.append(file).append("\">");
ret.append(file).append("</a></h3><ul>");
open = true;
@@ -306,8 +302,8 @@
ret.append(terror.getErrorDescription()).append(" : ");
ret.append(terror.getSkippedString()).append('\n');
} else {
- ret.append("\n<p>" +
- "<span class='error'>Uncaught error</span> ");
+ ret.append("\n<p>"
+ + "<span class='error'>Uncaught error</span> ");
ret.append(ex).append('\n');
if (ex instanceof NullPointerException) {
@@ -341,8 +337,7 @@
if (warnings.getWarningCount() != 0) {
int i = 0;
warnings.sort();
- for (Warning[] warning = warnings.getWarnings();
- i < warning.length; i++) {
+ for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
Warning warn = warning[i];
if (warn.getLevel() <= warningLevel) {
@@ -356,8 +351,8 @@
ret.append(oldSourceFile).append("</a></h3><ul>");
open = true;
}
- if (warn.getLine() != oldLine ||
- !warn.getWarningMessage().equals(oldMessage)) {
+ if (warn.getLine() != oldLine
+ || !warn.getWarningMessage().equals(oldMessage)) {
oldLine = warn.getLine();
oldMessage = warn.getWarningMessage();
ret.append("\n<li><span class='warning'>");
@@ -415,18 +410,17 @@
return processStyle(general.getProperty(s), general);
}
- private String processStyle(String str, Properties prop) {
+ private String processStyle(String str, Utf8Properties prop) {
try {
int i = 0;
while ((i = str.indexOf("<!-- #", i)) >= 0) {
int lastIndexOfEntity = str.indexOf("-->", i);
- String entity =
- str.substring(i+6,
- lastIndexOfEntity - 1).toLowerCase();
+ String entity = str.substring(i + 6, lastIndexOfEntity - 1)
+ .toLowerCase();
if (entity.equals("rule")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceStyleSheet();
} else if (entity.equals("selectors")) {
@@ -434,38 +428,38 @@
// contextuals selectors
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
} else {
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
}
} else if (entity.equals("selector")) {
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
} else if (entity.equals("charset")) {
str = str.substring(lastIndexOfEntity+3);
i = 0;
out.print(style.charset);
} else if (entity.equals("declaration")) {
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
} else if (entity.equals("warning")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceWarning();
} else if (entity.equals("error")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceError();
} else if (entity.equals("hook-html-validator")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
if (style.getType().equals("text/html")) {
out.println(ac.getMsg().getGeneratorString("doc-html",
@@ -476,8 +470,8 @@
} else {
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
@@ -493,39 +487,39 @@
public final static void printAvailableFormat(PrintWriter out) {
Enumeration e = availableFormat.propertyNames();
- out.println( " -- listing available output format --" );
+ out.println(" -- listing available output format --");
while (e.hasMoreElements()) {
String key = ((String) e.nextElement()).toLowerCase();
- out.print( "Format : ");
+ out.print("Format : ");
out.println(key);
- out.print( " File : ");
+ out.print(" File : ");
out.println(getDocumentName(null, key));
}
out.flush();
}
- private Properties setDocumentBase(String document) {
- Properties properties = (Properties) formats.get(document);
+ private Utf8Properties setDocumentBase(String document) {
+ Utf8Properties properties = (Utf8Properties) formats.get(document);
if (properties == null) {
URL url;
- properties = new Properties();
+ properties = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource(document);
java.io.InputStream f = url.openStream();
properties.load(f);
f.close();
- properties.put("author","www-validator-css");
+ properties.put("author", "www-validator-css");
properties.put("author-email", "Email.html");
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load properties " + document);
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
printAvailableFormat(new PrintWriter(System.err));
}
formats.put(document, properties);
}
- return new Properties(properties);
+ return new Utf8Properties(properties);
}
private final static String getDocumentName(ApplContext ac,
@@ -545,8 +539,8 @@
if (minusIndex != -1) {
// suppressed -cn in zh-cn (example)
l = l.substring(0, minusIndex);
- document = availableFormat.getProperty(documentName
- + "." + l);
+ document = availableFormat.getProperty(documentName + "."
+ + l);
}
if (document != null) {
break;
@@ -557,8 +551,8 @@
document = availableFormat.getProperty(documentName);
}
if (document == null) {
- System.err.println( "Unable to find " +
- documentName + " output format" );
+ System.err.println("Unable to find " + documentName
+ + " output format");
return documentName;
} else {
return document;
@@ -571,7 +565,7 @@
static {
URL url;
- availableFormat = new Properties();
+ availableFormat = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("format.properties");
java.io.InputStream f = url.openStream();
@@ -580,10 +574,10 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load format properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
- availablePropertiesURL = new Properties();
+ availablePropertiesURL = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("urls.properties");
java.io.InputStream f = url.openStream();
@@ -592,7 +586,7 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load URLs properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
}
}
Index: StyleSheetGenerator2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetGenerator2.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- StyleSheetGenerator2.java 8 Apr 2002 21:16:38 -0000 1.2
+++ StyleSheetGenerator2.java 12 Jul 2005 14:47:55 -0000 1.3
@@ -2,35 +2,26 @@
package org.w3c.css.css;
-import java.io.PrintWriter;
-import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
import java.util.Enumeration;
-import org.w3c.css.util.Date;
+import java.util.Hashtable;
import java.util.Vector;
-import org.w3c.css.parser.analyzer.ParseException;
-import org.w3c.css.parser.CssParseException;
-import org.w3c.css.parser.AtRule;
-import org.w3c.css.parser.AtRulePage;
-import org.w3c.css.parser.AtRuleMedia;
-import org.w3c.css.parser.AtRuleFontFace;
-import org.w3c.css.parser.Errors;
import org.w3c.css.parser.CssError;
import org.w3c.css.parser.CssErrorToken;
-import org.w3c.css.parser.CssFouffa;
-import org.w3c.css.parser.CssPrinterStyle;
-import org.w3c.css.parser.CssSelectorsConstant;
+import org.w3c.css.parser.CssParseException;
import org.w3c.css.parser.CssSelectors;
+import org.w3c.css.parser.Errors;
import org.w3c.css.properties.CssProperty;
+import org.w3c.css.util.Date;
import org.w3c.css.util.InvalidParamException;
-import org.w3c.css.util.SortedHashtable;
-import org.w3c.css.util.Warnings;
-import org.w3c.css.util.Warning;
+import org.w3c.css.util.Utf8Properties;
import org.w3c.css.util.Util;
+import org.w3c.css.util.Warning;
+import org.w3c.css.util.Warnings;
/**
* @version $Revision$
@@ -39,33 +30,41 @@
// SortedHashtable items;
Hashtable items;
+
Warnings warnings;
+
Errors errors;
private CssSelectors selector;
+
private CssProperty property;
+
private PrintWriter out;
+
private int warningLevel;
- private Properties general;
- private static Properties availableFormat;
+ private Utf8Properties general;
+
+ private static Utf8Properties availableFormat;
+
private static Hashtable formats = new Hashtable();
/**
* Create a new StyleSheetGenerator2
*
- * @param title The title for the generated document
- * @param style The style sheet
- * @param document The name of the source file
- * @param warningLevel If you want to reduce warning output.
- * (-1 means no warnings)
+ * @param title
+ * The title for the generated document
+ * @param style
+ * The style sheet
+ * @param document
+ * The name of the source file
+ * @param warningLevel
+ * If you want to reduce warning output. (-1 means no warnings)
*/
- public StyleSheetGenerator2(String title,
- StyleSheet style,
- String document,
- int warningLevel) {
+ public StyleSheetGenerator2(String title, StyleSheet style,
+ String document, int warningLevel) {
- //this small part prints the stylesheet to the screen
+ // this small part prints the stylesheet to the screen
if (StyleSheetCom.showCSS == true) {
if (style.charset != null) {
@@ -73,11 +72,12 @@
}
Vector atRules = style.newGetRules();
for (int i = 0; i < atRules.size(); i++) {
- System.out.println(((CssRuleList)atRules.elementAt(i)).toString());
+ System.out.println(((CssRuleList) atRules.elementAt(i))
+ .toString());
}
}
- general = new Properties(setDocumentBase(getDocumentName(document)));
+ general = new Utf8Properties(setDocumentBase(getDocumentName(document)));
general.put("file-title", title);
general.put("today", new Date().toString());
@@ -86,12 +86,10 @@
items = style.getRules();
this.warningLevel = warningLevel;
- general.put("errors-count",
- Integer.toString(errors.getErrorCount()));
- general.put("warnings-count",
- Integer.toString(warnings.getWarningCount()));
- general.put("rules-count",
- Integer.toString(items.size()));
+ general.put("errors-count", Integer.toString(errors.getErrorCount()));
+ general.put("warnings-count", Integer.toString(warnings
+ .getWarningCount()));
+ general.put("rules-count", Integer.toString(items.size()));
if (errors.getErrorCount() == 0) {
desactivateError();
@@ -112,7 +110,8 @@
general.put("no-error-or-warning", "");
}
- if (Util.onDebug) general.list(System.err);
+ if (Util.onDebug)
+ general.list(System.err);
}
@@ -133,8 +132,7 @@
out.println("An error occurred during the output "
+ "of your style sheet.");
out.println("Please correct your request ");
- out.println(" or send a mail to "
- + " www-validator-css@w3.org");
+ out.println(" or send a mail to " + " www-validator-css@w3.org");
}
out.flush();
@@ -143,8 +141,8 @@
void produceParseException(CssParseException error, StringBuffer ret) {
if (error.getContexts() != null && error.getContexts().size() != 0) {
StringBuffer buf = new StringBuffer();
- for (Enumeration e = error.getContexts().elements();
- e.hasMoreElements();) {
+ for (Enumeration e = error.getContexts().elements(); e
+ .hasMoreElements();) {
Object t = e.nextElement();
if (t != null) {
buf.append(t);
@@ -198,8 +196,7 @@
try {
if (errors.getErrorCount() != 0) {
int i = 0;
- for (CssError[] error = errors.getErrors();
- i < error.length; i++) {
+ for (CssError[] error = errors.getErrors(); i < error.length; i++) {
Exception ex = error[i].getException();
if (!error[i].getSourceFile().equals(oldSourceFile)) {
oldSourceFile = error[i].getSourceFile();
@@ -258,8 +255,7 @@
if (warnings.getWarningCount() != 0) {
int i = 0;
warnings.sort();
- for (Warning[] warning = warnings.getWarnings();
- i < warning.length; i++) {
+ for (Warning[] warning = warnings.getWarnings(); i < warning.length; i++) {
Warning warn = warning[i];
if (warn.getLevel() <= warningLevel) {
@@ -268,8 +264,8 @@
ret.append("\n URI : ");
ret.append(oldSourceFile).append('\n');
}
- if (warn.getLine() != oldLine ||
- !warn.getWarningMessage().equals(oldMessage)) {
+ if (warn.getLine() != oldLine
+ || !warn.getWarningMessage().equals(oldMessage)) {
oldLine = warn.getLine();
oldMessage = warn.getWarningMessage();
ret.append("Line : ").append(oldLine);
@@ -308,7 +304,7 @@
return processStyle(general.getProperty(s), general);
}
- private String processStyle(String str, Properties prop) {
+ private String processStyle(String str, Utf8Properties prop) {
if (str == null) {
return "";
}
@@ -317,34 +313,33 @@
int i = 0;
while ((i = str.indexOf("<!-- #", i)) >= 0) {
int lastIndexOfEntity = str.indexOf("-->", i);
- String entity =
- str.substring(i+6,
- lastIndexOfEntity - 1).toLowerCase();
+ String entity = str.substring(i + 6, lastIndexOfEntity - 1)
+ .toLowerCase();
if (entity.equals("warning")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceWarning();
} else if (entity.equals("error")) {
out.print(str.substring(0, i));
- str = str.substring(lastIndexOfEntity+3);
+ str = str.substring(lastIndexOfEntity + 3);
i = 0;
produceError();
} else {
String value = prop.getProperty(entity);
if (value != null) {
- str = str.substring(0, i) + value +
- str.substring(lastIndexOfEntity+3);
+ str = str.substring(0, i) + value
+ + str.substring(lastIndexOfEntity + 3);
} else {
i += 6; // skip this unknown entity
}
}
}
- /* if (errors.getErrorCount() == 0 &&
- warnings.getWarningCount() == 0) {
- out.print("No errors or warnings found");
- }*/
+ /*
+ * if (errors.getErrorCount() == 0 && warnings.getWarningCount() ==
+ * 0) { out.print("No errors or warnings found"); }
+ */
return str;
} catch (Exception e) {
e.printStackTrace();
@@ -354,47 +349,45 @@
public final static void printAvailableFormat(PrintWriter out) {
Enumeration e = availableFormat.propertyNames();
- out.println( " -- listing available output format --" );
+ out.println(" -- listing available output format --");
while (e.hasMoreElements()) {
String key = ((String) e.nextElement()).toLowerCase();
- out.println( "Format : " + key );
- out.println( " File : " + getDocumentName(key) );
+ out.println("Format : " + key);
+ out.println(" File : " + getDocumentName(key));
}
out.flush();
}
- private Properties setDocumentBase(String document) {
- Properties properties = (Properties) formats.get(document);
+ private Utf8Properties setDocumentBase(String document) {
+ Utf8Properties properties = (Utf8Properties) formats.get(document);
if (properties == null) {
URL url;
- properties = new Properties();
+ properties = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource(document);
java.io.InputStream f = url.openStream();
properties.load(f);
f.close();
- properties.put("author","Philippe Le Hegaret");
- properties.put("author-email",
- "www-validator-css@w3.org");
+ properties.put("author", "Philippe Le Hegaret");
+ properties.put("author-email", "www-validator-css@w3.org");
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load properties " + document);
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
printAvailableFormat(new PrintWriter(System.err));
}
formats.put(document, properties);
}
- return new Properties(properties);
+ return new Utf8Properties(properties);
}
private final static String getDocumentName(String documentName) {
- String document =
- availableFormat.getProperty(documentName.toLowerCase());
+ String document = availableFormat.getProperty(documentName
+ .toLowerCase());
if (document == null) {
- System.err.println( "Unable to find " +
- documentName.toLowerCase() +
- " output format" );
+ System.err.println("Unable to find " + documentName.toLowerCase()
+ + " output format");
return documentName;
} else {
return document;
@@ -403,7 +396,7 @@
static {
URL url;
- availableFormat = new Properties();
+ availableFormat = new Utf8Properties();
try {
url = StyleSheetGenerator.class.getResource("format.properties");
java.io.InputStream f = url.openStream();
@@ -412,8 +405,7 @@
} catch (Exception e) {
System.err.println("org.w3c.css.css.StyleSheetGenerator: "
+ "couldn't load format properties ");
- System.err.println(" " + e.toString() );
+ System.err.println(" " + e.toString());
}
}
}
-
Received on Tuesday, 12 July 2005 14:48:09 UTC