@Test public void testExtractAllJustAHashTag() { String content = "#HI"; List<String> hashtags = sut.extractAll(content); assertEquals(1, hashtags.size()); assertTrue(hashtags.contains("#HI")); }
public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); } }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  Substring extract(final String content, final int inStartingIndex); List<String> extractAll(final String content); }
HashTagExtractor { public List<String> extractAll(final String content) { Set<String> hashTagContents = new HashSet<String>(); Substring hashTag; int position = 0; while (null != (hashTag = extract(content, position))) { position = hashTag.getStartIndex() + hashTag.getLength(); hashTagContents.add(hashTag.getContent()); } return new ArrayList<String>(hashTagContents); }  Substring extract(final String content, final int inStartingIndex); List<String> extractAll(final String content);  }