Package org.supercsv.exception

Examples of org.supercsv.exception.SuperCsvException


          // .get(i).getClass(), lineResult.get(i)));
          cache.getSetMethod(resultBean, nameMapping[i], lineResult.get(i).getClass())//
            .invoke(resultBean, lineResult.get(i));
        }
        catch(final IllegalArgumentException e) {
          throw new SuperCSVException("Method set" + nameMapping[i].substring(0, 1).toUpperCase()
            + nameMapping[i].substring(1) + "() does not accept input \"" + lineResult.get(i) + "\" of type "
            + lineResult.get(i).getClass().getName(), null, e);
        }
      }
      return resultBean;
View Full Code Here


  this.regex = regex;
}

private void handleArguments(final String regex)  {
  if( regex == null ) { throw new NullInputException("the regular expression cannot be null", this); }
  if( regex.equals("") ) { throw new SuperCSVException(
    "the regular expression  cannot be \"\" as this has no effect", this); }
}
View Full Code Here

 
  boolean found = regexPattern.matcher((String) value).find();
  if (!found) {
    String msg = regexMessages.get(regex);
    if (msg == null) {
    throw new SuperCSVException(
      "Entry \"" + value + "\" does not respect the regular expression '" + regex + "'", context, this);
    } else {
      throw new SuperCSVException(
        "Entry \"" + value + "\" does not respect the constraint '" + msg + "' " +
            "(defined by the regular expression '" + regex + "')", context, this);     
    }
  }
  return next.execute(value, context);
View Full Code Here

  if( value == null ) { throw new NullInputException("Input cannot be null on line " + context.lineNumber
    + " at column " + context.columnNumber, context, this); }
 
  // check for uniqueness
  final int hash = value.hashCode();
  if( uniqueSet.contains(hash) ) { throw new SuperCSVException("Duplicate entry \"" + value
    + "\" found with same hash code!", context, this); }
 
  // if not found add it
  uniqueSet.add(hash);
 
View Full Code Here

}

private void handleArguments(final String regex, final String replacement)  {
  if( regex == null ) { throw new NullInputException("the regular expression cannot be null", this); }
  if( replacement == null ) { throw new NullInputException("the replacement string cannot be null", this); }
  if( regex.equals("") ) { throw new SuperCSVException(
    "the regular expression  cannot be \"\" as this has no effect", this); }
}
View Full Code Here

  } else if( value instanceof String ) {
    try {
      result = new Integer((String) value);
    }
    catch(final NumberFormatException e) {
      throw new SuperCSVException("Parser error", context, this, e);
    }
  } else {
    throw new SuperCSVException("Can't convert \"" + value
      + "\" to integer. Input is not of type Integer nor type String but of type " + value.getClass().getName(),
      context, this);
  }
 
  return next.execute(result, context);
View Full Code Here

  } else if( value instanceof String ) {
    try {
      result = new Double((String) value);
    }
    catch(final NumberFormatException e) {
      throw new SuperCSVException("Parser error", context, this, e);
    }
  } else {
    throw new SuperCSVException("Can't convert \"" + value
      + "\" to double. Input is not of type Double nor type String, but of type " + value.getClass().getName(),
      context, this);
  }
 
  return next.execute(result, context);
View Full Code Here

* @param values
*            A list of values TODO: see if using an iterator for the values is more efficient
*/
public static <T> void mapStringList(final Map<String, T> destination, final String[] nameMapper, final List<T> values) {
  if( nameMapper.length != values.size() ) {
    throw new SuperCSVException(
      "The namemapper array and the value list must match in size. Number of columns mismatch number of entries for your map.");
  }
  destination.clear();
 
  // map each element of the array
  for( int i = 0; i < nameMapper.length; i++ ) {
    final String key = nameMapper[i];
   
    // null's in the name mapping means skip column
    if( key == null ) {
      continue;
    }
   
    // only perform safe inserts
    if( destination.containsKey(key) ) {
      throw new SuperCSVException("nameMapper array contains duplicate key \"" + key
        + "\" cannot map the list");
    }
   
    destination.put(key, values.get(i));
  }
View Full Code Here

  final CellProcessor[] processors, final int lineNo) throws SuperCSVException {
  final CSVContext context = new CSVContext();
  context.lineSource = source;
  context.lineNumber = lineNo;
  if( source.size() != processors.length ) {
    throw new SuperCSVException("The value array (size " + source.size()
      + ")  must match the processors array (size " + processors.length + "):"
      + " You are probably reading a CSV line with a different number of columns"
      + " than the number of cellprocessors specified", context);
  }
 
View Full Code Here

    }
    catch(final NoSuchMethodException e1) {
      throwException(destinationObject, variableType, methodName, e1);
    }
  }
  throw new SuperCSVException("This can never happen!");
}
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.