summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkitfox2008-02-11 04:49:23 +0100
committerkitfox2008-02-11 04:49:23 +0100
commit1c591f20fce3ad83e43d26b7a9bee83167f98bf8 (patch)
tree1e7a7db0d8b47f3da400b385538ca4072430cad6 /src
parentQuick hack to allow 'currentColor' to be parsed (diff)
downloadsvg-salamander-core-1c591f20fce3ad83e43d26b7a9bee83167f98bf8.tar.gz
svg-salamander-core-1c591f20fce3ad83e43d26b7a9bee83167f98bf8.tar.xz
svg-salamander-core-1c591f20fce3ad83e43d26b7a9bee83167f98bf8.zip
Changed InputStream readers to handle European characters. Reorganised build process
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@49 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/kitfox/svg/SVGUniverse.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java
index 13c8988..c6b3e58 100644
--- a/src/main/java/com/kitfox/svg/SVGUniverse.java
+++ b/src/main/java/com/kitfox/svg/SVGUniverse.java
@@ -317,8 +317,15 @@ public class SVGUniverse implements Serializable
return null;
}
-
- private InputStreamReader createDocumentReader(InputStream is) throws IOException
+ /**
+ * Wraps input stream in a BufferedInputStream. If it is detected that this
+ * input stream is GZIPped, also wraps in a GZIPInputStream for inflation.
+ *
+ * @param is Raw input stream
+ * @return Uncompressed stream of SVG data
+ * @throws java.io.IOException
+ */
+ private InputStream createDocumentInputStream(InputStream is) throws IOException
{
BufferedInputStream bin = new BufferedInputStream(is);
bin.mark(2);
@@ -330,12 +337,12 @@ public class SVGUniverse implements Serializable
if ((b1 << 8 | b0) == GZIPInputStream.GZIP_MAGIC)
{
GZIPInputStream iis = new GZIPInputStream(bin);
- return new InputStreamReader(iis);
+ return iis;
}
else
{
//Plain text
- return new InputStreamReader(bin);
+ return bin;
}
}
@@ -360,7 +367,7 @@ public class SVGUniverse implements Serializable
if (loadedDocs.containsKey(uri) && !forceLoad) return uri;
InputStream is = docRoot.openStream();
- return loadSVG(uri, createDocumentReader(is));
+ return loadSVG(uri, new InputSource(createDocumentInputStream(is)));
}
catch (Throwable t)
{
@@ -378,7 +385,7 @@ public class SVGUniverse implements Serializable
public URI loadSVG(InputStream is, String name, boolean forceLoad) throws IOException
{
- return loadSVG(createDocumentReader(is), name, forceLoad);
+ return loadSVG(createDocumentInputStream(is), name, forceLoad);
}
public URI loadSVG(Reader reader, String name)
@@ -422,7 +429,7 @@ public class SVGUniverse implements Serializable
if (uri == null) return null;
if (loadedDocs.containsKey(uri) && !forceLoad) return uri;
- return loadSVG(uri, reader);
+ return loadSVG(uri, new InputSource(reader));
}
/**
@@ -448,7 +455,8 @@ public class SVGUniverse implements Serializable
}
- protected URI loadSVG(URI xmlBase, Reader is)
+// protected URI loadSVG(URI xmlBase, InputStream is)
+ protected URI loadSVG(URI xmlBase, InputSource is)
{
// Use an instance of ourselves as the SAX event handler
SVGLoader handler = new SVGLoader(xmlBase, this, verbose);
@@ -479,7 +487,7 @@ public class SVGUniverse implements Serializable
}
);
reader.setContentHandler(handler);
- reader.parse(new InputSource(new BufferedReader(is)));
+ reader.parse(is);
// SAXParser saxParser = factory.newSAXParser();
// saxParser.parse(new InputSource(new BufferedReader(is)), handler);