"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/main/java/com/openkm/extractor/RTFTextExtractor.java" between
OpenKM-document-management-system-6.3.10.tar.gz and OpenKM-document-management-system-6.3.11.tar.gz

About: OpenKM (Knowledge Management) is a document management system that allows easy management of documents, users, roles and finding your enterprise documents and records. Community version (source code).

RTFTextExtractor.java  (OpenKM-document-management-system-6.3.10):RTFTextExtractor.java  (OpenKM-document-management-system-6.3.11)
skipping to change at line 24 skipping to change at line 24
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* <p> * <p>
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
package com.openkm.extractor; package com.openkm.extractor;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.swing.text.DefaultStyledDocument; import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.rtf.RTFEditorKit; import javax.swing.text.rtf.RTFEditorKit;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
/** /**
* Text extractor for Rich Text Format (RTF) * Text extractor for Rich Text Format (RTF)
*/ */
@PluginImplementation
public class RTFTextExtractor extends AbstractTextExtractor { public class RTFTextExtractor extends AbstractTextExtractor {
/** /**
* Logger instance. * Logger instance.
*/ */
private static final Logger logger = LoggerFactory.getLogger(RTFTextExtra ctor.class); private static final Logger log = LoggerFactory.getLogger(RTFTextExtracto r.class);
/** /**
* Creates a new <code>RTFTextExtractor</code> instance. * Creates a new <code>RTFTextExtractor</code> instance.
*/ */
public RTFTextExtractor() { public RTFTextExtractor() {
super(new String[]{"application/rtf", "text/rtf"}); super(new String[]{"application/rtf", "text/rtf"});
} }
// -------------------------------------------------------< TextExtractor > // -------------------------------------------------------< TextExtractor >
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public String extractText(InputStream stream, String type, String encodin g) throws IOException { public String extractText(InputStream stream, String type, String encodin g) throws IOException {
try { try {
RTFEditorKit rek = new RTFEditorKit(); RTFEditorKit rek = new RTFEditorKit();
DefaultStyledDocument doc = new DefaultStyledDocument(); DefaultStyledDocument doc = new DefaultStyledDocument();
rek.read(stream, doc, 0); rek.read(stream, doc, 0);
String text = doc.getText(0, doc.getLength()); return doc.getText(0, doc.getLength());
return text;
} catch (Throwable e) { } catch (Throwable e) {
logger.warn("Failed to extract RTF text content", e); log.warn("Failed to extract RTF text content", e);
throw new IOException(e.getMessage(), e); throw new IOException(e.getMessage(), e);
} finally { } finally {
stream.close(); stream.close();
} }
} }
} }
 End of changes. 6 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)