/**
* This package contains all controller classes.
*/
package org.uploadDB.controller;
import org.apache.commons.csv.CSVStrategy;
public class CSVParserController {
private CSVStrategy csvstrat;
private char CSVSeparator;
private char CSVEncapsulator;
private char CSVComment;
private boolean ignoreLeadingSpaces;
private boolean interpretUnicodeEscapes;
private boolean ignoreEmptyLines;
private boolean fHeaderLine;
/**
* This is the object constructor, which sets the parameters for the CSVStrategy class.
* @param separator
* @param encapsulator
* @param comment
* @param ignoreLeads
* @param intUni
* @param ignoreEl
*/
public CSVParserController(char separator, char encapsulator, char comment, Boolean ignoreLeads, Boolean intUni, Boolean ignoreEl, Boolean headerLine ){
this.setCSVSeparator(separator);
this.setCSVEncapsulator(encapsulator);
this.setCSVComment(comment);
this.setIgnoreLeadingSpaces(ignoreLeads);
this.setInterpretUnicodeEscapes(intUni);
this.setIgnoreEmptyLines(ignoreEl);
this.setFHeaderLine(headerLine);
}
/**
* This method replaces the current CSV strategy object with a new object.
*/
public void ConfigureCSV(){
this.csvstrat = new CSVStrategy(this.getCSVSeparator(),this.getCSVEncapsulator(),this.getCSVComment(),this.isIgnoreLeadingSpaces(),this.isInterpretUnicodeEscapes(),this.isIgnoreEmptyLines());
}
/**
* This method is used to set the controller object according to the input variables, which are supplied by the user interface.
* @param separator
* @param encapsulator
* @param comment
* @param ignoreLeads
* @param intUni
* @param ignoreEl
* @param headerLine
*/
public void ReadScreen(char separator, char encapsulator, char comment, boolean ignoreLeads, boolean intUni, boolean ignoreEl, boolean headerLine){
this.setCSVSeparator(separator);
this.setCSVEncapsulator(encapsulator);
this.setCSVComment(comment);
this.setIgnoreLeadingSpaces(ignoreLeads);
this.setInterpretUnicodeEscapes(intUni);
this.setIgnoreEmptyLines(ignoreEl);
this.setFHeaderLine(headerLine);
}
/**
* @param cSVSeparator the cSVSeparator to set
*/
public void setCSVSeparator(char cSVSeparator) {
CSVSeparator = cSVSeparator;
}
/**
* @return the cSVSeparator
*/
public char getCSVSeparator() {
return CSVSeparator;
}
/**
* @param cSVEncapsulator the cSVEncapsulator to set
*/
public void setCSVEncapsulator(char cSVEncapsulator) {
CSVEncapsulator = cSVEncapsulator;
}
/**
* @return the cSVEncapsulator
*/
public char getCSVEncapsulator() {
return CSVEncapsulator;
}
/**
* @param cSVComment the cSVComment to set
*/
public void setCSVComment(char cSVComment) {
CSVComment = cSVComment;
}
/**
* @return the cSVComment
*/
public char getCSVComment() {
return CSVComment;
}
/**
* @param ignoreLeadingSpaces the ignoreLeadingSpaces to set
*/
public void setIgnoreLeadingSpaces(boolean ignoreLeadingSpaces) {
this.ignoreLeadingSpaces = ignoreLeadingSpaces;
}
/**
* @return the ignoreLeadingSpaces
*/
public boolean isIgnoreLeadingSpaces() {
return ignoreLeadingSpaces;
}
/**
* @param interpretUnicodeEscapes the interpretUnicodeEscapes to set
*/
public void setInterpretUnicodeEscapes(boolean interpretUnicodeEscapes) {
this.interpretUnicodeEscapes = interpretUnicodeEscapes;
}
/**
* @return the interpretUnicodeEscapes
*/
public boolean isInterpretUnicodeEscapes() {
return interpretUnicodeEscapes;
}
/**
* @param ignoreEmptyLines the ignoreEmptyLines to set
*/
public void setIgnoreEmptyLines(boolean ignoreEmptyLines) {
this.ignoreEmptyLines = ignoreEmptyLines;
}
/**
* @return the ignoreEmptyLines
*/
public boolean isIgnoreEmptyLines() {
return ignoreEmptyLines;
}
/**
* @param csvstrat the csvstrat to set
*/
public void setCsvstrat(CSVStrategy csvstrat) {
this.csvstrat = csvstrat;
}
/**
* @return the csvstrat
*/
public CSVStrategy getCsvstrat() {
return csvstrat;
}
/**
* @param fHeaderLine the fHeaderLine to set
*/
public void setFHeaderLine(boolean fHeaderLine) {
this.fHeaderLine = fHeaderLine;
}
/**
* @return the fHeaderLine
*/
public boolean isFHeaderLine() {
return fHeaderLine;
}
}