List of usage examples for org.apache.lucene.analysis.charfilter HTMLStripCharFilter close
@Override
public void close() throws IOException
From source file:org.apache.solr.handler.dataimport.HTMLStripTransformer.java
License:Apache License
private Object stripHTML(String value, String column) { StringBuilder out = new StringBuilder(); StringReader strReader = new StringReader(value); try {//from w w w. ja va 2 s . c o m HTMLStripCharFilter html = new HTMLStripCharFilter( strReader.markSupported() ? strReader : new BufferedReader(strReader)); char[] cbuf = new char[1024 * 10]; while (true) { int count = html.read(cbuf); if (count == -1) break; // end of stream mark is -1 if (count > 0) out.append(cbuf, 0, count); } html.close(); } catch (IOException e) { throw new DataImportHandlerException(DataImportHandlerException.SEVERE, "Failed stripping HTML for column: " + column, e); } return out.toString(); }
From source file:org.emonocot.persistence.dao.hibernate.SearchableDaoImpl.java
License:Open Source License
private String filter(String value) { StringBuilder out = new StringBuilder(); StringReader strReader = new StringReader(value); try {/*from w w w . ja v a 2s. com*/ HTMLStripCharFilter html = new HTMLStripCharFilter(new BufferedReader(strReader)); char[] cbuf = new char[1024 * 10]; while (true) { int count = html.read(cbuf); if (count == -1) break; // end of stream mark is -1 if (count > 0) out.append(cbuf, 0, count); } html.close(); } catch (IOException e) { throw new RuntimeException("Failed stripping HTML for value: " + value, e); } return out.toString(); }
From source file:org.si4t.solr.SolrIndexer.java
License:Apache License
@SuppressWarnings("unused") private static String stripHtmlTags(String input) throws IOException { StringBuilder out = new StringBuilder(); StringReader strReader = new StringReader(input); HTMLStripCharFilter html = new HTMLStripCharFilter(strReader); char[] cbuf = new char[1024 * 10]; while (true) { int count = html.read(cbuf); if (count == -1) break; // end of stream mark is -1 if (count > 0) out.append(cbuf, 0, count);/* w ww .ja v a 2 s . co m*/ } html.close(); return out.toString(); }