mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Extract CsvReader into separate ebean-csv-reader module
This commit is contained in:
@@ -785,12 +785,6 @@ public final class DB {
|
||||
return getDefault().createUpdate(beanType, ormUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CsvReader for a given beanType.
|
||||
*/
|
||||
public static <T> CsvReader<T> createCsvReader(Class<T> beanType) {
|
||||
return getDefault().createCsvReader(beanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a named query.
|
||||
|
||||
@@ -204,10 +204,6 @@ public interface Database {
|
||||
*/
|
||||
<T> T createEntityBean(Class<T> type);
|
||||
|
||||
/**
|
||||
* Create a CsvReader for a given beanType.
|
||||
*/
|
||||
<T> CsvReader<T> createCsvReader(Class<T> beanType);
|
||||
|
||||
/**
|
||||
* Create an Update query to perform a bulk update.
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package io.ebean.text;
|
||||
|
||||
import java.sql.Time;
|
||||
|
||||
/**
|
||||
* Parser for TIME types that supports both HH:mm:ss and HH:mm.
|
||||
*/
|
||||
public final class TimeStringParser implements StringParser {
|
||||
|
||||
private static final TimeStringParser SHARED = new TimeStringParser();
|
||||
|
||||
/**
|
||||
* Return a shared instance as this is thread safe.
|
||||
*/
|
||||
public static TimeStringParser get() {
|
||||
return SHARED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the String supporting both HH:mm:ss and HH:mm formats.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Object parse(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String s = value.trim();
|
||||
int firstColon = s.indexOf(':');
|
||||
|
||||
if (firstColon == -1) {
|
||||
throw new java.lang.IllegalArgumentException("No ':' in value [" + s + "]");
|
||||
}
|
||||
try {
|
||||
int second;
|
||||
int minute;
|
||||
int hour = Integer.parseInt(s.substring(0, firstColon));
|
||||
int secondColon = s.indexOf(':', firstColon + 1);
|
||||
|
||||
if (secondColon == -1) {
|
||||
minute = Integer.parseInt(s.substring(firstColon + 1, s.length()));
|
||||
second = 0;
|
||||
} else {
|
||||
minute = Integer.parseInt(s.substring(firstColon + 1, secondColon));
|
||||
second = Integer.parseInt(s.substring(secondColon + 1));
|
||||
}
|
||||
|
||||
return new Time(hour, minute, second);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
throw new java.lang.IllegalArgumentException("Number format Error parsing time [" + s + "] " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
*/
|
||||
protected final int persistBatchSize;
|
||||
|
||||
protected boolean getGeneratedKeys = true;
|
||||
/**
|
||||
* The time the process started.
|
||||
*/
|
||||
@@ -164,7 +165,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||
if (persistBatchSize > 1) {
|
||||
transaction.setBatchMode(true);
|
||||
transaction.setBatchSize(persistBatchSize);
|
||||
transaction.setGetGeneratedKeys(false);
|
||||
transaction.setGetGeneratedKeys(getGeneratedKeys);
|
||||
} else {
|
||||
// explicitly turn off JDBC batching in case
|
||||
// is has been turned on globally
|
||||
|
||||
Reference in New Issue
Block a user