1 /*------------------------------------------------------------------------------
2 Name: SvgUtility.java
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Demo code for a svg client using batik
6 Version: $Id: SvgUtility.java 16476 2007-09-06 22:36:52Z laghi $
7 ------------------------------------------------------------------------------*/
8 package javaclients.svg.batik;
9
10 import java.io.IOException;
11 import java.io.Reader;
12 import java.io.InputStream;
13 import java.io.ByteArrayInputStream;
14 import java.io.StringReader;
15
16 import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
17 import org.apache.batik.dom.svg.SVGOMDocument;
18
19
20 /**
21 * @author $Author: laghi $ (michele@laghi.eu)
22 */
23
24 public class SvgUtility
25 {
26 private final static String PARSER_CLASSNAME = "org.apache.crimson.parser.XMLReaderImpl";
27
28 protected SvgUtility ()
29 {
30 }
31
32
33 public static SVGOMDocument createDocument (Reader reader, String dummyURI)
34 throws IOException
35 {
36 SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(PARSER_CLASSNAME);
37 return (org.apache.batik.dom.svg.SVGOMDocument)factory.createDocument(dummyURI, reader);
38 }
39
40
41 public static SVGOMDocument createDocument (InputStream inputStream, String dummyURI)
42 throws IOException
43 {
44 SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(PARSER_CLASSNAME);
45 return (org.apache.batik.dom.svg.SVGOMDocument)factory.createDocument(dummyURI, inputStream);
46 }
47
48
49 public static SVGOMDocument createDocument (String xmlString, String dummyURI) throws IOException
50 {
51 return createDocument(new StringReader(xmlString), dummyURI);
52 }
53
54
55 public static SVGOMDocument createDocument (byte[] byteArray, String dummyURI) throws IOException
56 {
57 return createDocument(new ByteArrayInputStream(byteArray), dummyURI);
58 }
59
60 }
syntax highlighted by Code2HTML, v. 0.9.1