/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(byte[], java.lang.String) */ @Override public I_CmsExtractionResult extractText(byte[] content, String encoding) throws Exception { String result = ""; try { // RTF always uses ASCII, so we don't need to care about the encoding String input = new String(content); // workaround to remove RTF keywords that cause a NPE in Java 1.4 // this is a known bug in Java 1.4 that was fixed in 1.5 // please see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5042109 for the official bug report input = TS_REMOVE_PATTERN.matcher(input).replaceAll(""); // use build in RTF parser from Swing API RTFEditorKit rtfEditor = new RTFEditorKit(); Document doc = rtfEditor.createDefaultDocument(); rtfEditor.read(new StringReader(input), doc, 0); result = doc.getText(0, doc.getLength()); result = removeControlChars(result); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } return new CmsExtractionResult(result); }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(in); // extract all information rawContent = removeControlChars(m_buffer.toString()); // free buffer memory m_buffer = new StringBuffer(4096); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String result = ""; try { if (CmsStringUtil.isEmpty(encoding)) { encoding = OpenCms.getSystemInfo().getDefaultEncoding(); } result = CmsHtmlExtractor.extractText(in, encoding); result = removeControlChars(result); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } return new CmsExtractionResult(result); } }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String result = ""; try { if (CmsStringUtil.isEmpty(encoding)) { encoding = OpenCms.getSystemInfo().getDefaultEncoding(); } result = CmsHtmlExtractor.extractText(in, encoding); result = removeControlChars(result); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } return new CmsExtractionResult(result); } }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { // first extract the table content rawContent = extractTableContent(getStreamCopy(in)); rawContent = removeControlChars(rawContent); // now extract the meta information using POI POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(getStreamCopy(in)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); }
/** * @see org.opencms.search.extractors.I_CmsTextExtractor#extractText(java.io.InputStream, java.lang.String) */ @Override public I_CmsExtractionResult extractText(InputStream in, String encoding) throws Exception { String rawContent = ""; try { // first extract the text using the text abstraction libary WordExtractor wordExtractor = new WordExtractor(); rawContent = wordExtractor.extractText(getStreamCopy(in)); rawContent = removeControlChars(rawContent); // now extract the meta information using POI POIFSReader reader = new POIFSReader(); reader.registerListener(this); reader.read(getStreamCopy(in)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error(Messages.get().container(Messages.LOG_EXTRACT_TEXT_ERROR_0), e); } } // combine the meta information with the content and create the result return createExtractionResult(rawContent); } }
org.opencms.search.Messages.get(), org.opencms.search.documents.Messages.get(), org.opencms.search.extractors.Messages.get(), org.opencms.search.solr.Messages.get(), org.opencms.security.Messages.get(),