org.eobjects.metamodel.csv
Class InconsistentRowLengthException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.eobjects.metamodel.MetaModelException
                  extended by org.eobjects.metamodel.InconsistentRowFormatException
                      extended by org.eobjects.metamodel.csv.InconsistentRowLengthException
All Implemented Interfaces:
Serializable

public final class InconsistentRowLengthException
extends InconsistentRowFormatException

Exception thrown when a line in a CSV file has an inconsistent amount of columns compared to the previous lines (and headers). The exception will be thrown when DataSet.next() is called. Note that this exception is only thrown if the CsvConfiguration.isFailOnInconsistentRowLength() property is true. Enabling it allows a somewhat different approach to iterating through a resulting DataSet. For example something like:

 while (true) {
        try {
                if (!dataSet.next) {
                        break;
                }
                Row row = dataSet.getRow();
                handleRegularRow(row);
        } catch (InconsistentRowLengthException e) {
                handleIrregularRow(e.getSourceLine());
        }
 }
 

Author:
Kasper Sørensen
See Also:
Serialized Form

Constructor Summary
InconsistentRowLengthException(int columnsInTable, Row proposedRow, String[] line, int rowNumber)
           
 
Method Summary
 int getColumnsInLine()
          Gets the amount of columns in the parsed line.
 int getColumnsInTable()
          Gets the expected amounts of columns, as defined by the table metadata.
 String getMessage()
           
 String[] getSourceLine()
          Gets the source line, as parsed by the CSV parser (regardless of table metadata).
 
Methods inherited from class org.eobjects.metamodel.InconsistentRowFormatException
getProposedRow, getRowNumber
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InconsistentRowLengthException

public InconsistentRowLengthException(int columnsInTable,
                                      Row proposedRow,
                                      String[] line,
                                      int rowNumber)
Method Detail

getMessage

public String getMessage()
Overrides:
getMessage in class InconsistentRowFormatException

getSourceLine

public String[] getSourceLine()
Gets the source line, as parsed by the CSV parser (regardless of table metadata).

Returns:
an array of string values.

getColumnsInLine

public int getColumnsInLine()
Gets the amount of columns in the parsed line.

Returns:
an int representing the amount of values in the inconsistent line.

getColumnsInTable

public int getColumnsInTable()
Gets the expected amounts of columns, as defined by the table metadata.

Returns:
an int representing the amount of columns defined in the table.


Copyright © 2007-2012. All Rights Reserved.