Class DocumentHandlerFactory
IDocumentWriter
,IDocumentReader
IDocumentConverter
interfaces.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IDocumentConverter
createDocumentConverter
(DocumentType documentType, String filePath) The staticcreateDocumentConverter
method instantiates a class which implements theIDocumentConverter
interface.static IDocumentConverter
createDocumentOLEConverter
(DocumentType documentType, String filePath) The staticcreateDocumentOLEConverter
method instantiates a class which implements theIDocumentConverter
interface.static IDocumentConverter
createDocumentOLEConverter
(DocumentType documentType, String filePath, SupportedOLETypes oleTypes) The staticcreateDocumentOLEConverter
method instantiates a class which implements theIDocumentConverter
interface.static IDocumentReader
createDocumentReader
(DocumentType documentType, InputStream inputStream) The staticcreateDocumentReader
method instantiates a class which implements theIDocumentReader
interface.static IDocumentReader
createDocumentReader
(DocumentType documentType, String filePath) The staticcreateDocumentReader
method instantiates a class which implements theIDocumentReader
interface.static IDocumentTemplateWriter
createDocumentTemplateWriter
(DocumentType documentType, InputStream inputTemplateStream, String targetPath) The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentTemplateWriter
interface.static IDocumentTemplateWriter
createDocumentTemplateWriter
(DocumentType documentType, String templateFilePath, String targetPath) The staticcreateDocumentTemplateWriter
method instantiates a class which implements theIDocumentTemplateWriter
interface.static IDocumentWriter
createDocumentWriter
(DocumentType documentType, InputStream inputStream, OutputStream outputStream) The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface.static IDocumentWriter
createDocumentWriter
(DocumentType documentType, OutputStream outputStream) The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface.static IDocumentWriter
createDocumentWriter
(DocumentType documentType, String filePath) The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface.
-
Constructor Details
-
DocumentHandlerFactory
public DocumentHandlerFactory()
-
-
Method Details
-
createDocumentWriter
public static IDocumentWriter createDocumentWriter(DocumentType documentType, String filePath) throws Exception The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface. The new object can be used to edit the file given in thefilePath
parameter.The following is one example how to use the createDocumentWriter. The code:
File testFile = File.createTempFile("Testdocs", ".pptx"); IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumfilePath
- - The path of the file which will be edited- Returns:
- The document writer object.
- Throws:
Exception
-
createDocumentWriter
public static IDocumentWriter createDocumentWriter(DocumentType documentType, InputStream inputStream, OutputStream outputStream) throws Exception The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface. The new object can be used to read from the inputstream and write to the stream given in the outputstream parameter *The following is one example how to use the createDocumentWriter. The code:
File testFileRead = File.createTempFile("TestdocsR", ".pptx"); FileInputStream inputStream = new FileInputStream(testFileRead.getPath()); File testFileWrite = File.createTempFile("TestdocsW", ".pptx"); FileOutputStream outputStream = new FileOutputStream(testFileWrite); IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, inputStream, outputStream);
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enuminputStream
- - The input stream from where the document should be readoutputStream
- - The output stream where the edited document should be written- Returns:
- the document writer object
- Throws:
Exception
-
createDocumentWriter
public static IDocumentWriter createDocumentWriter(DocumentType documentType, OutputStream outputStream) throws Exception The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentWriter
interface. The new object can be used to read and write from/to the stream given in the output stream parameterThe following is one example how to use the createDocumentWriter. The code:
File testFileWrite = File.createTempFile("Testdocs", ".pptx"); FileOutputStream outputStream = new FileOutputStream(testFileWrite); IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, outputStream);
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumoutputStream
- - The output stream where the edited document should be written- Returns:
- IDocumentWriter
- Throws:
Exception
-
createDocumentReader
public static IDocumentReader createDocumentReader(DocumentType documentType, String filePath) throws Exception The staticcreateDocumentReader
method instantiates a class which implements theIDocumentReader
interface. The new object can be used to read from the file given in the filepath parameter.The following is one example how to use the createDocumentReader. The code:
IDocumentReader reader = DocumentHandlerFactory.createDocumentReader(DocumentType.Word, "TestFiles/Test.docx");
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumfilePath
- - The path of the file from where the document should be read- Returns:
- IDocumentReader
- Throws:
Exception
-
createDocumentReader
public static IDocumentReader createDocumentReader(DocumentType documentType, InputStream inputStream) throws Exception The staticcreateDocumentReader
method instantiates a class which implements theIDocumentReader
interface. The new object can be used to read from the stream given in the inputStream parameterThe following is one example how to use the createDocumentReader. The code:
File testFileRead = File.createTempFile("Testdocs", ".docx"); FileInputStream inputStream = new FileInputStream(testFileRead.getPath()); IDocumentReader reader = DocumentHandlerFactory.createDocumentReader(DocumentType.Word, inputStream);
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enuminputStream
- - The input stream from where the document should be read- Returns:
- IDocumentReader
- Throws:
Exception
-
createDocumentConverter
public static IDocumentConverter createDocumentConverter(DocumentType documentType, String filePath) throws Exception The staticcreateDocumentConverter
method instantiates a class which implements theIDocumentConverter
interface. The new object can be used to convert the structures in the given document from one format to another formatThe following is one example how to use the createDocumentConverter. The code:
IDocumentConverter converter = DocumentHandlerFactory.createDocumentConverter(DocumentType.Word, "TestFiles/Test.docx");
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumfilePath
- - The path of the file in what the structures should be converted- Returns:
- IDocumentConverter
- Throws:
Exception
-
createDocumentTemplateWriter
public static IDocumentTemplateWriter createDocumentTemplateWriter(DocumentType documentType, String templateFilePath, String targetPath) throws Exception The staticcreateDocumentTemplateWriter
method instantiates a class which implements theIDocumentTemplateWriter
interface. The new reports are to be generated intargetPath
from thetemplateFilePath
document parameter.The following is one example how to use the createDocumentWriter. The code:
File testFile = File.createTempFile("Testdocs", ".pptx"); IDocumentWriter writer = DocumentHandlerFactory.createDocumentTemplateWriter(DocumentType.PPT, testFile.getPath(), "C:\\Reports");
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumtemplateFilePath
- - The path of the document template which will be used as a sourcetargetPath
- - The path of the folder where the generated reports will be written- Returns:
- The template document writer object
- Throws:
Exception
-
createDocumentTemplateWriter
public static IDocumentTemplateWriter createDocumentTemplateWriter(DocumentType documentType, InputStream inputTemplateStream, String targetPath) throws Exception The staticcreateDocumentWriter
method instantiates a class which implements theIDocumentTemplateWriter
interface. The new reports are to be generated intargetPath
from theinputTemplateStream
document parameter.The following is one example how to use the createDocumentWriter. The code:
File testFileRead = File.createTempFile("TestdocsR", ".pptx"); FileInputStream inputStream = new FileInputStream(testFileRead.getPath()); IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, inputStream, "C:\\Reports");
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enuminputTemplateStream
- - The stream of the document template which will be used as a sourcetargetPath
- - The path of the folder where the generated reports will be written- Returns:
- The template document writer object
- Throws:
Exception
-
createDocumentOLEConverter
public static IDocumentConverter createDocumentOLEConverter(DocumentType documentType, String filePath) throws IOException The staticcreateDocumentOLEConverter
method instantiates a class which implements theIDocumentConverter
interface. The document located intargetPath
will be converted from the old-style OLE to JChem for Office objects/shapes embedded document report.The following is one example how to use the OLEConverter. The code:
IDocumentConverter converter = DocumentHandlerFactory.createDocumentOLEConverter(DocumentType.Word, "TestFiles/Test.docx");
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumfilePath
- - File of the target document that needs to be converted from OLE to JChem For Office- Returns:
- The document converter object
- Throws:
IOException
-
createDocumentOLEConverter
public static IDocumentConverter createDocumentOLEConverter(DocumentType documentType, String filePath, SupportedOLETypes oleTypes) throws IOException The staticcreateDocumentOLEConverter
method instantiates a class which implements theIDocumentConverter
interface. The document located intargetPath
will be converted from the old-style OLE to JChem for Office objects/shapes embedded document report.The following is one example how to use the OLEConverter. The code:
IDocumentConverter converter = DocumentHandlerFactory.createDocumentOLEConverter(DocumentType.Word, "TestFiles/Test.docx", SupportedOLETypes.CDX);
- Parameters:
documentType
- - The type of the document. It can be Word or PPT as defined in theDocumentType
enumfilePath
- - File of the target document that needs to be converted from OLE to JChem For OfficeoleTypes
- - if we do not want to convert all types of OLE embeddings to JChem for Office it can be filtered by the Supported OLE types enum By specifying the SupportedOLETypes.CDX value all ChemDraw OLE objects will only be converted.- Returns:
- The document converter object
- Throws:
IOException
-