KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > fileextraction > JahiaMSPowerPointExtractor


1 package org.jahia.services.fileextraction;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.io.Reader JavaDoc;
6
7 import org.apache.slide.extractor.MSPowerPointExtractor;
8 import org.jahia.utils.FileUtils;
9
10
11 /**
12  * <p>Title: HDF Text content extractor file</p>
13  * <p>Description: This classes uses Jakarta's POI library to extract content
14  * from HDF formatted files. Some of the code in this class is not used
15  * currently but might be needed to process other types of files based on
16  * the POI File system.</p>
17  * <p>Copyright: Copyright (c) 2003</p>
18  * <p>Company: Jahia Ltd</p>
19  * @author Serge Huber
20  * @version 1.0
21  */

22
23 public class JahiaMSPowerPointExtractor extends JahiaOfficeExtractor {
24
25     private static org.apache.log4j.Logger logger =
26         org.apache.log4j.Logger.getLogger (JahiaMSPowerPointExtractor.class);
27
28     public JahiaMSPowerPointExtractor(){
29     }
30     
31     /**
32      * This method returns all the text of an HDF file.
33      *
34      * @param path String
35      * @param lastModified long
36      * @param fileStream InputStream
37      * @throws IOException thrown if there was an error while parsing the
38      * file format, notably if the file is an RTF file instead of a HDF file.
39      * @return String
40      */

41     public String JavaDoc getContentAsString(String JavaDoc path, long lastModified,
42                                      InputStream JavaDoc fileStream)
43     throws IOException JavaDoc {
44         return getContentAsString(path, lastModified, fileStream, null);
45     }
46
47     /**
48      * This method returns all the text of an HDF file.
49      *
50      * @param path String
51      * @param lastModified long
52      * @param fileStream InputStream
53      * @param charSet String
54      * @throws IOException thrown if there was an error while parsing the file
55      * @return String
56      */

57     public String JavaDoc getContentAsString(String JavaDoc path, long lastModified,
58                                      InputStream JavaDoc fileStream, String JavaDoc charSet)
59     throws IOException JavaDoc {
60         MSPowerPointExtractor ex = new MSPowerPointExtractor("","","");
61         try {
62             Reader JavaDoc reader = ex.extract(fileStream);
63             return FileUtils.readerToString(reader);
64         } catch ( Throwable JavaDoc t ){
65             logger.debug("Exception extraction file " + path, t);
66             throw new IOException JavaDoc(t.getMessage());
67         }
68     }
69
70 }
71
Popular Tags