@Test public void testGetNext() throws Exception { FileCollectionReader fsr = (FileCollectionReader) new FileCollectionReader(new File(rootDirectory + "src/test/resources/inputDirectory"), true) .setEncoding(Charset.defaultCharset().displayName()) .setRecurseFlag(false) .produceCollectionReader(); assertNotNull(fsr); assertEquals(Charset.defaultCharset().displayName(), fsr.getEncoding()); assertEquals(new File(rootDirectory + "src/test/resources/inputDirectory").getAbsolutePath(), fsr.getInputDirectory().getAbsolutePath()); FilenameFilter filenameFilter = fsr.getFilenameFilter(); assertTrue(filenameFilter instanceof SuffixFileFilter); assertFalse(fsr.mRecurse); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(SampleService .simpleServiceDefinition() .getAnalysisEngineDescription()); CAS mockCas = ae.newCAS(); assertTrue(fsr.hasNext()); fsr.getNext(mockCas); assertEquals(1, fsr.getCurrentIndex()); FSIterator<AnnotationFS> csiIterator = mockCas.getAnnotationIndex(mockCas.getTypeSystem().getType(CSI.class.getCanonicalName())).iterator(); assertTrue(csiIterator.hasNext()); CSI csi = (CSI) csiIterator.next(); assertTrue("text1.txt".equals(csi.getID())); assertTrue(csi.getLocator().endsWith("client/src/test/resources/inputDirectory/text1.txt")); assertNull(csi.getPropertiesKeys()); assertNull(csi.getRowData()); assertTrue(RESULTS.equals(mockCas.getDocumentText())); }
@Override public void getNext(CAS aCAS) throws IOException, CollectionException { File next = mFileCollection.get(mFileIndex++); String fileText = (StringUtils.isBlank(mEncoding)) ? FileUtils.file2String(next) : FileUtils.file2String(next, mEncoding); String docText = LeoUtils.filterText(fileText, filters); aCAS.setDocumentText(docText); JCas jcas = null; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(e); } CSI csi = new CSI(jcas); csi.setBegin(0); csi.setEnd(docText.length()); csi.setID(next.getName()); csi.setLocator(next.toURI().getPath()); csi.addToIndexes(); }
FileCollectionReader extends BaseFileCollectionReader { @Override public void getNext(CAS aCAS) throws IOException, CollectionException { File next = mFileCollection.get(mFileIndex++); String fileText = (StringUtils.isBlank(mEncoding)) ? FileUtils.file2String(next) : FileUtils.file2String(next, mEncoding); String docText = LeoUtils.filterText(fileText, filters); aCAS.setDocumentText(docText); JCas jcas = null; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(e); } CSI csi = new CSI(jcas); csi.setBegin(0); csi.setEnd(docText.length()); csi.setID(next.getName()); csi.setLocator(next.toURI().getPath()); csi.addToIndexes(); } }
FileCollectionReader extends BaseFileCollectionReader { @Override public void getNext(CAS aCAS) throws IOException, CollectionException { File next = mFileCollection.get(mFileIndex++); String fileText = (StringUtils.isBlank(mEncoding)) ? FileUtils.file2String(next) : FileUtils.file2String(next, mEncoding); String docText = LeoUtils.filterText(fileText, filters); aCAS.setDocumentText(docText); JCas jcas = null; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(e); } CSI csi = new CSI(jcas); csi.setBegin(0); csi.setEnd(docText.length()); csi.setID(next.getName()); csi.setLocator(next.toURI().getPath()); csi.addToIndexes(); } FileCollectionReader();  FileCollectionReader(File inputDirectory, boolean recurse); }
FileCollectionReader extends BaseFileCollectionReader { @Override public void getNext(CAS aCAS) throws IOException, CollectionException { File next = mFileCollection.get(mFileIndex++); String fileText = (StringUtils.isBlank(mEncoding)) ? FileUtils.file2String(next) : FileUtils.file2String(next, mEncoding); String docText = LeoUtils.filterText(fileText, filters); aCAS.setDocumentText(docText); JCas jcas = null; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(e); } CSI csi = new CSI(jcas); csi.setBegin(0); csi.setEnd(docText.length()); csi.setID(next.getName()); csi.setLocator(next.toURI().getPath()); csi.addToIndexes(); } FileCollectionReader();  FileCollectionReader(File inputDirectory, boolean recurse); @Override void getNext(CAS aCAS); }
FileCollectionReader extends BaseFileCollectionReader { @Override public void getNext(CAS aCAS) throws IOException, CollectionException { File next = mFileCollection.get(mFileIndex++); String fileText = (StringUtils.isBlank(mEncoding)) ? FileUtils.file2String(next) : FileUtils.file2String(next, mEncoding); String docText = LeoUtils.filterText(fileText, filters); aCAS.setDocumentText(docText); JCas jcas = null; try { jcas = aCAS.getJCas(); } catch (CASException e) { throw new CollectionException(e); } CSI csi = new CSI(jcas); csi.setBegin(0); csi.setEnd(docText.length()); csi.setID(next.getName()); csi.setLocator(next.toURI().getPath()); csi.addToIndexes(); } FileCollectionReader();  FileCollectionReader(File inputDirectory, boolean recurse); @Override void getNext(CAS aCAS); static final String fileExtensionString; }