summaryrefslogtreecommitdiff
path: root/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry
diff options
context:
space:
mode:
Diffstat (limited to 'xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry')
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java436
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java536
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java279
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java47
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml135
-rw-r--r--xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/package.html82
6 files changed, 1515 insertions, 0 deletions
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java
new file mode 100644
index 000000000000..359bcbfeb222
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java
@@ -0,0 +1,436 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.xmerge.util.registry;
+
+import java.util.Vector;
+import java.util.Enumeration;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.lang.reflect.Constructor;
+import org.openoffice.xmerge.PluginFactory;
+import org.openoffice.xmerge.DocumentSerializerFactory;
+import org.openoffice.xmerge.DocumentDeserializerFactory;
+import org.openoffice.xmerge.DocumentMergerFactory;
+
+/**
+ * Class for storing the information about a converter plugin.
+ *
+ * @author Brian Cameron
+ */
+public class ConverterInfo {
+
+ /**
+ * Keep track of the valid Office mime types
+ */
+ private static String[] validOfficeTypes;
+ public static String SxwType = "staroffice/sxw";
+ public static String SxcType = "staroffice/sxc";
+
+
+ static {
+ // This needs to be updated to reflect all valid office types.
+ //
+ validOfficeTypes = new String[2];
+ validOfficeTypes[0] = SxwType;
+ validOfficeTypes[1] = SxcType;
+ }
+
+ private String piJarName;
+ private String piOfficeMime;
+ private Vector piDeviceMime;
+ private String piDisplayName;
+ private String piDescription;
+ private String piVersion;
+ private String piVendor;
+ private String piClassImpl;
+ private String piXsltSerial;
+ private String piXsltDeserial;
+ private boolean piCanSerialize = false;
+ private boolean piCanDeserialize = false;
+ private boolean piCanMerge = false;
+ private ClassLoader piClassLoader = null;
+ private PluginFactory piPluginFactory;
+
+
+ /**
+ * The constructor builds a ConverterInfo structure.
+ *
+ * @param jarName The URL of the jarfile.
+ * @param officeMime The office mime-type.
+ * @param deviceMime The device mime-type.
+ * @param displayName The display name.
+ * @param description The description.
+ * @param version The version.
+ * @param vendor The vendor name.
+ * @param impl The implementation class name of
+ * PluginFactory.
+ * @param xsltSerial The url of the serializer xsl stylesheet
+ * @param xsltDeserial The url of the deserializer xsl stylesheet
+ *
+ * @throws RegistryException If <code>ci</code> cannot
+ * be loaded.
+ */
+ public ConverterInfo(String jarName, String officeMime,
+ Vector deviceMime, String displayName, String description,
+ String version, String vendor, String impl,String xsltSerial,
+ String xsltDeserial)
+ throws RegistryException {
+
+ if (isValidOfficeType(officeMime.trim()) == false) {
+ RegistryException re = new RegistryException(
+ "Invalid office type");
+ throw re;
+ }
+
+ piJarName = jarName.trim();
+ piOfficeMime = officeMime.trim();
+ piDeviceMime = deviceMime;
+ piDisplayName = displayName.trim();
+ piDescription = description.trim();
+ piVersion = version.trim();
+ piVendor = vendor.trim();
+ piXsltSerial = xsltSerial.trim();
+ piXsltDeserial= xsltDeserial.trim();
+ piClassImpl = impl.trim();
+ piClassLoader = this.getClass().getClassLoader();
+
+ // Get instance of the PluginFactory.
+ //
+ try {
+ URL jarURL = new URL(jarName);
+ URLClassLoader loader = new URLClassLoader(new URL[] { jarURL },
+ piClassLoader);
+ Class clas = loader.loadClass(piClassImpl);
+ Class[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class };
+ Constructor construct = clas.getConstructor(argumentTypes);
+
+ Object[] arguments = { this };
+ piPluginFactory = ( PluginFactory ) construct.newInstance(arguments);
+
+ // See which interfaces the plug-in PluginFactory supports.
+ //
+ Class[] cl = piPluginFactory.getClass().getInterfaces();
+ for (int i=0; i < cl.length; i++) {
+
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentSerializerFactory")) {
+ piCanSerialize = true;
+ }
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentDeserializerFactory")) {
+ piCanDeserialize = true;
+ }
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentMergerFactory")) {
+ piCanMerge = true;
+ }
+ }
+
+ } catch (Exception e) {
+ RegistryException re = new RegistryException(
+ "Class implementation of the plug-in cannot be loaded.");
+ throw re;
+ }
+ }
+
+ /**
+ * The constructor builds a ConverterInfo structure.
+ *
+ * @param jarName The URL of the jarfile.
+ * @param officeMime The office mime-type.
+ * @param deviceMime The device mime-type.
+ * @param displayName The display name.
+ * @param description The description.
+ * @param version The version.
+ * @param vendor The vendor name.
+ * @param impl The implementation class name of
+ * PluginFactory.
+ *
+ * @throws RegistryException If <code>ci</code> cannot
+ * be loaded.
+ */
+
+
+ public ConverterInfo(String jarName, String officeMime,
+ Vector deviceMime, String displayName, String description,
+ String version, String vendor, String impl)
+ throws RegistryException {
+
+ if (isValidOfficeType(officeMime.trim()) == false) {
+ RegistryException re = new RegistryException(
+ "Invalid office type");
+ throw re;
+ }
+
+ piJarName = jarName.trim();
+ piOfficeMime = officeMime.trim();
+ piDeviceMime = deviceMime;
+ piDisplayName = displayName.trim();
+ piDescription = description.trim();
+ piVersion = version.trim();
+ piVendor = vendor.trim();
+ piClassImpl = impl.trim();
+ piClassLoader = this.getClass().getClassLoader();
+
+ // Get instance of the PluginFactory.
+ //
+ try {
+ URL jarURL = new URL(jarName);
+ URLClassLoader loader = new URLClassLoader(new URL[] { jarURL },
+ piClassLoader);
+ Class clas = loader.loadClass(piClassImpl);
+ Class[] argumentTypes = { org.openoffice.xmerge.util.registry.ConverterInfo.class };
+ Constructor construct = clas.getConstructor(argumentTypes);
+
+ Object[] arguments = { this };
+ piPluginFactory = ( PluginFactory ) construct.newInstance(arguments);
+
+ // See which interfaces the plug-in PluginFactory supports.
+ //
+ Class[] cl = piPluginFactory.getClass().getInterfaces();
+ for (int i=0; i < cl.length; i++) {
+
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentSerializerFactory")) {
+ piCanSerialize = true;
+ }
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentDeserializerFactory")) {
+ piCanDeserialize = true;
+ }
+ if (cl[i].getName().equals("org.openoffice.xmerge.DocumentMergerFactory")) {
+ piCanMerge = true;
+ }
+ }
+
+ } catch (Exception e) {
+ RegistryException re = new RegistryException(
+ "Class implementation of the plug-in cannot be loaded.");
+ throw re;
+ }
+ }
+
+
+
+
+ /**
+ * Create a default constructor so we can use isValidOfficeType
+ * without having to actually have a valid ConverterInfo.
+ */
+ private ConverterInfo() {
+ }
+
+
+ /**
+ * Returns an instance of the DocumentDeserializerFactory interface.
+ *
+ * @return instance of the DocumentDeserializer for this ConverterInfo.
+ */
+ public DocumentSerializerFactory getDocSerializerFactory() {
+ return (DocumentSerializerFactory)piPluginFactory;
+ }
+
+
+ /**
+ * Returns an instance of the DocumentSerializerFactory interface.
+ *
+ * @return instance of the DocumentSerializer for this ConverterInfo.
+ */
+ public DocumentDeserializerFactory getDocDeserializerFactory() {
+ return (DocumentDeserializerFactory)piPluginFactory;
+ }
+
+
+ /**
+ * Returns an instance of the DocumentMergerFactory interface.
+ *
+ * @return instance of the DocumentMergerFactory for this ConverterInfo.
+ */
+ public DocumentMergerFactory getDocMergerFactory() {
+ return (DocumentMergerFactory)piPluginFactory;
+ }
+
+
+ /**
+ * Returns the jar file name.
+ *
+ * @return The jar file name, null if none exists.
+ */
+ public String getJarName() {
+ return piJarName;
+ }
+
+
+ /**
+ * Returns the office mime-type.
+ *
+ * @return The office mime-type, null if none exists.
+ */
+ public String getOfficeMime() {
+ return piOfficeMime;
+ }
+
+
+ /**
+ * Returns an <code>Enumeration</code> of <code>String</code>
+ * objects indicating the device mime-type.
+ *
+ * @return An <code>Enumeration</code> of <code>String</code>
+ * objects indicating the device mime-type.
+ */
+ public Enumeration getDeviceMime() {
+ return(piDeviceMime.elements());
+ }
+
+
+ /**
+ * Returns the display name.
+ *
+ * @return The display name, null if none exists.
+ */
+ public String getDisplayName() {
+ return piDisplayName;
+ }
+
+
+ /**
+ * Returns the description.
+ *
+ * @return The description, null if none exists.
+ */
+ public String getDescription() {
+ return piDescription;
+ }
+
+
+ /**
+ * Returns the version.
+ *
+ * @return The version, null if none exists.
+ */
+ public String getVersion() {
+ return piVersion;
+ }
+
+
+ /**
+ * Returns the vendor name.
+ *
+ * @return The vendor name, null if none exists.
+ */
+ public String getVendor() {
+ return piVendor;
+ }
+
+
+ /**
+ * Returns the implementation class name of PluginFactory.
+ *
+ * @return The implementation class name of PluginFactory,
+ * null if none exists.
+ */
+ public String getClassImpl() {
+ return piClassImpl;
+ }
+
+
+ /**
+ * Returns the PluginFactory instance for this plug-in.
+ *
+ * @return The PluginFactory instance for this plug-in.
+ */
+ public PluginFactory getPluginFactory() {
+ return piPluginFactory;
+ }
+
+
+ /**
+ * Returns true if this plug-in has a serializier, false otherwise.
+ *
+ * @return true if this plug-in has a serializier, false otherwise.
+ */
+ public boolean canSerialize() {
+ return piCanSerialize;
+ }
+
+
+ /**
+ * Returns true if this plug-in has a deserializier, false otherwise.
+ *
+ * @return true if this plug-in has a deserializier, false otherwise.
+ */
+ public boolean canDeserialize() {
+ return piCanDeserialize;
+ }
+
+
+ /**
+ * Returns true if this plug-in has a merger, false otherwise.
+ *
+ * @return true if this plug-in has a merger, false otherwise.
+ */
+ public boolean canMerge() {
+ return piCanMerge;
+ }
+
+
+ /**
+ * Returns true if the officeMime is a valid Office mime type.
+ *
+ * @return true if the officeMime is a valid Office mime type.
+ */
+ public static boolean isValidOfficeType(String officeMime) {
+
+ boolean rc = false;
+ for (int i=0; i < validOfficeTypes.length; i++) {
+ if (officeMime.equals(validOfficeTypes[i])) {
+ rc = true;
+ }
+ }
+
+ return rc;
+ }
+
+ /**
+ * Returns a <code>String</code> containing the Xslt stylesheet url that
+ * is to be used by the Xslt Plugin Serializer.
+ *
+ * @return <code>String</code>
+ */
+
+ public String getXsltSerial() {
+ return piXsltSerial;
+ }
+
+ /**
+ * Returns a <code>String</code> containing the xslt stylesheet url that
+ * is to be used by the Xslt Plugin Deserializer.
+ *
+ * @return <code>String</code>
+ */
+
+ public String getXsltDeserial() {
+ return piXsltDeserial;
+ }
+}
+
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java
new file mode 100644
index 000000000000..0993924c129f
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java
@@ -0,0 +1,536 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.xmerge.util.registry;
+
+import java.util.*;
+import java.io.*;
+
+/**
+ * Manages the converter plug-ins that are currently active.
+ * This class allows plug-ins to be added or removed dynamically.
+ * This class is a singleton (static) class, so that only one
+ * manager can exist at a time. It is final, so it may not be
+ * subclassed.
+ *
+ * @author: Brian Cameron
+ */
+public final class ConverterInfoMgr {
+
+ private static Vector converterInfoList;
+
+ /**
+ * Constructor
+ */
+ static {
+ converterInfoList = new Vector();
+ }
+
+
+ /**
+ * Adds a converter plug-in to the registry. The
+ * <code>ConverterInfo</code> must have a unique DisplayName
+ * and must have non-null values for DisplayName, ClassImpl,
+ * OfficeMime, and DeviceMime.
+ *
+ * @param ConverterInfo A <code>ConverterInfo</code> object
+ * describing a plug-in.
+ *
+ * @throws RegistryException If the <code>ConverterInfo</code>
+ * is not valid.
+ */
+ public static void addPlugIn(ConverterInfo ci) throws RegistryException {
+
+ ConverterInfo converterInfo;
+
+ // Validate
+ //
+ if (ci.getDisplayName() == null) {
+ RegistryException re = new RegistryException(
+ "Converter must have valid name.");
+ throw re;
+ }
+ if (ci.getClassImpl() == null) {
+ RegistryException re = new RegistryException(
+ "Converter must have valid class implementation specified.");
+ throw re;
+ }
+ if (ci.getOfficeMime() == null) {
+ RegistryException re = new RegistryException(
+ "Converter must have valid office mime specified.");
+ throw re;
+ }
+ if (! ci.getDeviceMime().hasMoreElements()) {
+ RegistryException re = new RegistryException(
+ "Converter must have valid device mime specified.");
+ throw re;
+ }
+
+ // Verify there is no converter with the same Display Name in
+ // the registry.
+ //
+ Enumeration ciEnum = converterInfoList.elements();
+ while (ciEnum.hasMoreElements()) {
+ converterInfo = (ConverterInfo)ciEnum.nextElement();
+ if (ci.getDisplayName().equals(converterInfo.getDisplayName())) {
+ RegistryException re = new RegistryException(
+ "Converter with specified display name already exists.");
+ throw re;
+ }
+ }
+
+ // Since this is a adding to a static Vector, make sure this
+ // add method call is synchronized.
+ //
+ synchronized (converterInfoList) {
+ converterInfoList.add(ci);
+ }
+ }
+
+
+ /**
+ * Adds a <code>Vector</code> of converter plug-ins to the registry.
+ * Each <code>ConverterInfo</code> in the <code>Vector</code> must have
+ * a unique DisplayName and must have non-null values for DisplayName,
+ * ClassImpl, OfficeMime, and DeviceMime.
+ *
+ * @param ciVectory A <code>Vector</code> of <code>ConverterInfo</code>
+ * objects describing one or more plug-in(s).
+ *
+ * @throws RegistryException If a <code>ConverterInfo</code> in the
+ * <code>Vector</code> is not valid.
+ */
+ public static void addPlugIn(Enumeration jarEnum) throws RegistryException {
+
+ while (jarEnum.hasMoreElements()) {
+ ConverterInfo converterInfo = (ConverterInfo)jarEnum.nextElement();
+ addPlugIn(converterInfo);
+ }
+ }
+
+
+ /**
+ * Returns an <code>Enumeration</code> of registered
+ * <code>ConverterInfo</code> objects.
+ *
+ * @return An <code>Enumeration</code> containing the currently registered
+ * <code>ConverterInfo</code> objects, an empty
+ * <code>Vector</code> if none exist.
+ */
+ public static Enumeration getConverterInfoEnumeration() {
+ return (converterInfoList.elements());
+ }
+
+
+ /**
+ * Removes any <code>ConverterInfo</code> object from the registry
+ * that have the specified jar name value.
+ *
+ * @param jar The name of the jarfile.
+ *
+ * @return True if a <code>ConverterInfo</code> object was
+ * removed, false otherwise.
+ */
+ public static boolean removeByJar(String jar) {
+
+ ConverterInfo converterInfo;
+ boolean rc = false;
+
+ // FIX (HJ): Has to use an iterator, since we are removing items
+ /*Enumeration ciEnum = converterInfoList.elements();
+ while (ciEnum.hasMoreElements())
+ {
+ converterInfo = (ConverterInfo)ciEnum.nextElement();
+ if (jar.equals(converterInfo.getJarName())) {
+ converterInfoList.remove(converterInfo);
+ rc = true;
+ }
+ }*/
+
+ Iterator ciIter = converterInfoList.iterator();
+ while (ciIter.hasNext())
+ {
+ converterInfo = (ConverterInfo)ciIter.next();
+ if (jar.equals(converterInfo.getJarName())) {
+ ciIter.remove();
+ rc = true;
+ }
+ }
+ return rc;
+ }
+
+
+ /**
+ * Removes any <code>ConverterInfo</code> object from the registry
+ * that have the specified display name value.
+ *
+ * @param name The display name.
+ *
+ * @return True if a <code>ConverterInfo</code> object was
+ * removed, false otherwise.
+ */
+ public static boolean removeByName(String name) {
+
+ ConverterInfo converterInfo;
+ boolean rc = false;
+
+ Enumeration ciEnum = converterInfoList.elements();
+ while (ciEnum.hasMoreElements())
+ {
+ converterInfo = (ConverterInfo)ciEnum.nextElement();
+ if (name.equals(converterInfo.getDisplayName())) {
+ converterInfoList.remove(converterInfo);
+ rc = true;
+ }
+ }
+ return rc;
+ }
+
+
+ /**
+ * Returns the <code>ConverterInfo</code> object that supports
+ * the specified device/office mime type conversion. If there
+ * are multiple <code>ConverterInfo</code> objects registered
+ * that support this conversion, only the first is returned.
+ *
+ * @param deviceMime The device mime.
+ * @param officeMime The office mime.
+ *
+ * @return The first plug-in that supports the specified
+ * conversion.
+ */
+ public static ConverterInfo findConverterInfo(String deviceMime, String officeMime) {
+
+ ConverterInfo converterInfo;
+
+ if (deviceMime == null ||
+ ConverterInfo.isValidOfficeType(officeMime) == false) {
+ return null;
+ }
+
+ // Loop over elements comparing with deviceFromMime
+ //
+ Enumeration ciEnum = converterInfoList.elements();
+ while (ciEnum.hasMoreElements()) {
+
+ converterInfo = (ConverterInfo)ciEnum.nextElement();
+ String toDeviceInfo = (String)converterInfo.getOfficeMime();
+ Enumeration fromEnum = converterInfo.getDeviceMime();
+
+ // Loop over the deviceMime types.
+ //
+ while (fromEnum.hasMoreElements()) {
+ String fromDeviceInfo = (String)fromEnum.nextElement();
+ if (deviceMime.trim().equals(fromDeviceInfo) &&
+ officeMime.trim().equals(toDeviceInfo)) {
+ return (converterInfo);
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Returns an array of two <code>ConverterInfo</code> objects that
+ * can be chained to perform the specified mime type conversion.
+ * If there are multiple <code>ConverterInfo</code> objects that
+ * support this conversion, only the first is returned.
+ *
+ * @param deviceMimeFrom The device from mime.
+ * @param deviceMimeTo The device to mime.
+ *
+ * @return An array of two <code>ConverterInfo</code> objects
+ * that can be chained to perform the specified
+ * conversion.
+ */
+ public static ConverterInfo[] findConverterInfoChain(String deviceFromMime, String deviceToMime) {
+
+ if (deviceFromMime == null || deviceToMime == null) {
+ return null;
+ }
+
+ ConverterInfo[] converterInfo = new ConverterInfo[2];
+
+ // Loop over elements comparing with deviceFromMime
+ //
+ Enumeration cifEnum = converterInfoList.elements();
+ while (cifEnum.hasMoreElements()) {
+
+ converterInfo[0] = (ConverterInfo)cifEnum.nextElement();
+ String fromOfficeInfo = converterInfo[0].getOfficeMime();
+ Enumeration fromEnum = converterInfo[0].getDeviceMime();
+
+ // Loop over the deviceMime types looking for a deviceFromMime
+ // match.
+ //
+ while (fromEnum.hasMoreElements()) {
+ String fromDeviceInfo = (String)fromEnum.nextElement();
+
+ if (deviceFromMime.trim().equals(fromDeviceInfo)) {
+
+ // Found a a match for deviceFrom. Now loop over the
+ // elements comparing with deviceToMime
+ //
+ Enumeration citEnum = converterInfoList.elements();
+ while (citEnum.hasMoreElements()) {
+
+ converterInfo[1] = (ConverterInfo)citEnum.nextElement();
+ String toOfficeInfo = converterInfo[1].getOfficeMime();
+ Enumeration toEnum = converterInfo[1].getDeviceMime();
+
+ // Loop over deviceMime types looking for a
+ // deviceToMime match.
+ //
+ while (toEnum.hasMoreElements()) {
+ String toDeviceInfo = (String)toEnum.nextElement();
+ if (deviceToMime.trim().equals(toDeviceInfo) &&
+ fromOfficeInfo.equals(toOfficeInfo)) {
+
+ // Found a match
+ //
+ return (converterInfo);
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * main to let the user specify what plug-ins to register from
+ * jarfiles and to display the currently registered plug-ins.
+ *
+ * @param args Not used.
+ */
+ public static void main(String args[]) {
+
+ ConverterInfoReader cir = null;
+ boolean validate = false;
+ InputStreamReader isr = new InputStreamReader(System.in);
+ BufferedReader br = new BufferedReader(isr);
+ char c = ' ';
+
+ boolean exitFlag = false;
+ while (exitFlag == false) {
+
+ System.out.println("\nMenu:");
+ System.out.println("(L)oad plug-ins from a jar file");
+ System.out.println("(D)isplay name unload");
+ System.out.println("(J)ar name unload");
+ System.out.println("(F)ind ConverterInfo");
+ System.out.println("(C)ind ConverterInfo chain");
+ System.out.println("(V)iew plug-ins");
+ System.out.println("(T)oggle Validation");
+ System.out.println("(Q)uit\n");
+
+ try {
+ c = br.readLine().toUpperCase().trim().charAt(0);
+ } catch(Exception e) {
+ System.out.println("Invalid entry");
+ System.out.println("Error msg: " + e.getMessage());
+ continue;
+ }
+
+ System.out.println("");
+
+ // Quit
+ //
+ if (c == 'Q') {
+ exitFlag = true;
+
+ // Load by Jarfile
+ //
+ } else if (c == 'L') {
+
+ System.out.println("Enter path to jarfile: ");
+ try {
+ String jarname = br.readLine().trim();
+ cir = new ConverterInfoReader(jarname,validate);
+ } catch (RegistryException e) {
+ System.out.println("Cannot load plug-in ConverterFactory implementation.");
+ System.out.println("Error msg: " + e.getMessage());
+ } catch (Exception e) {
+ System.out.println("Error adding data to registry");
+ System.out.println("Error msg: " + e.getMessage());
+ }
+
+ if (cir != null) {
+ Enumeration jarInfoEnum = cir.getConverterInfoEnumeration();
+ try {
+ ConverterInfoMgr.addPlugIn(jarInfoEnum);
+ } catch (Exception e) {
+ System.out.println("Error adding data to registry");
+ System.out.println("Error msg: " + e.getMessage());
+ }
+ }
+
+ // Unload by Display Name or Jarfile
+ //
+ } else if (c == 'T') {
+ if (validate== true){
+ System.out.println("Validation switched off");
+ validate=false;
+ }else{
+ System.out.println("Validation switched on");
+ validate=true;
+ }
+ } else if (c == 'D' || c == 'J') {
+
+ if (c == 'D') {
+ System.out.println("Enter display name: ");
+ } else {
+ System.out.println("Enter path to jarfile: ");
+ }
+
+ try
+ {
+ String name = br.readLine().trim();
+ boolean rc = false;
+
+ if (c == 'D') {
+ rc = ConverterInfoMgr.removeByName(name);
+ } else {
+ rc = ConverterInfoMgr.removeByJar(name);
+ }
+
+ if (rc == true) {
+ System.out.println("Remove successful.");
+ } else {
+ System.out.println("Remove failed.");
+ }
+
+ } catch (Exception e) {
+ System.out.println("Error removing value from registry");
+ System.out.println("Error msg: " + e.getMessage());
+ }
+
+ // Find Office Mime
+ //
+ } else if (c == 'F' || c == 'C') {
+
+ String findMimeOne = null;
+ String findMimeTwo = null;
+
+ if (c == 'F') {
+ System.out.println("Enter device mime: ");
+ } else {
+ System.out.println("Enter device from mime: ");
+ }
+
+ try {
+ findMimeOne = br.readLine().trim();
+ } catch (Exception e) {
+ System.out.println("Error adding data to registry");
+ System.out.println("Error msg: " + e.getMessage());
+ }
+
+ if (c == 'F') {
+ System.out.println("Enter office mime: ");
+ } else {
+ System.out.println("Enter device to mime: ");
+ }
+
+ try {
+ findMimeTwo = br.readLine().trim();
+ } catch (Exception e) {
+ System.out.println("Error adding data to registry");
+ System.out.println("Error msg: " + e.getMessage());
+ }
+
+ if (c == 'F') {
+ ConverterInfo foundInfo = ConverterInfoMgr.findConverterInfo(findMimeOne, findMimeTwo);
+ if (foundInfo != null) {
+ System.out.println(" Found ConverterInfo");
+ System.out.println(" DisplayName : " + foundInfo.getDisplayName());
+ } else {
+ System.out.println(" Did not find ConverterInfo");
+ }
+ } else {
+ ConverterInfo[] foundInfo = ConverterInfoMgr.findConverterInfoChain(findMimeOne,
+ findMimeTwo);
+ if (foundInfo[0] != null && foundInfo[1] != null ) {
+ System.out.println(" Found ConverterInfo Chain");
+ System.out.println(" DisplayName : " + foundInfo[0].getDisplayName());
+ System.out.println(" DisplayName : " + foundInfo[1].getDisplayName());
+ } else {
+ System.out.println(" Did not find ConverterInfo");
+ }
+ }
+
+ // View
+ //
+ } else if (c == 'V') {
+
+ Enumeration ciEnum = ConverterInfoMgr.getConverterInfoEnumeration();
+
+ int ciCnt = 0;
+ while (ciEnum.hasMoreElements())
+ {
+ System.out.println("");
+ System.out.println(" Displaying converter number " + ciCnt);
+ ConverterInfo converterInfo = (ConverterInfo)ciEnum.nextElement();
+ System.out.println(" DisplayName : " + converterInfo.getDisplayName());
+ System.out.println(" JarFile : " + converterInfo.getJarName());
+ System.out.println(" Description : " + converterInfo.getDescription());
+ System.out.println(" Version : " + converterInfo.getVersion());
+ System.out.println(" OfficeMime : " + converterInfo.getOfficeMime());
+ Enumeration fromEnum = converterInfo.getDeviceMime();
+ int feCnt = 1;
+ while (fromEnum.hasMoreElements())
+ {
+ System.out.println(" DeviceMime : (#" + feCnt + ") : " +
+ (String)fromEnum.nextElement());
+ feCnt++;
+ }
+ if (feCnt == 1) {
+ System.out.println(" DeviceMime : None specified");
+ }
+
+ System.out.println(" Vendor : " + converterInfo.getVendor());
+ System.out.println(" ClassImpl : " + converterInfo.getClassImpl());
+ System.out.println(" XsltSerial : " + converterInfo.getXsltSerial());
+ System.out.println(" XsltDeserial : " + converterInfo.getXsltDeserial());
+ System.out.println(" Serialize : " + converterInfo.canSerialize());
+ System.out.println(" Deserialize : " + converterInfo.canDeserialize());
+ System.out.println(" Merge : " + converterInfo.canMerge());
+ ciCnt++;
+ }
+
+ if (ciCnt == 0) {
+ System.out.println("No converters registered");
+ }
+ } else {
+ System.out.println("Invalid input");
+ }
+ }
+ }
+}
+
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java
new file mode 100644
index 000000000000..238fd59f9608
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoReader.java
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.xmerge.util.registry;
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import org.xml.sax.*;
+import org.w3c.dom.*;
+import javax.xml.parsers.*;
+import java.net.URL;
+import java.net.JarURLConnection;
+
+/**
+ * The <code>ConverterInfoReader</code> pulls a META-INF/converter.xml
+ * file out of a jar file and parses it, providing access to this
+ * information in a <code>Vector</code> of <code>ConverterInfo</code>
+ * objects.
+ *
+ * @author Brian Cameron
+ */
+public class ConverterInfoReader {
+
+ private final static String TAG_CONVERTER = "converter";
+ private final static String ATTRIB_OFFICE_TYPE = "type";
+ private final static String ATTRIB_VERSION = "version";
+ private final static String TAG_NAME = "converter-display-name";
+ private final static String TAG_DESC = "converter-description";
+ private final static String TAG_VENDOR = "converter-vendor";
+ private final static String TAG_CLASS_IMPL = "converter-class-impl";
+ private final static String TAG_TARGET = "converter-target";
+ private final static String ATTRIB_DEVICE_TYPE = "type";
+ private final static String TAG_XSLT_DESERIAL = "converter-xslt-deserialize";
+ private final static String TAG_XSLT_SERIAL = "converter-xslt-serialize";
+ private String jarfilename;
+ private Document document;
+ private Vector converterInfoList;
+
+
+ /**
+ * Constructor. A jar file is passed in. The jar file is
+ * parsed and the <code>Vector</code> of <code>ConverterInfo</code>
+ * objects is built.
+ *
+ * @param jar The URL of the jar file to process.
+ * @param shouldvalidate Boolean to enable or disable xml validation.
+ *
+ * @throws IOException If the jar file cannot
+ * be read or if the
+ * META-INF/converter.xml
+ * can not be read in the
+ * jar file.
+ * @throws ParserConfigurationException If the DocumentBuilder
+ * can not be built.
+ * @throws org.xml.sax.SAXException If the converter.xml
+ * file can not be parsed.
+ * @throws RegistryException If the ConverterFactory
+ * implementation of a
+ * plug-in cannot be loaded.
+ */
+ public ConverterInfoReader(String jar,boolean shouldvalidate) throws IOException,
+ ParserConfigurationException, org.xml.sax.SAXException,
+ RegistryException {
+
+ InputStream istream;
+ InputSource isource;
+ DocumentBuilderFactory builderFactory;
+ DocumentBuilder builder;
+ JarURLConnection jarConnection;
+ JarEntry jarentry;
+ JarFile jarfile;
+ URL url;
+
+ converterInfoList = new Vector();
+ jarfilename = jar;
+
+ // Get Jar via URL
+ //
+ url = new URL("jar:" + jar + "!/META-INF/converter.xml");
+ jarConnection = (JarURLConnection)url.openConnection();
+ jarentry = jarConnection.getJarEntry();
+ jarfile = jarConnection.getJarFile();
+
+ // Build the InputSource
+ //
+ istream = jarfile.getInputStream(jarentry);
+ isource = new InputSource(istream);
+
+ // Get the DOM builder and build the document.
+ //
+ builderFactory = DocumentBuilderFactory.newInstance();
+
+ //DTD validation
+ if (shouldvalidate){
+ System.out.println("Validating xml...");
+ builderFactory.setValidating(true);
+ }
+ //
+ builder = builderFactory.newDocumentBuilder();
+ document = builder.parse(isource);
+
+ // Parse the document.
+ //
+ parseDocument();
+ }
+
+
+ /**
+ * Loops over the <i>converter</i> <code>Node</code> in the converter.xml
+ * file and processes them.
+ *
+ * @throws RegistryException If the plug-in associated with a
+ * specific <i>converter</i> <code>Node</code>
+ * cannot be loaded.
+ */
+ private void parseDocument() throws RegistryException {
+
+ Node converterNode;
+ NodeList converterNodes = document.getElementsByTagName(TAG_CONVERTER);
+
+ for (int i=0; i < converterNodes.getLength(); i++) {
+ converterNode = converterNodes.item(i);
+ if (converterNode.getNodeType() == Node.ELEMENT_NODE) {
+ parseConverterNode((Element)converterNode);
+ }
+ }
+ }
+
+
+ /**
+ * Parses a <i>converter</i> node, pulling the information out of
+ * the <code>Node</code> and placing it in a <code>ConverterInfo</code>
+ * object, and adds that object to a <code>Vector</code> of
+ * <code>ConverterInfo</code> objects.
+ *
+ * @param e The <code>Element</code> corresponding to the
+ * <i>converter</i> XML tag.
+ *
+ *
+ * @throws RegistryException If the plug-in cannot be loaded.
+ */
+ private void parseConverterNode(Element e) throws RegistryException {
+
+ Element detailElement;
+ Node detailNode;
+ String elementTagName;
+ String officeMime = null;
+ Vector deviceMime = new Vector();
+ String name = null;
+ String desc = null;
+ String version = null;
+ String vendor = null;
+ String classImpl = null;
+ String xsltSerial = null;
+ String xsltDeserial= null;
+ String temp;
+
+ temp = e.getAttribute(ATTRIB_OFFICE_TYPE);
+ if (temp.length() != 0) {
+ officeMime = temp;
+ }
+
+ temp = e.getAttribute(ATTRIB_VERSION);
+ if (temp.length() != 0) {
+ version = temp;
+ }
+
+ NodeList detailNodes = e.getChildNodes();
+ for (int i=0; i < detailNodes.getLength(); i++) {
+
+ detailNode = detailNodes.item(i);
+ if (detailNode.getNodeType() == Node.ELEMENT_NODE) {
+
+ detailElement = (Element)detailNode;
+ elementTagName = detailElement.getTagName();
+
+ if (TAG_NAME.equalsIgnoreCase(elementTagName)) {
+ name = getTextValue(detailElement);
+ } else if (TAG_DESC.equalsIgnoreCase(elementTagName)) {
+ desc = getTextValue(detailElement);
+ } else if (TAG_VENDOR.equalsIgnoreCase(elementTagName)) {
+ vendor = getTextValue(detailElement);
+ } else if (TAG_XSLT_SERIAL.equalsIgnoreCase(elementTagName)) {
+ xsltSerial = getTextValue(detailElement);
+ } else if (TAG_XSLT_DESERIAL.equalsIgnoreCase(elementTagName)) {
+ xsltDeserial = getTextValue(detailElement);
+ } else if (TAG_CLASS_IMPL.equalsIgnoreCase(elementTagName)) {
+ classImpl = getTextValue(detailElement);
+ } else if (TAG_TARGET.equalsIgnoreCase(elementTagName)) {
+
+ temp = detailElement.getAttribute(ATTRIB_DEVICE_TYPE);
+ if (temp.length() != 0) {
+ deviceMime.add(temp);
+ }
+ }
+ }
+ }
+ ConverterInfo converterInfo;
+ if ((xsltSerial==null) || (xsltDeserial==null)){
+ converterInfo = new ConverterInfo(jarfilename,
+ officeMime, deviceMime, name,
+ desc, version, vendor,classImpl);
+ }
+ else{
+ converterInfo = new ConverterInfo(jarfilename,
+ officeMime, deviceMime, name,
+ desc, version, vendor,classImpl,
+ xsltSerial,xsltDeserial);
+ }
+ /*ConverterInfo converterInfo = new ConverterInfo(jarfilename,
+ officeMime, deviceMime, name, desc, version, vendor,
+ classImpl);*/
+ converterInfoList.add(converterInfo);
+ }
+
+
+ /**
+ * Helper function to get the text value of an
+ * <code>Element</code>.
+ *
+ * @param e The <code>Element</code> to process.
+ *
+ * @return The text value of the <code>Element</code>.
+ */
+ private String getTextValue(Element e) {
+
+ NodeList tempNodes = e.getChildNodes();
+ String text = null;
+ Node tempNode;
+
+ for (int j=0; j < tempNodes.getLength(); j++) {
+ tempNode = tempNodes.item(j);
+ if (tempNode.getNodeType() == Node.TEXT_NODE) {
+ text = tempNode.getNodeValue().trim();
+ break;
+ }
+ }
+
+ return text;
+ }
+
+
+ /**
+ * Returns an <code>Enumeration</code> of <code>ConverterInfo</code>
+ * objects.
+ *
+ * @return An <code>Enumeration</code> of <code>ConverterInfo</code>
+ * objects.
+ */
+ public Enumeration getConverterInfoEnumeration() {
+ return (converterInfoList.elements());
+ }
+}
+
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java
new file mode 100644
index 000000000000..ea370d386c1c
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/RegistryException.java
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package org.openoffice.xmerge.util.registry;
+
+/**
+ * This <code>Exception</code> is thrown by converter registry
+ * algorithms.
+ */
+public class RegistryException extends Exception {
+
+
+ /**
+ * Exception thrown by merge algorithms.
+ *
+ * @param message Message to be included in the
+ * <code>Exception</code>.
+ */
+ public RegistryException(String message) {
+ super(message);
+ }
+}
+
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml
new file mode 100644
index 000000000000..525546d2f7fc
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/build.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #*************************************************************************
+ #
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+ #*************************************************************************
+ -->
+<project name="xmrg_jooxu_registry" default="main" basedir=".">
+
+ <!-- ================================================================= -->
+ <!-- settings -->
+ <!-- ================================================================= -->
+
+ <!-- project prefix, used for targets and build.lst -->
+ <property name="prj.prefix" value="xmrg"/>
+
+ <!-- name of this sub target used in recursive builds -->
+ <property name="target" value="xmrg_jooxu_registry"/>
+
+ <!-- relative path to project directory -->
+ <property name="prj" value="../../../../../.."/>
+
+ <!-- start of java source code package structure -->
+ <property name="java.dir" value="${prj}/java"/>
+
+ <!-- path component for current java package -->
+ <property name="package" value="org/openoffice/xmerge/util/registry"/>
+
+ <!-- define how to handle CLASSPATH environment -->
+ <property name="build.sysclasspath" value="ignore"/>
+
+ <property environment="env"/>
+ <property name="env.XML_APIS_JAR" value="${solar.jar}/xml-apis.jar"/>
+ <property name="env.XERCES_JAR" value="${solar.jar}/xercesImpl.jar"/>
+
+ <!-- classpath settings for javac tasks -->
+ <path id="classpath">
+ <pathelement location="${build.class}"/>
+ <pathelement location="${env.XML_APIS_JAR}"/>
+ <pathelement location="${env.XERCES_JAR}"/>
+ </path>
+
+ <!-- set whether we want to compile with or without deprecation -->
+ <property name="deprecation" value="on"/>
+
+ <!-- ================================================================= -->
+ <!-- solar build environment targets -->
+ <!-- ================================================================= -->
+
+ <target name="build_dir" unless="build.dir">
+ <property name="build.dir" value="${out}"/>
+ </target>
+
+ <target name="solar" depends="build_dir" if="solar.update">
+ <property name="solar.properties"
+ value="${solar.bin}/solar.properties"/>
+ </target>
+
+ <target name="init" depends="solar">
+ <property name="build.compiler" value="classic"/>
+ <property file="${solar.properties}"/>
+ <property file="${build.dir}/class/solar.properties"/>
+ </target>
+
+ <target name="info">
+ <echo message="--------------------"/>
+ <echo message="${target}"/>
+ <echo message="--------------------"/>
+ </target>
+
+
+ <!-- ================================================================= -->
+ <!-- custom targets -->
+ <!-- ================================================================= -->
+
+ <!-- the main target, called in recursive builds -->
+ <target name="main" depends="info,prepare,compile"/>
+
+ <!-- prepare output directories -->
+ <target name="prepare" depends="init" if="build.class">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.class}"/>
+ </target>
+
+ <!-- compile java sources in ${package} -->
+ <target name="compile" depends="prepare" if="build.class">
+ <javac srcdir="${java.dir}"
+ destdir="${build.class}"
+ debug="${debug}"
+ deprecation="${deprecation}"
+ optimize="${optimize}">
+ <classpath refid="classpath"/>
+ <include name="${package}/ConverterInfo.java"/>
+ <include name="${package}/ConverterInfoMgr.java"/>
+ <include name="${package}/ConverterInfoReader.java"/>
+ <include name="${package}/RegistryException.java"/>
+ <include name="${package}/UnoBridgeConverterInfo.java"/>
+ </javac>
+ </target>
+
+ <!-- clean up -->
+ <target name="clean" depends="prepare">
+ <delete includeEmptyDirs="true">
+ <fileset dir="${build.class}">
+ <patternset>
+ <include name="${package}/*.class"/>
+ </patternset>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
+
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/package.html b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/package.html
new file mode 100644
index 000000000000..b6af6262cc5c
--- /dev/null
+++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/package.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ #*************************************************************************
+ #
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ Copyright 2000, 2010 Oracle and/or its affiliates.
+
+ OpenOffice.org - a multi-platform office productivity suite
+
+ This file is part of OpenOffice.org.
+
+ OpenOffice.org is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License version 3
+ only, as published by the Free Software Foundation.
+
+ OpenOffice.org is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License version 3 for more details
+ (a copy is included in the LICENSE file that accompanied this code).
+
+ You should have received a copy of the GNU Lesser General Public License
+ version 3 along with OpenOffice.org. If not, see
+ <http://www.openoffice.org/license.html>
+ for a copy of the LGPLv3 License.
+
+ #*************************************************************************
+ -->
+<html>
+<head>
+<title>org.openoffice.xmerge.util.registry package</title>
+</head>
+
+<body bgcolor="white">
+
+<p>Provides an interface for plug-in registration. Each plug-in must
+have a corresponding Plugin Configuration XML File which is named
+converter.xml. If the plug-in is stored in a jarfile, this
+converter.xml file is typically stored in the following location in
+the jarfile:</p>
+
+<blockquote>
+ META-INF/converter.xml
+</blockquote>
+
+<p>The Plugin Configuration XML File must validate against the
+converter.dtd file provided with this package. Since a jarfile
+can contain multiple plug-ins, this DTD supports specifying multiple
+plug-ins per jarfile. Please refer to the SDK document for more
+information about how to implement a Plugin Configuration XML File
+for a specific plugin.</p>
+
+<p>All information in the Plugin Configuratino XML File is bundled
+into one or more <code>ConverterInfo</code> object. The
+<code>ConverterInfoReader</code> object is used to build a
+<code>Vector</code> of <code>ConverterInfo</code> objects from a
+jarfile.</p>
+
+<p>The <code>ConverterInfoMgr</code> manages the registry of
+<code>ConverterInfo</code>. It is a singleton class, so that only one
+registry manager will ever exist. It is the client program's
+responsibility to register <code>ConverterInfo</code> objects that
+correspond to the plug-ins that are to be used.</p>
+
+<h2>TODO/IDEAS list</h2>
+
+<p><ol>
+<li>The <code>ConverterInfo</code> object could contain
+ <code>org.w3c.dom.Document</code> fragments that are accessed in a
+ generic fashion rather than get/set methods for each item in the DTD.
+ This would provide a more flexible approach, especially for adding
+ custom tags to a specific Plugin Configuration XML file (tags that
+ are only used by its associated plug-in).
+<li><code>ConverterInfo</code> should allow the merge/serialize/deserialize
+ logic to be included in separate plug-ins, if desired.</li>
+<li><code>ConverterInfoMgr</code> could use the Java Activation
+ Framework (JAF) to manage registration.</li>
+</ol></p>
+
+</body>
+</html>