Package org.supercsv.exception

Examples of org.supercsv.exception.SuperCsvException


*            check to ensure that this method is only applied to the first line of the CSV file.
* @since 1.0
*/
public String[] getCSVHeader(final boolean firstLineCheck) throws IOException {
  if( firstLineCheck && tokenizer.getLineNumber() != 0 ) {
    throw new SuperCSVException("CSV header can only be fetched as the first read operation on a source!");
  }
  final List<String> tmp = new ArrayList<String>();
  String[] res = null;
  if( tokenizer.readStringList(tmp) ) {
    res = tmp.toArray(new String[0]);
View Full Code Here


    if( sval.indexOf(required) != -1 ) {
      found = true;
      break;
    }
  }
  if( found == false ) { throw new SuperCSVException("Entry \"" + value + "\" on line " + context.lineNumber
    + " column " + context.columnNumber + " doesn't contain any of the required substrings", context, this); }
 
  return next.execute(value, context);
}
View Full Code Here

public Object execute(final Object value, final CSVContext context) throws SuperCSVException, ClassCastException {
  if( value == null ) { throw new NullInputException("Input cannot be null on line " + context.lineNumber + " at column " + context.columnNumber, context, this); }
  // check for required hash
  if( !possibleValues.contains(value) ) {
   
    throw new SuperCSVException("Entry \"" + value + "\" on line " + context.lineNumber + " column "
      + context.columnNumber + " is not accepted as a possible value", context, this);
  }
 
  return next.execute(value, context);
}
View Full Code Here

public class StrMinMax extends CellProcessorAdaptor implements StringCellProcessor {
protected long min, max;

public StrMinMax(final long min, final long max) {
  super(NullObjectPattern.INSTANCE);
  if( max < min ) { throw new SuperCSVException("max < min in the arguments " + min + " " + max, this); }
  if( min < 0 ) { throw new SuperCSVException("min length must be >= 0, is " + min, this); }
 
  this.min = min;
  this.max = max;
}
View Full Code Here

  this.max = max;
}

public StrMinMax(final long min, final long max, final CellProcessor next) {
  super(next);
  if( max < min ) { throw new SuperCSVException("max < min in the arguments " + min + " " + max, this); }
  this.min = min;
  this.max = max;
}
View Full Code Here

*/
@Override
public Object execute(final Object value, final CSVContext context) throws NumberFormatException {
  if( value == null ) { throw new NullInputException("Input cannot be null on line " + context.lineNumber + " at column " + context.columnNumber, context, this); }
  final String sval = value.toString(); // cast
  if( sval.length() < min || sval.length() > max ) { throw new SuperCSVException("Entry \"" + value + "\" on line "
    + context.lineNumber + " column " + context.columnNumber + " is not within the string sizes " + min + " - "
    + max, context, this); }
 
  return next.execute(sval, context);
}
View Full Code Here

  else {
    try {
      result = Double.parseDouble(value.toString());
    }
    catch(final NumberFormatException e) {
      throw new SuperCSVException("Parser error", context, this, e);
    }
  }
 
  if( !(result >= min && result <= max) ) {
    throw new SuperCSVException("Entry \"" + value + "\" on line " + context.lineNumber + " column "
      + context.columnNumber + " is not within the numerical range " + min + "-" + max, context, this);
  }
  return next.execute(result, context);
}
View Full Code Here

  return next.execute(result, context);
}

private void init(final double min, final double max) {
  if( max < min ) {
    throw new SuperCSVException("max < min in the arguments " + min + " " + max, this);
  }
 
  this.min = min;
  this.max = max;
}
View Full Code Here

public Object execute(final Object value, final CSVContext context) {
  if( value == null ) { throw new NullInputException("Input cannot be null on line " + context.lineNumber
    + " at column " + context.columnNumber, context, this); }
  if( value instanceof String ) {
    String svalue = (String) value;
    if( svalue.length() == 0 ) { throw new SuperCSVException("unexpected empty string", context, this); }
  } else {
    throw new ClassCastInputCSVException(value, String.class, context, this);
  }
 
  return next.execute(value, context);
View Full Code Here

    if (constantValue == UNKNOWN) {
      constantValue = value;
    } else {
      if (!equals(constantValue, value)) {
        if (isGivenValue) {
          throw new SuperCSVException("Entry \"" + value + "\" is not equals " +
              "to the given value \"" + constantValue + "\"", context, this);
        } else {
          throw new SuperCSVException("Entry \"" + value + "\" is not equals " +
            "to the other previous value(s) being \"" + constantValue + "\"", context, this);
        }
      }
    }
    return next.execute(value, context);
View Full Code Here

TOP

Related Classes of org.supercsv.exception.SuperCsvException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.