本文整理汇总了Java中org.supercsv.exception.SuperCsvCellProcessorException类的典型用法代码示例。如果您正苦于以下问题:Java SuperCsvCellProcessorException类的具体用法?Java SuperCsvCellProcessorException怎么用?Java SuperCsvCellProcessorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SuperCsvCellProcessorException类属于org.supercsv.exception包,在下文中一共展示了SuperCsvCellProcessorException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Override
public Object execute(Object value, CsvContext context) {
validateInputNotNull(value, context);
try {
DateTimeFormatter pattern = DateTimeFormat
.forPattern(DETAILED_CSV_DATE_FORMAT_YYYY_MM_DD_HH_MM_SS);
LocalDateTime localDate = new LocalDateTime(
pattern.parseLocalDateTime(value.toString()));
return next.execute(localDate, context);
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
String.format("Could not parse '%s' as a LocalDateTime", value), context,
this);
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:18,代码来源:AWSCsvBillParser.java
示例2: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Override
/**
* The airports codes contained in the csv can be IATA ( 3-letter) codes or ICAO (4-letter) codes.
*/
public Object execute(Object value, CsvContext context) {
validateInputNotNull(value, context);
String airportCode = (String) value;
if ((airportCode.length() == AIRPORT_IATACODE_LENGTH)) {
return next.execute(value, context);
}
// attempt to convert the icao code to an IATA code. If not possible proceed with the code as it is.
if (airportCode.length() == AIRPORT_ICAOCODE_LENGTH) {
List<Airport> airports = airportBusinessService.findAirportByIcaoCode(airportCode);
if (!airports.isEmpty()) {
return next.execute(airports.get(0)
.getIataCode(), context);
} else {
return next.execute(airportCode, context);
}
}
throw new SuperCsvCellProcessorException(
String.format("Could not parse '%s' neither as an IATA nor as an IACAO code for Airports", value),
context, this);
}
开发者ID:Educama,项目名称:Showcase,代码行数:26,代码来源:ConnectionCsvDeserializer.java
示例3: deserializeThrowsExceptionWhenInvalidAirportCodeLength
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Test
public void deserializeThrowsExceptionWhenInvalidAirportCodeLength() throws IOException {
//Given
final String invalidAirportCode = "invalid airport code";
boolean thrown = false;
FlightConnection flightConnection = getDefaultConnection();
flightConnection.setSourceAirportIataCode(invalidAirportCode);
List<FlightConnection> flightConnections = new ArrayList<>();
flightConnections.add(flightConnection);
String csvContent = cut.createCsvContentForConnections(flightConnections);
InputStream inputStream = new ByteArrayInputStream(csvContent.getBytes(charset));
//When
try {
cut.deserialize(inputStream);
} catch (SuperCsvCellProcessorException e) {
//Then: ensure that the proper cell processor what activated to reject the invalid airport code
thrown = true;
assertThat(e.getMessage()).containsIgnoringCase(invalidAirportCode);
}
assertThat(thrown).isTrue();
}
开发者ID:Educama,项目名称:Showcase,代码行数:25,代码来源:FlightConnectionCsvDeserializerIntTest.java
示例4: deserializeThrowsExceptionWhenInvalidAirlineCodeLength
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Test
public void deserializeThrowsExceptionWhenInvalidAirlineCodeLength() throws IOException {
//Given
final String invalidAirlineCode = "invalid airline code";
boolean thrown = false;
FlightConnection flightConnection = getDefaultConnection();
flightConnection.setDestinationAirportIataCode(invalidAirlineCode);
List<FlightConnection> flightConnections = new ArrayList<>();
flightConnections.add(flightConnection);
String csvContent = cut.createCsvContentForConnections(flightConnections);
InputStream inputStream = new ByteArrayInputStream(csvContent.getBytes(charset));
//When
try {
cut.deserialize(inputStream);
} catch (SuperCsvCellProcessorException e) {
//Then: ensure that the proper cell processor what activated to reject the invalid airline code
thrown = true;
assertThat(e.getMessage()).containsIgnoringCase(invalidAirlineCode);
}
assertThat(thrown).isTrue();
}
开发者ID:Educama,项目名称:Showcase,代码行数:24,代码来源:FlightConnectionCsvDeserializerIntTest.java
示例5: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
public Object execute(Object value, CsvContext context) {
validateInputNotNull(value, context);
if(!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
String numString = (String)value;
int number = Integer.parseInt(numString);
Team team = new Select().from(Team.class).where(Team.TEAM_NUMBER+"=?",number).executeSingle();
if(null==team) {
team = new Team();
team.setTeamNumber(number);
team.save();
}
return next.execute(team,context);
}
开发者ID:mechinn,项目名称:our-alliance-android,代码行数:22,代码来源:ParseTeam.java
示例6: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null, isn't a Character or String, or is a String of multiple characters
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final Character result;
if( value instanceof Character ) {
result = (Character) value;
} else if( value instanceof String ) {
final String stringValue = (String) value;
if( stringValue.length() == 1 ) {
result = Character.valueOf(stringValue.charAt(0));
} else {
throw new SuperCsvCellProcessorException(String.format(
"'%s' cannot be parsed as a char as it is a String longer than 1 character", stringValue), context,
this);
}
} else {
final String actualClassName = value.getClass().getName();
throw new SuperCsvCellProcessorException(String.format(
"the input value should be of type Character or String but is of type %s", actualClassName), context,
this);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:31,代码来源:ParseChar.java
示例7: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException if value is null or is not a String
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof String) ) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
final String string = (String) value;
final T result;
try {
if( formatter != null ) {
result = parse(string, formatter);
} else {
result = parse(string);
}
}
catch(DateTimeParseException e) {
throw new SuperCsvCellProcessorException("Failed to parse value", context, this, e);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:27,代码来源:AbstractTemporalAccessorParsingProcessor.java
示例8: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException if value is null, not the correct type, or can't be formatted
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final Class<T> ourType = getType();
if( !(value.getClass().equals(ourType)) ) {
throw new SuperCsvCellProcessorException(ourType, value, context, this);
}
final TemporalAccessor timeType = ourType.cast(value);
try {
if( formatter != null ) {
return formatter.format(timeType);
} else {
return timeType.toString();
}
}
catch(DateTimeException | IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
String.format("Failed to format value as a %s", ourType.getSimpleName()), context, this, e);
}
}
开发者ID:super-csv,项目名称:super-csv,代码行数:25,代码来源:AbstractTemporalAccessorFormattingProcessor.java
示例9: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException if value is null or is not a String
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof String) ) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
final ZoneId result;
try {
if( aliasMap != null ) {
result = ZoneId.of((String) value, aliasMap);
} else {
result = ZoneId.of((String) value);
}
}
catch(DateTimeException e) {
throw new SuperCsvCellProcessorException("Failed to parse value as a ZoneId", context, this, e);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:25,代码来源:ParseZoneId.java
示例10: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or not a Number, or if an invalid decimalFormat String was supplied
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof Number) ) {
throw new SuperCsvCellProcessorException(Number.class, value, context, this);
}
// create a new DecimalFormat if one is not supplied
final DecimalFormat decimalFormatter;
try {
decimalFormatter = formatter != null ? formatter : new DecimalFormat(decimalFormat);
}
catch(IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
String.format("'%s' is not a valid decimal format", decimalFormat), context, this, e);
}
final String result = decimalFormatter.format(value);
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:27,代码来源:FmtNumber.java
示例11: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null, not a String, or can't be parsed to a Boolean
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof String) ) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
final String stringValue = (String) value;
final Boolean result;
if( contains(trueValues, stringValue, ignoreCase) ) {
result = Boolean.TRUE;
} else if( contains(falseValues, stringValue, ignoreCase) ) {
result = Boolean.FALSE;
} else {
throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a Boolean", value),
context, this);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:27,代码来源:ParseBool.java
示例12: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null, isn't a Double or String, or can't be parsed as a Double
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final Double result;
if( value instanceof Double ) {
result = (Double) value;
} else if( value instanceof String ) {
try {
result = new Double((String) value);
}
catch(final NumberFormatException e) {
throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a Double", value),
context, this, e);
}
} else {
final String actualClassName = value.getClass().getName();
throw new SuperCsvCellProcessorException(String.format(
"the input value should be of type Double or String but is of type %s", actualClassName), context, this);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:29,代码来源:ParseDouble.java
示例13: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or is not a Date, or if dateFormat is not a valid date format
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof Date) ) {
throw new SuperCsvCellProcessorException(Date.class, value, context, this);
}
final SimpleDateFormat formatter;
try {
formatter = new SimpleDateFormat(dateFormat);
}
catch(IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(String.format("'%s' is not a valid date format", dateFormat),
context, this, e);
}
String result = formatter.format((Date) value);
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:26,代码来源:FmtDate.java
示例14: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or is not a String
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value,
context, this);
}
final DateTimeZone result;
try {
result = DateTimeZone.forID((String) value);
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
"Failed to parse value as a DateTimeZone", context, this, e);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:23,代码来源:ParseDateTimeZone.java
示例15: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or can't be parsed as an Enum
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
final String inputString = value.toString();
for( final Enum<?> enumConstant : enumClass.getEnumConstants() ) {
String constantName = enumConstant.name();
if( ignoreCase ? constantName.equalsIgnoreCase(inputString) : constantName.equals(inputString) ) {
return enumConstant;
}
}
throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a enum of type %s", value,
enumClass.getName()), context, this);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:23,代码来源:ParseEnum.java
示例16: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or is not a String
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value,
context, this);
}
final Duration result;
try {
result = Duration.parse((String) value);
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
"Failed to parse value as a Duration", context, this, e);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:22,代码来源:ParseDuration.java
示例17: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null or is not a String
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value,
context, this);
}
final String string = (String) value;
final Period result;
try {
if (formatter != null) {
result = Period.parse(string, formatter);
} else {
result = Period.parse(string);
}
} catch (IllegalArgumentException e) {
throw new SuperCsvCellProcessorException(
"Failed to parse value as a Period", context, this, e);
}
return next.execute(result, context);
}
开发者ID:super-csv,项目名称:super-csv,代码行数:30,代码来源:ParsePeriod.java
示例18: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException
* if value is null, isn't a String, or can't be parsed to a Date
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof String) ) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
try {
if( locale == null ) {
formatter = new SimpleDateFormat(dateFormat);
} else {
formatter = new SimpleDateFormat(dateFormat, locale);
}
formatter.setLenient(lenient);
Object result = parseValue(value);
return next.execute(result, context);
}
catch(final ParseException e) {
throw new SuperCsvCellProcessorException(String.format("'%s' could not be parsed as a Date", value),
context, this, e);
}
}
开发者ID:super-csv,项目名称:super-csv,代码行数:29,代码来源:ParseDateTimeAbstract.java
示例19: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Override
public <T> T execute(Object value, CsvContext context) {
if (!(value instanceof String)) {
throw new SuperCsvCellProcessorException(String.class, value, context, this);
}
String result = pool.pool((String) value);
return this.next.execute(result, context);
}
开发者ID:shopping24,项目名称:geoip-dbip-rest-api,代码行数:9,代码来源:DbIpFileParser.java
示例20: execute
import org.supercsv.exception.SuperCsvCellProcessorException; //导入依赖的package包/类
@Override
public DateTime execute(Object input, CsvContext context) {
if (input == null) {
throw new SuperCsvCellProcessorException("Could not parse value as it was null.", context, this);
}
if (input instanceof String == false) {
throw new SuperCsvCellProcessorException("Could not parse value as it is not a String.", context, this);
}
return getDateTimeFromStringOrThrowException(context, (String) input);
}
开发者ID:NLeSC,项目名称:eEcology-Classification,代码行数:12,代码来源:JodaTimeCellProcessor.java
注:本文中的org.supercsv.exception.SuperCsvCellProcessorException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论