/************************************************************************* * * 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 * * for a copy of the LGPLv3 License. * ************************************************************************/ package org.openoffice.xmerge; import org.openoffice.xmerge.util.registry.ConverterInfo; import java.io.InputStream; import java.io.IOException; /** *

A PluginFactory encapsulates the * conversions from one Document format to another. * It provides conversions in both directions. Refer to the * * package description for its usage.

* *

Conversion from the "Office" Document * format to a "Device" Document format may * be lossy, i.e. some information may be lost. If a plug-in * implements the DocumentMergerFactory interface, * then there is the possibility for merging the changes done on the * "Device" Document back to the original * "Office" Document via the * DocumentMerger interface.

* *

Plug-ins that convert from the "Device" * Document format to the "Office" * Document format must implement the * DocumentDeserializerFactory interface. Plug-ins * that convert from the "Office" Document * format to the "Device" format must implement the * DocumentSerializerFactory interface. * *

All plug-ins should have an associated Plugin Configuration XML * File which describes the capabilities of the plug-in. If the * plug-in is bundled in a jarfile, then this XML file is also bundled * with the jarfile. The data in the XML file is managed by the * ConverterInfo object. The ConverterInfoMgr * manages a registry of all ConverterInfo objects. For * more information about this XML file, refer to * * org.openoffice.xmerge.util.registry.

* * @author Herbie Ong * @see Document * @see DocumentSerializer * @see DocumentSerializerFactory * @see DocumentDeserializer * @see DocumentDeserializerFactory * @see DocumentMerger * @see DocumentMergerFactory * @see ConverterInfo * @see org.openoffice.xmerge.util.registry.ConverterInfoMgr */ public abstract class PluginFactory { /** * Cached ConvertInfo object. */ private ConverterInfo ciCache; /** * Constructor that caches the ConvertInfo that * corresponds to the registry information for this plug-in. * * @param ci ConvertInfo object. */ public PluginFactory(ConverterInfo ci) { ciCache=ci; } /** * Returns the ConvertInfo that corresponds to this * plug-in. * * @return The ConvertInfo that corresponds to this * plug-in. */ public ConverterInfo getConverterInfo () { return ciCache; } /** *

Create a Document object that corresponds to * the Office data passed in via the InputStream * object. This abstract method must be implemented for each * plug-in.

* *

This method will read from the given InputStream * object. The returned Document object will contain * the necessary data for the other objects created by the * PluginFactory to process, like a * DocumentSerializer object and a * DocumentMerger object.

* * @param name The Document name. * @param is InputStream object corresponding * to the Document. * * @return A Document object representing the * particular Document format for the * PluginFactory. * * @throws IOException If any I/O error occurs. */ public abstract Document createOfficeDocument(String name, InputStream is) throws IOException; /** *

Create a Document object that corresponds to * the Office data passed in via the InputStream * object. This abstract method must be implemented for each * plug-in.

* *

This method will read from the given InputStream * object. The returned Document object will contain * the necessary data for the other objects created by the * PluginFactory to process, like a * DocumentSerializer object and a * DocumentMerger object.

* * @param name The Document name. * @param is InputStream object corresponding * to the Document. * @param isZip boolean to show that the created office * document is to be zipped. * * @return A Document object representing the * particular Document format for the * PluginFactory. * * @throws IOException If any I/O error occurs. */ public abstract Document createOfficeDocument(String name, InputStream is,boolean isZip) throws IOException; /** *

Create a Document object that corresponds to * the device data passed in via the InputStream * object. This abstract method must be implemented for each * plug-in.

* *

This method will read from the given InputStream * object. The returned Document object will contain * the necessary data for the other objects created by the * PluginFactory to process, like a * DocumentSerializer object and a * DocumentMerger object.

* * @param name The Document name. * @param is InputStream object corresponding * to the Document. * * @return A Document object representing the * particular Document format for the * PluginFactory. * * @throws IOException If any I/O error occurs. */ public abstract Document createDeviceDocument(String name, InputStream is) throws IOException; }