19package org.openoffice.xmerge.util.registry;
23import java.util.jar.*;
26import javax.xml.parsers.*;
28import java.net.JarURLConnection;
73 ParserConfigurationException,
org.xml.sax.SAXException,
80 URL url =
new URL(
"jar:" + jar +
"!/META-INF/converter.xml");
81 JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
82 JarEntry jarentry = jarConnection.getJarEntry();
83 JarFile jarfile = jarConnection.getJarFile();
85 if (jarfile ==
null || jarentry ==
null) {
86 throw new IOException(
"Missing jar entry");
90 InputStream istream = jarfile.getInputStream(jarentry);
91 InputSource isource =
new InputSource(istream);
95 DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
100 System.out.println(
"Validating xml...");
101 builderFactory.setValidating(
true);
104 DocumentBuilder builder = builderFactory.newDocumentBuilder();
125 for (
int i=0;
i < converterNodes.getLength();
i++) {
126 converterNode = converterNodes.item(
i);
127 if (converterNode.getNodeType() == Node.ELEMENT_NODE) {
145 Element detailElement;
149 ArrayList<String> deviceMime =
new ArrayList<String>();
156 String xsltDeserial =
null;
160 if (temp.length() != 0) {
165 if (temp.length() != 0) {
169 NodeList detailNodes = e.getChildNodes();
170 for (
int i=0;
i < detailNodes.getLength();
i++) {
172 detailNode = detailNodes.item(
i);
173 if (detailNode.getNodeType() == Node.ELEMENT_NODE) {
175 detailElement = (Element)detailNode;
176 elementTagName = detailElement.getTagName();
178 if (
TAG_NAME.equalsIgnoreCase(elementTagName)) {
180 }
else if (
TAG_DESC.equalsIgnoreCase(elementTagName)) {
182 }
else if (
TAG_VENDOR.equalsIgnoreCase(elementTagName)) {
190 }
else if (
TAG_TARGET.equalsIgnoreCase(elementTagName)) {
192 if (temp.length() != 0) {
193 deviceMime.add(temp);
200 if ((xsltSerial ==
null) || (xsltDeserial ==
null)) {
202 officeMime, deviceMime,
name,
203 desc, version, vendor, classImpl);
206 officeMime, deviceMime,
name,
207 desc, version, vendor, classImpl,
208 xsltSerial, xsltDeserial);
222 NodeList tempNodes = e.getChildNodes();
226 for (
int j=0; j < tempNodes.getLength(); j++) {
227 tempNode = tempNodes.item(j);
228 if (tempNode.getNodeType() == Node.TEXT_NODE) {
229 text = tempNode.getNodeValue().trim();
The ConverterInfoReader pulls a META-INF/converter.xml file out of a jar file and parses it,...
final ArrayList< ConverterInfo > converterInfoList
static final String TAG_CLASS_IMPL
static final String TAG_XSLT_SERIAL
static final String TAG_TARGET
static final String ATTRIB_DEVICE_TYPE
static final String TAG_CONVERTER
static final String TAG_XSLT_DESERIAL
void parseDocument()
Loops over the converter Node in the converter.xml file and processes them.
void parseConverterNode(Element e)
Parses a converter node, pulling the information out of the Node and placing it in a ConverterInfo ob...
static final String TAG_DESC
ConverterInfoReader(String jar, boolean shouldvalidate)
Constructor.
static final String TAG_VENDOR
String getTextValue(Element e)
Helper function to get the text value of an Element.
static final String ATTRIB_OFFICE_TYPE
static final String ATTRIB_VERSION
static final String TAG_NAME
Iterator< ConverterInfo > getConverterInfoEnumeration()
Returns an Enumeration of ConverterInfo objects.
Class for storing the information about a converter plug-in.
This Exception is thrown by converter registry algorithms.
A Document represents any Document to be converted and the resulting Document from any conversion.