當前位置: 首頁>>代碼示例>>Java>>正文


Java ReaderLineIterator.hasNext方法代碼示例

本文整理匯總了Java中org.databene.commons.ReaderLineIterator.hasNext方法的典型用法代碼示例。如果您正苦於以下問題:Java ReaderLineIterator.hasNext方法的具體用法?Java ReaderLineIterator.hasNext怎麽用?Java ReaderLineIterator.hasNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.databene.commons.ReaderLineIterator的用法示例。


在下文中一共展示了ReaderLineIterator.hasNext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ArchetypeManager

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
private ArchetypeManager() {
   	try {
        // read archetypes in the order specified in the file 'archetypes.txt'
        ReaderLineIterator iterator = new ReaderLineIterator(IOUtil.getReaderForURI(ARCHETYPES_INDEX));
        ArrayBuilder<Archetype> builder = new ArrayBuilder<Archetype>(Archetype.class);
        while (iterator.hasNext()) {
        	String name = iterator.next();
        	URL archUrl = new URL(ARCHETYPE_FOLDER_URL.toString() + "/" + name);
        	Archetype archetype = new Archetype(archUrl);
        	builder.add(archetype);
        }
        this.archetypes = builder.toArray();
       } catch (IOException e) {
       	throw new ConfigurationError("Error parsing archetype definitions", e);
       }
}
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:17,代碼來源:ArchetypeManager.java

示例2: testShuffleFile

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
@Test
  public void testShuffleFile() throws IOException {
  	boolean[] check = new boolean[3];
      String outFile = "target/LineShufflerTest.txt";
LineShuffler.shuffle("org/databene/benerator/util/test.txt", outFile, 3);
ReaderLineIterator iterator = new ReaderLineIterator(IOUtil.getReaderForURI(outFile));
int count = 0;
while (iterator.hasNext()) {
	count++;
	int value = Integer.parseInt(iterator.next());
	assertFalse(check[value]);
	check[value] = true;
}
assertEquals(3, count);
for (boolean c : check)
	assertTrue(c);
  }
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:18,代碼來源:LineShufflerTest.java

示例3: SeedSentenceGenerator

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
public SeedSentenceGenerator(String seedUri, int depth) throws IOException {
super(new SeedGenerator<String>(String.class, depth));
ReaderLineIterator iterator = new ReaderLineIterator(IOUtil.getReaderForURI(seedUri));
while (iterator.hasNext()) {
	String line = iterator.next();
	if (StringUtil.isEmpty(line))
		continue;
   	((SeedGenerator<String>) getSource()).addSample(line.split("\\s"));
}
  }
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:11,代碼來源:SeedSentenceGenerator.java

示例4: read

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
private static List<String> read(int bufferSize, ReaderLineIterator iterator) {
    List<String> lines = new ArrayList<String>(Math.max(100000, bufferSize));
    int lineCount = 0;
    while (iterator.hasNext() && lineCount < bufferSize) {
        String line = iterator.next();
        if (!StringUtil.isEmpty(line)) {
            lines.add(line);
            lineCount++;
            if (lineCount % 100000 == 99999)
                logger.info("parsed " + lineCount + " lines");
        }
    }
    return lines;
}
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:15,代碼來源:LineShuffler.java

示例5: testMultiThreaded

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
@Test
public void testMultiThreaded() throws Exception {
	try {
		ComplexTypeDescriptor type = createComplexType("testtype");
		SimpleTypeDescriptor stringType = dataModel.getPrimitiveTypeDescriptor(String.class);
		type.addComponent(createPart("a", stringType));
		type.addComponent(createPart("b", stringType));
		type.addComponent(createPart("c", stringType));
		final CSVEntityExporter exporter = new CSVEntityExporter(
				DEFAULT_FILE.getAbsolutePath(), type);
		final Entity entity = new Entity(type, "a", "0123456789", "b", "5555555555", "c", "9876543210");
		ExecutorService service = Executors.newCachedThreadPool();
		Runnable runner = new Runnable() {
			@Override
			public void run() {
				for (int i = 0; i < 500; i++)
					exporter.startProductConsumption(entity);
				exporter.finishProductConsumption(entity);
            }
		};
		for (int i = 0; i < 20; i++)
			service.execute(runner);
		service.shutdown();
		service.awaitTermination(2, TimeUnit.SECONDS);
		exporter.close();
		ReaderLineIterator iterator = new ReaderLineIterator(new FileReader(DEFAULT_FILE));
		assertEquals("a,b,c", iterator.next());
		String expectedContent = "0123456789,5555555555,9876543210";
		while (iterator.hasNext()) {
			String line = iterator.next();
			assertEquals(expectedContent, line);
		}
		iterator.close();
	} finally {
		DEFAULT_FILE.delete();
	}
}
 
開發者ID:raphaelfeng,項目名稱:benerator,代碼行數:38,代碼來源:CSVEntityExporterTest.java

示例6: runScript

import org.databene.commons.ReaderLineIterator; //導入方法依賴的package包/類
private static DBExecutionResult runScript(
		Reader reader, char separator, Connection connection, boolean ignoreComments, ErrorHandler errorHandler) {
	ReaderLineIterator iterator = new ReaderLineIterator(reader);
	SQLScriptException exception = null;
	Object result = null;
	Boolean changedStructure = false;
	try {
		StringBuilder cmd = new StringBuilder();
		while (iterator.hasNext()) {
		    String line = iterator.next().trim();
		    if (line.startsWith("--"))
		        continue;
		    if (cmd.length() > 0)
		        cmd.append('\n');
		    cmd.append(line);
		    boolean lineEndsWithSeparator = (line.length() > 0 && StringUtil.lastChar(line) == separator);
		    if (lineEndsWithSeparator || !iterator.hasNext()) {
		    	if (lineEndsWithSeparator)
		    		cmd.delete(cmd.length() - 1, cmd.length()); // delete trailing separators
		        String sql = cmd.toString().trim();
		        if (sql.length() > 0 && (!ignoreComments || !StringUtil.startsWithIgnoreCase(sql, "COMMENT"))) {
		        	try {
			        	if (SQLUtil.isQuery(sql))
			        		result = queryAndSimplify(sql, connection);
			        	else {
			        		result = executeUpdate(sql, connection);
			        		if (!Boolean.TRUE.equals(changedStructure)) {
			        			// if we are not already certain that structure was changed, check it
				        		Boolean tmp = SQLUtil.mutatesStructure(sql);
				        		if (!(changedStructure == null && Boolean.FALSE.equals(tmp)))
				        			changedStructure = tmp; // merge results using the worse one (true worse than null worse than false)
			        		}
			        	}
					} catch (SQLException e) {
						if (errorHandler == null)
							errorHandler = new ErrorHandler(DBUtil.class);
						errorHandler.handleError("Error in executing SQL: " + SystemInfo.getLineSeparator() + cmd, e);
						// if we arrive here, the ErrorHandler decided not to throw an exception
						// so we save the exception and line number and continue execution
						if (exception != null) // only the first exception is saved
							exception = new SQLScriptException(e, iterator.lineCount());
					}
			    }
		        cmd.delete(0, cmd.length());
		    }
		}
		Object returnedValue = (exception != null ? exception : result);
		return new DBExecutionResult(returnedValue, changedStructure);
       } finally {
		IOUtil.close(iterator);
       }
}
 
開發者ID:aravindc,項目名稱:jdbacl,代碼行數:53,代碼來源:DBUtil.java


注:本文中的org.databene.commons.ReaderLineIterator.hasNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。