KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > image > XMLImage


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: XMLImage.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.image;
21
22 // Java
23
import org.w3c.dom.Document JavaDoc;
24 import javax.xml.parsers.SAXParserFactory JavaDoc;
25
26 /**
27  * This is an implementation for XML-based images such as SVG.
28  *
29  * @see AbstractFopImage
30  * @see FopImage
31  */

32 public class XMLImage extends AbstractFopImage {
33
34     private Document JavaDoc doc;
35     private String JavaDoc namespace = "";
36
37     /**
38      * @see org.apache.fop.image.AbstractFopImage#AbstractFopImage(FopImage.ImageInfo)
39      */

40     public XMLImage(FopImage.ImageInfo imgInfo) {
41         super(imgInfo);
42         if (imgInfo.data instanceof Document JavaDoc) {
43             doc = (Document JavaDoc)imgInfo.data;
44             loaded = loaded | ORIGINAL_DATA;
45         }
46         namespace = imgInfo.str;
47     }
48
49     /**
50      * Returns the fully qualified classname of an XML parser for
51      * Batik classes that apparently need it (error messages, perhaps)
52      * @return an XML parser classname
53      */

54     public static String JavaDoc getParserName() {
55         try {
56             SAXParserFactory JavaDoc factory = SAXParserFactory.newInstance();
57             return factory.newSAXParser().getXMLReader().getClass().getName();
58         } catch (Exception JavaDoc e) {
59             return null;
60         }
61     }
62
63     /**
64      * Returns the XML document as a DOM document.
65      * @return the DOM document
66      */

67     public Document JavaDoc getDocument() {
68         return this.doc;
69     }
70
71     /**
72      * Returns the namespace of the XML document.
73      * @return the namespace
74      */

75     public String JavaDoc getNameSpace() {
76         return this.namespace;
77     }
78 }
79
Popular Tags