Package org.apache.metamodel.csv
Class InconsistentRowLengthException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.apache.metamodel.MetaModelException
-
- org.apache.metamodel.InconsistentRowFormatException
-
- org.apache.metamodel.csv.InconsistentRowLengthException
-
- All Implemented Interfaces:
Serializable
public final class InconsistentRowLengthException extends org.apache.metamodel.InconsistentRowFormatExceptionException 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 whenDataSet.next()is called. Note that this exception is only thrown if theCsvConfiguration.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()); } }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description InconsistentRowLengthException(int columnsInTable, org.apache.metamodel.data.Row proposedRow, String[] line, int rowNumber)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnsInLine()Gets the amount of columns in the parsed line.intgetColumnsInTable()Gets the expected amounts of columns, as defined by the table metadata.StringgetMessage()String[]getSourceLine()Gets the source line, as parsed by the CSV parser (regardless of table metadata).-
Methods inherited from class org.apache.metamodel.InconsistentRowFormatException
getProposedRow, getRowNumber
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
InconsistentRowLengthException
public InconsistentRowLengthException(int columnsInTable, org.apache.metamodel.data.Row proposedRow, String[] line, int rowNumber)
-
-
Method Detail
-
getMessage
public String getMessage()
- Overrides:
getMessagein classorg.apache.metamodel.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.
-
-