|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ricebridge.csvman.BadLine
Description of a badly formatted data line.
This class describes a badly formatted data line. By default,
CSV processing stops when a bad line is encountered and a CsvManagerException
(CODE_bad_line) is thrown. The
CsvManagerException.getBadLine method
returns a BadLine object describing the problem.
When CsvManager.setRunInbackground is true,
the bad lines are collected and can be obtained using the
CsvManager.getBadLines method.
Each bad line has the following attributes:
getOriginalLine: the text of the original data linegetLineNumber: the line number of the bad data line (counting starts from 1)getErrorMsg: a technical message describing the problemgetErrorType: the type of error that occurred; incorrect CSV format (SYNTAX), or invalid data (SEMANTIC)getException: the exception that caused the bad line, if any. MAY BE NULL.Sometimes the original data line is not available and the previous line or an empty String is provided.
For example, for an error at the start of loading, no lines have been read yet, but a single BadLine object
is still generated for consistency of error handling.
If you implement LineListener, parsing errors in the CSV data are reported
via LineListener.handleBadLine.
You can also return your own BadLine
objects from LineListener.handleLine if you encounter a semantic data error.
BadLine objects are also created when LineProvider instances throw an Exception.
This maintains the accuracy of the CsvManager statistics.
You may subclass BadLine in order to add your own
additional error description information.
The Source Code of this Java class is available under a BSD-style license.
LineListener,
LineProvider| Field Summary | |
protected String |
iErrorMsg
A technical error message describing the problem with the original data line. |
protected int |
iErrorType
The type of error, syntactic or semantic. |
protected Exception |
iException
The Exception that caused the bad line, if any. |
protected long |
iLineNumber
The line number of the bad data line, counting from 1. |
protected String |
iOriginalLine
The original text of the data line. |
static int |
SEMANTIC
Indicate that the data line was semantically invalid and that the value of one or more data fields is incorrect. |
static int |
SYNTAX
Indicate that the data line was syntactically invalid and could not be parsed correctly as a CSV format line. |
| Constructor Summary | |
BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg)
Create a SEMANTIC error description of a bad data line. |
|
BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
Exception pException)
Create an SEMANTIC error description caused by a particular Exception. |
|
BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
int pErrorType)
Create an error description of type pErrorType (SYNTAX or SEMANTIC). |
|
BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
int pErrorType,
Exception pException)
Create an error description of a bad data line. |
|
| Method Summary | |
protected void |
appendErrorMsg(String pAppend)
Append more text to the error message. |
String |
getErrorMsg()
Get the error message describing the bad data line. |
int |
getErrorType()
Get the type of error that occurred. |
Exception |
getException()
Get the Exception that caused the bad line. |
long |
getLineNumber()
Get the line number of the bad data line. |
String |
getOriginalLine()
Get the text of the bad data line. |
String |
toString()
A utility method useful for debugging. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int SEMANTIC
public static final int SYNTAX
protected String iOriginalLine
protected String iErrorMsg
protected int iErrorType
syntactic or semantic.
protected long iLineNumber
protected Exception iException
Exception that caused the bad line, if any.
| Constructor Detail |
public BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg)
SEMANTIC error description of a bad data line.
The LineListener.handleLine method can return a
BadLine object if the data line is semantically invalid. Use this constructor
to create the BadLine object to return. If there is no error, you should
return null from the handleLine method.
pLineNumber - line number if the bad data line, available from handleLine parameters.pOriginalLine - original text of the line in the CSV file, available from handleLine parameters.pErrorMsg - your own description of the problemBadLine(long, String, String, int),
BadLine(long, String, String, Exception),
BadLine(long, String, String, int, Exception)
public BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
int pErrorType)
pErrorType (SYNTAX or SEMANTIC).
This constructor is used by CsvManager to create syntax error reports.
pLineNumber - line number if the bad data line, available from handleLine parameters.pOriginalLine - original text of the line in the CSV file, available from handleLine parameters.pErrorMsg - your own description of the problempErrorType - one of SYNTAX or SEMANTICBadLine(long, String, String),
BadLine(long, String, String, Exception),
BadLine(long, String, String, int, Exception)
public BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
Exception pException)
SEMANTIC error description caused by a particular Exception.
pLineNumber - line number if the bad data line, available from handleLine parameters.pOriginalLine - original text of the line in the CSV file, available from handleLine parameters.pErrorMsg - your own description of the problempException - Exception that caused the bad line, optionalBadLine(long, String, String),
BadLine(long, String, String, int),
BadLine(long, String, String, int, Exception)
public BadLine(long pLineNumber,
String pOriginalLine,
String pErrorMsg,
int pErrorType,
Exception pException)
pLineNumber - line number if the bad data line, available from handleLine parameters.pOriginalLine - original text of the line in the CSV file, available from handleLine parameters.pErrorMsg - your own description of the problempErrorType - one of SYNTAX or SEMANTICpException - Exception that caused the bad line, optionalBadLine(long, String, String),
BadLine(long, String, String, int),
BadLine(long, String, String, Exception)| Method Detail |
public long getLineNumber()
Line numbers always start at 1. If no line information is available, this method returns 0.
public String getOriginalLine()
If no line information is available, this method returns an empty string.
public String getErrorMsg()
This message is normally of a technical nature.
public int getErrorType()
The current error types are SEMANTIC, for
invalid data values, and SYNTAX, for CSV data that
cannot be parsed due to formatting errors.
public Exception getException()
Exception that caused the bad line.
WARNING: MAY BE NULL. There may not be a causing exception.
public String toString()
returns a String in the format:
[CSV:BadLine:1:error message text:SYNTAX|SEMANTIC:original data line text:exception msg]
protected void appendErrorMsg(String pAppend)
pAppend - text to append
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||