W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2008

2006/unicorn/org/w3c/unicorn/response/parser DefaultParser.java,1.4,1.5 ResponseParser.java,1.1,1.2 ResponseParserFactory.java,1.2,1.3

From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 10 Sep 2008 10:10:42 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1KdMeo-0001z5-SF@lionel-hutz.w3.org>

Update of /sources/public/2006/unicorn/org/w3c/unicorn/response/parser
In directory hutz:/tmp/cvs-serv7539/org/w3c/unicorn/response/parser

Modified Files:
	DefaultParser.java ResponseParser.java 
	ResponseParserFactory.java 
Log Message:
fixed a bug with special characters caused by a deprecated class (now using a StringBuilder)

Index: ResponseParserFactory.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/response/parser/ResponseParserFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ResponseParserFactory.java	17 Jun 2008 13:45:32 -0000	1.2
+++ ResponseParserFactory.java	10 Sep 2008 10:10:40 -0000	1.3
@@ -50,4 +50,18 @@
 		}
 		return null;
 	} 
+
+    public static Response parse(String r, String responseType) {
+		try {
+			Response response = createResponseParser(responseType).parse(r);
+			return response;
+		} catch (SAXException e) {
+			e.printStackTrace();
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	} 
 }

Index: ResponseParser.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/response/parser/ResponseParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ResponseParser.java	20 Feb 2008 15:09:57 -0000	1.1
+++ ResponseParser.java	10 Sep 2008 10:10:40 -0000	1.2
@@ -6,4 +6,5 @@
 
 public interface ResponseParser {
 	public Response parse(InputStream inputStream);
+  public Response parse(String r);
 }

Index: DefaultParser.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/response/parser/DefaultParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- DefaultParser.java	27 Aug 2008 11:54:53 -0000	1.4
+++ DefaultParser.java	10 Sep 2008 10:10:40 -0000	1.5
@@ -15,6 +15,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+
 import org.w3c.unicorn.response.A;
 import org.w3c.unicorn.response.Code;
 import org.w3c.unicorn.response.Error;
@@ -25,6 +27,7 @@
 import org.w3c.unicorn.response.Result;
 import org.w3c.unicorn.response.Warning;
 import org.w3c.unicorn.util.LocalizedString;
+import java.io.*;
 
 /**
  * Default parser class.
@@ -41,7 +44,8 @@
 	 */
 	public Response parse(InputStream inputStream) {
 			try {
-				return swap(org.w3.unicorn.observationresponse.ObservationresponseDocument.Factory.parse(inputStream));
+          org.w3.unicorn.observationresponse.ObservationresponseDocument ord = org.w3.unicorn.observationresponse.ObservationresponseDocument.Factory.parse(inputStream);
+          return swap(ord);
 			} catch (XmlException e) {
 				e.printStackTrace();
 				logger.error("XMLBeansException : " + e.getMessage(), e);
@@ -50,8 +54,25 @@
 				e.printStackTrace();
 				logger.error("XMLBeansException : " + e.getMessage(), e);
 				return null;
-			}
-		
+      }
+
+	}
+
+    /**
+	 * Parses the input and returns the response.
+	 * @param inputStream The input stream.
+	 * @return The corresponding response.
+	 */
+	public Response parse(String r) {
+			try {
+          org.w3.unicorn.observationresponse.ObservationresponseDocument ord = org.w3.unicorn.observationresponse.ObservationresponseDocument.Factory.parse(r);
+          return swap(ord);
+			} catch (XmlException e) {
+				e.printStackTrace();
+				logger.error("XMLBeansException : " + e.getMessage(), e);
+				return null;
+      }
+
 	}
 
 	/**
Received on Wednesday, 10 September 2008 10:11:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:02:30 UTC