2002/css-validator/org/w3c/css/css StyleSheetParser.java,1.7,1.8

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

Modified Files:
	StyleSheetParser.java 
Log Message:
for jdk1.2


Index: StyleSheetParser.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/css/StyleSheetParser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- StyleSheetParser.java	8 Sep 2005 12:23:33 -0000	1.7
+++ StyleSheetParser.java	8 Sep 2005 16:37:44 -0000	1.8
@@ -15,6 +15,8 @@
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import java.lang.reflect.Constructor;
+
 import org.w3c.css.parser.AtRule;
 import org.w3c.css.parser.AtRuleMedia;
 import org.w3c.css.parser.AtRulePage;
@@ -39,6 +41,18 @@
 public final class StyleSheetParser 
     implements CssValidatorListener, CssParser {
 
+    private static Constructor co = null;
+
+    static {
+	try {
+	    Class c = java.lang.Exception.class;
+	    Class cp[] = { java.lang.Exception.class };
+	    co = c.getDeclaredConstructor(cp);
+	} catch (NoSuchMethodException ex) {
+	    co = null;
+	}
+    }
+
     CssFouffa  cssFouffa;
     StyleSheet style = new StyleSheet();
 
@@ -64,7 +78,9 @@
      * @param selector     the selector
      * @param declarations Properties to associate with contexts
      */  
-    public void handleRule(ApplContext ac, CssSelectors selector, Vector properties) {
+    public void handleRule(ApplContext ac, CssSelectors selector, 
+			   Vector properties) 
+    {
 	if (selector.getAtRule() instanceof AtRulePage) {
 	    style.remove(selector);
 	}
@@ -261,12 +277,30 @@
 							-1, e));
 	    notifyErrors(er);
 	} catch(TokenMgrError e) {
-	    Errors er = new Errors();	    
-	    er.addError(new org.w3c.css.parser.CssError(url.toString(), e.getErrorLine(), new CssParseException(new Exception(e))));
+	    Errors er = new Errors(); 
+	    CssParseException cpe = null;
+	    if (co != null) {
+		try {
+		    Object o[] = new Object[1];
+		    o[0] = e;
+		    Exception new_e = (Exception) co.newInstance(o);
+		    cpe = new CssParseException(new_e);
+		} catch (Exception ex) {
+		    cpe = null;
+		}
+	    }
+	    if (cpe == null) {
+		cpe = new CssParseException(new Exception(e.getMessage()));
+	    }
+	    er.addError(new org.w3c.css.parser.CssError(url.toString(), 
+							e.getErrorLine(),
+							cpe));
 	    notifyErrors(er);
 	} catch(RuntimeException e) {
 	    Errors er = new Errors();	    
-	    er.addError(new org.w3c.css.parser.CssError(url.toString(), cssFouffa.getLine(), new CssParseException(e)));
+	    er.addError(new org.w3c.css.parser.CssError(url.toString(), 
+							cssFouffa.getLine(),
+						    new CssParseException(e)));
 	    notifyErrors(er);
 	}
     }

Received on Thursday, 8 September 2005 16:38:05 UTC