
com.github.vicenthy.filehelpers4j.exceptions.WrongLenthException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of FileHelpers4J Show documentation
Show all versions of FileHelpers4J Show documentation
FileHelpers4J is a library that automates the tedious task of parsing and creating structured text files. It handles fixed width or delimited files with Java annotations sweetness
The newest version!
package com.github.vicenthy.filehelpers4j.exceptions;
import java.lang.reflect.Field;
public class WrongLenthException extends Exception {
/**
*
*/
private static final long serialVersionUID = -1966549998480148706L;
private String currentString;
private int currentLength;
private int lineNumber;
private String name;
private int fieldLength;
private Field field;
private String msgError;
public WrongLenthException(Field field, String currentString, int currentLength, int lineNumber, int fieldLength , String name) {
// TODO Auto-generated constructor stub
this.currentString = currentString;
this.currentLength = currentLength;
this.lineNumber = lineNumber;
this.fieldLength = fieldLength;
this.name = name;
this.field = field;
}
public WrongLenthException(String msgError) {
this.msgError = msgError;
}
@Override
public String getMessage() {
return "The string '" + currentString +
"' (length " + currentLength + ") at line " +
lineNumber + " has less chars than the defined for " +
name + " (" + fieldLength + "). " +
"You can use the @FixedLengthRecord(fixedMode=FixedMode.AllowLessChars) to avoid this problem in Class " +field.getDeclaringClass().getSimpleName() ;
}
public String getMsgError() {
return msgError;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy