You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by hi...@apache.org on 2001/02/11 21:36:42 UTC
cvs commit: xml-batik/sources/org/apache/batik/dom/util SAXDocumentFactory.java
hillion 01/02/11 12:36:42
Modified: resources/org/apache/batik/css/resources Messages.properties
sources/org/apache/batik/bridge BufferedDocumentLoader.java
ConcreteGVTBuilder.java DocumentLoader.java
SVGFilterElementBridge.java SVGGradientBridge.java
SVGPatternElementBridge.java SVGUtilities.java
URIResolver.java
sources/org/apache/batik/dom/events EventListenerList.java
sources/org/apache/batik/dom/svg SAXSVGDocumentFactory.java
SVGDocumentLoader.java
sources/org/apache/batik/dom/util SAXDocumentFactory.java
Added: sources/org/apache/batik/bridge
InterruptedBridgeException.java
Log:
Few cleanups.
Revision Changes Path
1.4 +2 -2 xml-batik/resources/org/apache/batik/css/resources/Messages.properties
Index: Messages.properties
===================================================================
RCS file: /home/cvs/xml-batik/resources/org/apache/batik/css/resources/Messages.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Messages.properties 2001/02/05 09:55:27 1.3
+++ Messages.properties 2001/02/11 20:36:40 1.4
@@ -3,13 +3,13 @@
#
bad.unit.type =\
-The given number ({0}) do not represent a valid unit type.
+The given number ({0}) does not represent a valid unit type.
inherit.not.string = \
'inherit' is not a string value.
out.of.range.unit.type = \
-The given number ({0}) represents an invalid unit type.
+The given number ({0}) represents an unknown unit type.
invalid.value = \
The called method cannot be invoked on this value.
1.2 +2 -3 xml-batik/sources/org/apache/batik/bridge/BufferedDocumentLoader.java
Index: BufferedDocumentLoader.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BufferedDocumentLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BufferedDocumentLoader.java 2001/01/23 17:06:20 1.1
+++ BufferedDocumentLoader.java 2001/02/11 20:36:41 1.2
@@ -28,7 +28,7 @@
* oldest document is removed from the cache.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: BufferedDocumentLoader.java,v 1.1 2001/01/23 17:06:20 tkormann Exp $
+ * @version $Id: BufferedDocumentLoader.java,v 1.2 2001/02/11 20:36:41 hillion Exp $
*/
public class BufferedDocumentLoader implements DocumentLoader {
@@ -76,8 +76,7 @@
* @param uri the uri of the document to return
* @exception InterruptedException is thrown if this thread is interrupted.
*/
- public Document loadDocument(String uri) throws DOMException, SAXException,
- IOException {
+ public Document loadDocument(String uri) throws IOException {
int n = uri.indexOf('#');
if (n != -1) {
uri = uri.substring(0, n);
1.7 +21 -6 xml-batik/sources/org/apache/batik/bridge/ConcreteGVTBuilder.java
Index: ConcreteGVTBuilder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ConcreteGVTBuilder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ConcreteGVTBuilder.java 2001/02/06 09:30:47 1.6
+++ ConcreteGVTBuilder.java 2001/02/11 20:36:41 1.7
@@ -8,6 +8,11 @@
package org.apache.batik.bridge;
+import java.io.InterruptedIOException;
+import java.io.IOException;
+
+import java.net.MalformedURLException;
+
import java.util.List;
import org.apache.batik.css.HiddenChildElement;
@@ -48,7 +53,7 @@
* @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
* @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: ConcreteGVTBuilder.java,v 1.6 2001/02/06 09:30:47 tkormann Exp $
+ * @version $Id: ConcreteGVTBuilder.java,v 1.7 2001/02/11 20:36:41 hillion Exp $
*/
public class ConcreteGVTBuilder implements GVTBuilder, SVGConstants {
/**
@@ -56,7 +61,7 @@
* @param ctx the context to use
* @param svgDocument the DOM tree that represents an SVG document
*/
- public GraphicsNode build(BridgeContext ctx, Document svgDocument){
+ public GraphicsNode build(BridgeContext ctx, Document svgDocument) {
ctx.initialize(this);
RootGraphicsNode root = new RootGraphicsNode();
Element svgRoot = svgDocument.getDocumentElement();
@@ -109,7 +114,7 @@
* @param ctx the context to use
* @param element element for which a GVT representation should be built
*/
- public GraphicsNode build(BridgeContext ctx, Element element){
+ public GraphicsNode build(BridgeContext ctx, Element element) {
Bridge bridge = ctx.getBridge(element);
@@ -135,7 +140,7 @@
*/
protected void buildComposite(BridgeContext ctx,
CompositeGraphicsNode composite,
- Node first){
+ Node first) {
for (Node child = first;
child != null;
child = child.getNextSibling()) {
@@ -151,6 +156,10 @@
protected void buildGraphicsNode(BridgeContext ctx,
CompositeGraphicsNode composite,
Element e) {
+ // Check for interruption.
+ if (Thread.currentThread().isInterrupted()) {
+ throw new InterruptedBridgeException();
+ }
Bridge bridge = ctx.getBridge(e);
@@ -240,8 +249,12 @@
buildGraphicsNode(ctx,
(CompositeGraphicsNode)childGVTNode,
inst);
- } catch (Exception ex) {
- ex.printStackTrace();
+ } catch (MalformedURLException ex) {
+ throw new BridgeException(ex.getMessage());
+ } catch (InterruptedIOException ex) {
+ throw new InterruptedBridgeException();
+ } catch (IOException ex) {
+ throw new BridgeException(ex.getMessage());
}
} else if (SVG_SWITCH_TAG.equals(e.getLocalName())) {
for (Node n = e.getFirstChild();
@@ -263,6 +276,8 @@
}
}
gnb.buildGraphicsNode(childGVTNode, ctx, e);
+ } catch (InterruptedBridgeException ex) {
+ throw ex;
} catch (BridgeException ex) {
if (ex.getGraphicsNode() != null) {
GraphicsNode gn = ex.getGraphicsNode();
1.5 +2 -2 xml-batik/sources/org/apache/batik/bridge/DocumentLoader.java
Index: DocumentLoader.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/DocumentLoader.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DocumentLoader.java 2001/01/02 16:11:36 1.4
+++ DocumentLoader.java 2001/02/11 20:36:41 1.5
@@ -17,7 +17,7 @@
* Defines a class that is responsible of loading (creating) a Document.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: DocumentLoader.java,v 1.4 2001/01/02 16:11:36 hillion Exp $
+ * @version $Id: DocumentLoader.java,v 1.5 2001/02/11 20:36:41 hillion Exp $
*/
public interface DocumentLoader {
@@ -25,7 +25,7 @@
* Returns a document from the specified uri.
* @param uri the uri of the document
*/
- Document loadDocument(String uri) throws DOMException, SAXException, IOException;
+ Document loadDocument(String uri) throws IOException;
/**
* Disposes and releases all resources allocated by this document loader.
1.6 +1 -3 xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java
Index: SVGFilterElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFilterElementBridge.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SVGFilterElementBridge.java 2001/02/07 10:24:01 1.5
+++ SVGFilterElementBridge.java 2001/02/11 20:36:41 1.6
@@ -44,7 +44,7 @@
* <tt>Filter</tt>.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: SVGFilterElementBridge.java,v 1.5 2001/02/07 10:24:01 tkormann Exp $
+ * @version $Id: SVGFilterElementBridge.java,v 1.6 2001/02/11 20:36:41 hillion Exp $
*/
public class SVGFilterElementBridge implements FilterBridge, SVGConstants {
@@ -202,8 +202,6 @@
refs.add(url);
} catch(MalformedURLException ex) {
throw new IllegalAttributeValueException("bad url on "+uriStr);
- } catch(SAXException ex) {
- throw new IllegalAttributeValueException("bad document on "+uriStr);
} catch(IOException ex) {
throw new IllegalAttributeValueException("I/O error on "+uriStr);
}
1.5 +1 -3 xml-batik/sources/org/apache/batik/bridge/SVGGradientBridge.java
Index: SVGGradientBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGGradientBridge.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SVGGradientBridge.java 2001/02/06 21:48:44 1.4
+++ SVGGradientBridge.java 2001/02/11 20:36:41 1.5
@@ -41,7 +41,7 @@
* Base class for SVGLinearGradientBridge and SVGRadialGradientBridge
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: SVGGradientBridge.java,v 1.4 2001/02/06 21:48:44 tkormann Exp $
+ * @version $Id: SVGGradientBridge.java,v 1.5 2001/02/11 20:36:41 hillion Exp $
*/
public abstract class SVGGradientBridge implements SVGConstants {
@@ -105,8 +105,6 @@
refs.add(url);
} catch(MalformedURLException ex) {
throw new IllegalAttributeValueException("bad url on "+uriStr);
- } catch(SAXException ex) {
- throw new IllegalAttributeValueException("bad document on "+uriStr);
} catch(IOException ex) {
throw new IllegalAttributeValueException("I/O error on "+uriStr);
}
1.10 +1 -3 xml-batik/sources/org/apache/batik/bridge/SVGPatternElementBridge.java
Index: SVGPatternElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGPatternElementBridge.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SVGPatternElementBridge.java 2001/02/07 09:38:27 1.9
+++ SVGPatternElementBridge.java 2001/02/11 20:36:41 1.10
@@ -45,7 +45,7 @@
* a <tt>PatternPaint</tt>
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: SVGPatternElementBridge.java,v 1.9 2001/02/07 09:38:27 tkormann Exp $
+ * @version $Id: SVGPatternElementBridge.java,v 1.10 2001/02/11 20:36:41 hillion Exp $
*/
public class SVGPatternElementBridge implements PaintBridge, SVGConstants {
@@ -127,8 +127,6 @@
refs.add(url);
} catch(MalformedURLException ex) {
throw new IllegalAttributeValueException("bad url on "+uriStr);
- } catch(SAXException ex) {
- throw new IllegalAttributeValueException("bad document on "+uriStr);
} catch(IOException ex) {
throw new IllegalAttributeValueException("I/O error on "+uriStr);
}
1.7 +1 -3 xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java
Index: SVGUtilities.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGUtilities.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SVGUtilities.java 2001/02/10 01:17:08 1.6
+++ SVGUtilities.java 2001/02/11 20:36:41 1.7
@@ -50,7 +50,7 @@
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: SVGUtilities.java,v 1.6 2001/02/10 01:17:08 vhardy Exp $
+ * @version $Id: SVGUtilities.java,v 1.7 2001/02/11 20:36:41 hillion Exp $
*/
public class SVGUtilities implements SVGConstants {
/**
@@ -637,8 +637,6 @@
refs.add(url);
} catch(MalformedURLException ex) {
throw new IllegalAttributeValueException("bad url on "+uriStr);
- } catch(SAXException ex) {
- throw new IllegalAttributeValueException("bad document on "+uriStr);
} catch(IOException ex) {
throw new IllegalAttributeValueException("I/O error on "+uriStr);
}
1.2 +3 -3 xml-batik/sources/org/apache/batik/bridge/URIResolver.java
Index: URIResolver.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/URIResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URIResolver.java 2001/01/23 17:06:42 1.1
+++ URIResolver.java 2001/02/11 20:36:41 1.2
@@ -30,7 +30,7 @@
* This class is used to resolve the URI that can be found in a SVG document.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: URIResolver.java,v 1.1 2001/01/23 17:06:42 tkormann Exp $
+ * @version $Id: URIResolver.java,v 1.2 2001/02/11 20:36:41 hillion Exp $
*/
public class URIResolver {
/**
@@ -64,7 +64,7 @@
* @param uri The element URI.
*/
public Element getElement(String uri)
- throws MalformedURLException, SAXException, IOException {
+ throws MalformedURLException, IOException {
Node n = getNode(uri);
if (n.getNodeType() == n.DOCUMENT_NODE) {
throw new Error("Documents not allowed");
@@ -77,7 +77,7 @@
* @return The document or the element
*/
public Node getNode(String uri) throws MalformedURLException,
- SAXException, IOException {
+ IOException {
if (documentURI.equals(uri)) {
return document;
}
1.1 xml-batik/sources/org/apache/batik/bridge/InterruptedBridgeException.java
Index: InterruptedBridgeException.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.bridge;
/**
* This class represents the exception thrown by the bridge when the
* current thread was interrupted.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id: InterruptedBridgeException.java,v 1.1 2001/02/11 20:36:41 hillion Exp $
*/
public class InterruptedBridgeException extends BridgeException {
/**
* Creates a new InterruptedBridgeException.
*/
public InterruptedBridgeException() {
super("");
}
}
1.2 +1 -1 xml-batik/sources/org/apache/batik/dom/events/EventListenerList.java
Index: EventListenerList.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/events/EventListenerList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EventListenerList.java 2000/10/10 18:39:06 1.1
+++ EventListenerList.java 2001/02/11 20:36:42 1.2
@@ -14,7 +14,7 @@
* A simple list of EventListener. Listeners are always added at the
* head of the list.
*
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
+ * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
*/
public class EventListenerList {
1.6 +23 -11 xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java
Index: SAXSVGDocumentFactory.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SAXSVGDocumentFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SAXSVGDocumentFactory.java 2001/01/29 15:34:39 1.5
+++ SAXSVGDocumentFactory.java 2001/02/11 20:36:42 1.6
@@ -19,6 +19,8 @@
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.zip.GZIPInputStream;
+
import org.apache.batik.dom.util.SAXDocumentFactory;
import org.w3c.dom.Document;
@@ -32,7 +34,7 @@
* from an URI using SAX2.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SAXSVGDocumentFactory.java,v 1.5 2001/01/29 15:34:39 tkormann Exp $
+ * @version $Id: SAXSVGDocumentFactory.java,v 1.6 2001/02/11 20:36:42 hillion Exp $
*/
public class SAXSVGDocumentFactory
extends SAXDocumentFactory
@@ -58,23 +60,33 @@
}
/**
- * Creates a SVGOMDocument instance.
+ * Creates a SVGOMDocument instance.<br>
+ * This method supports gzipped sources.
* @param uri The document URI.
* @exception IOException if an error occured while reading the document.
*/
public SVGOMDocument createDocument(String uri) throws IOException {
- SVGOMDocument doc;
- InputSource is = new InputSource(uri);
-
+ URL url = null;
try {
- doc = (SVGOMDocument)super.createDocument
- (SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, is);
- if (uri != null) {
- doc.setURLObject(new URL(uri));
- }
+ url = new URL(uri);
} catch (MalformedURLException e) {
- throw new IOException(e.getMessage());
+ throw new IOException("Malformed URL: " + uri);
+ }
+
+ InputStream is = url.openStream();
+ try {
+ is = new GZIPInputStream(is);
+ } catch (IOException e) {
+ is.close();
+ is = url.openStream();
}
+
+ InputSource isrc = new InputSource(is);
+
+ SVGOMDocument doc = (SVGOMDocument)super.createDocument
+ (SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", uri, isrc);
+ doc.setURLObject(url);
+
return doc;
}
1.6 +3 -4 xml-batik/sources/org/apache/batik/dom/svg/SVGDocumentLoader.java
Index: SVGDocumentLoader.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/SVGDocumentLoader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SVGDocumentLoader.java 2001/01/08 13:19:52 1.5
+++ SVGDocumentLoader.java 2001/02/11 20:36:42 1.6
@@ -26,7 +26,7 @@
* This class is responsible on loading an SVG document.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: SVGDocumentLoader.java,v 1.5 2001/01/08 13:19:52 hillion Exp $
+ * @version $Id: SVGDocumentLoader.java,v 1.6 2001/02/11 20:36:42 hillion Exp $
*/
public class SVGDocumentLoader implements DocumentLoader {
@@ -44,9 +44,8 @@
this.documentFactory = new SAXSVGDocumentFactory(parser);
}
- public Document loadDocument(String uri)
- throws DOMException, SAXException, IOException {
- return documentFactory.createDocument(uri, (InputStream)null);
+ public Document loadDocument(String uri) throws IOException {
+ return documentFactory.createDocument(uri);
}
public void dispose() {
1.2 +11 -1 xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java
Index: SAXDocumentFactory.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SAXDocumentFactory.java 2001/01/08 13:19:52 1.1
+++ SAXDocumentFactory.java 2001/02/11 20:36:42 1.2
@@ -9,6 +9,7 @@
package org.apache.batik.dom.util;
import java.io.InputStream;
+import java.io.InterruptedIOException;
import java.io.IOException;
import java.io.Reader;
@@ -35,7 +36,7 @@
* from an URI using SAX2.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SAXDocumentFactory.java,v 1.1 2001/01/08 13:19:52 hillion Exp $
+ * @version $Id: SAXDocumentFactory.java,v 1.2 2001/02/11 20:36:42 hillion Exp $
*/
public class SAXDocumentFactory
extends DefaultHandler
@@ -164,6 +165,10 @@
parser.parse(is);
} catch (SAXException e) {
+ Exception ex = e.getException();
+ if (ex != null && ex instanceof InterruptedIOException) {
+ throw (InterruptedIOException)ex;
+ }
throw new IOException(e.getMessage());
}
@@ -194,6 +199,11 @@
String localName,
String rawName,
Attributes attributes) throws SAXException {
+ // Check for interruption.
+ if (Thread.currentThread().isInterrupted()) {
+ throw new SAXException(new InterruptedIOException());
+ }
+
// Namespaces resolution
int len = attributes.getLength();
namespaces.push();