@Test public void testObjectToString() { StandardAnalyzerSortFieldBridge sut = new StandardAnalyzerSortFieldBridge(); assertEquals("foooo baaaar", sut.objectToString("FooOO BaaAAr")); assertEquals("cool", sut.objectToString("the cool")); assertEquals("cool", sut.objectToString("***the cool!!")); assertEquals("o reilly", sut.objectToString("O-Reilly")); assertEquals("o'reilly", sut.objectToString("O'Reilly")); assertEquals("cool", sut.objectToString("This is Cool")); assertEquals("drive car", sut.objectToString("DRIVE thIs CAR")); assertEquals("drive car", sut.objectToString("DRIVE thIs CAR")); assertEquals("drive car", sut.objectToString("DRIVE -a- assertNull(sut.objectToString(null)); }
@Override public String objectToString(final Object obj) { log.info("..."); if (obj == null) { return null; } log.info("Parsing '" + obj.toString() + "'"); StringBuilder outputSb = new StringBuilder(); TokenStream stream = analyzer.tokenStream(null, new StringReader(obj.toString())); Token token = new Token(); try { while ((token = stream.next(token)) != null) { if (outputSb.length() > 0) { outputSb.append(" "); } outputSb.append(token.term()); } } catch (IOException e) { log.error("Error parsing '" + obj.toString() + "'", e); return null; } String output = outputSb.toString(); if (log.isInfoEnabled()) { log.info("Parsed '" + obj.toString() + "' as '" + output + "'"); } return output; }
StandardAnalyzerSortFieldBridge implements StringBridge { @Override public String objectToString(final Object obj) { log.info("..."); if (obj == null) { return null; } log.info("Parsing '" + obj.toString() + "'"); StringBuilder outputSb = new StringBuilder(); TokenStream stream = analyzer.tokenStream(null, new StringReader(obj.toString())); Token token = new Token(); try { while ((token = stream.next(token)) != null) { if (outputSb.length() > 0) { outputSb.append(" "); } outputSb.append(token.term()); } } catch (IOException e) { log.error("Error parsing '" + obj.toString() + "'", e); return null; } String output = outputSb.toString(); if (log.isInfoEnabled()) { log.info("Parsed '" + obj.toString() + "' as '" + output + "'"); } return output; } }
StandardAnalyzerSortFieldBridge implements StringBridge { @Override public String objectToString(final Object obj) { log.info("..."); if (obj == null) { return null; } log.info("Parsing '" + obj.toString() + "'"); StringBuilder outputSb = new StringBuilder(); TokenStream stream = analyzer.tokenStream(null, new StringReader(obj.toString())); Token token = new Token(); try { while ((token = stream.next(token)) != null) { if (outputSb.length() > 0) { outputSb.append(" "); } outputSb.append(token.term()); } } catch (IOException e) { log.error("Error parsing '" + obj.toString() + "'", e); return null; } String output = outputSb.toString(); if (log.isInfoEnabled()) { log.info("Parsed '" + obj.toString() + "' as '" + output + "'"); } return output; }  }
StandardAnalyzerSortFieldBridge implements StringBridge { @Override public String objectToString(final Object obj) { log.info("..."); if (obj == null) { return null; } log.info("Parsing '" + obj.toString() + "'"); StringBuilder outputSb = new StringBuilder(); TokenStream stream = analyzer.tokenStream(null, new StringReader(obj.toString())); Token token = new Token(); try { while ((token = stream.next(token)) != null) { if (outputSb.length() > 0) { outputSb.append(" "); } outputSb.append(token.term()); } } catch (IOException e) { log.error("Error parsing '" + obj.toString() + "'", e); return null; } String output = outputSb.toString(); if (log.isInfoEnabled()) { log.info("Parsed '" + obj.toString() + "' as '" + output + "'"); } return output; }  @Override String objectToString(final Object obj); }
StandardAnalyzerSortFieldBridge implements StringBridge { @Override public String objectToString(final Object obj) { log.info("..."); if (obj == null) { return null; } log.info("Parsing '" + obj.toString() + "'"); StringBuilder outputSb = new StringBuilder(); TokenStream stream = analyzer.tokenStream(null, new StringReader(obj.toString())); Token token = new Token(); try { while ((token = stream.next(token)) != null) { if (outputSb.length() > 0) { outputSb.append(" "); } outputSb.append(token.term()); } } catch (IOException e) { log.error("Error parsing '" + obj.toString() + "'", e); return null; } String output = outputSb.toString(); if (log.isInfoEnabled()) { log.info("Parsed '" + obj.toString() + "' as '" + output + "'"); } return output; }  @Override String objectToString(final Object obj);  }