boundry = "##endofrow##";
nextBoundry = input.indexOf(boundry);
}
while (nextBoundry != -1) {
rows++;
VariableForImport var = new VariableForImport();
String oneRow = input.substring(lastBoundry, nextBoundry);
// logger.log(Level.INFO, "Input row: " + oneRow);
arry = ValidationHelper.separateToArray(oneRow, separator);
if (log.isDebugEnabled()) {
log.log(Level.INFO, "populateFromFile(): reading row: "
+ arry[NAMECOLUMN]);
}
if (arry[NAMECOLUMN].trim().length() > 0) {
if (arry[NAMECOLUMN] != null) {
var.setName(arry[NAMECOLUMN].toString());
}
if (arry[DESCRIPTIONCOLUMN] != null) {
var.setDescription(arry[DESCRIPTIONCOLUMN].toString()
.replaceAll(" :", " "));
}
if (arry[TYPECOLUMN] != null){
Class clazz = null;
try {
if(log.isDebugEnabled()){
log.log(Level.INFO, "Row: "+ rows +" Variable class: "+ arry[TYPECOLUMN]);
}
clazz = Class.forName(arry[TYPECOLUMN]);
if(ListElement.class.isAssignableFrom(clazz)) {
if(arry[ALTERNATIVESCOLUMN] != null){
Vector alternatives = new Vector();
Alternative alternative = new Alternative();
String[] altrows = ValidationHelper.separateToArray(
arry[ALTERNATIVESCOLUMN].toString(), "\n");
for (int r = 0; r < altrows.length; r++) {
String row = altrows[r].toString();
if (row.indexOf("=") != -1) {
alternative = new Alternative();
alternative.setValue(row.substring(0,
row.indexOf("=")).trim().replaceAll("\"",
""));
alternative.setText(row.substring(
row.indexOf("=") + 1).trim().replaceAll(
"\"", ""));
alternatives.add(alternative);
}
}
alternatives.trimToSize();
var.setAlternatvies(alternatives);
}
if(arry[ALTERNATIVESDATECOLUMN] != null) {
Vector alternatives = var.getAlternatvies();
Alternative alternative = new Alternative();
String[] altrows = ValidationHelper.separateToArray(
arry[ALTERNATIVESDATECOLUMN].toString(), "\n");
for (int r = 0; r < altrows.length; r++) {
String row = altrows[r].toString();
if (row.indexOf("=") != -1) {
alternative = (Alternative) alternatives.get(r);
int startPos = row.indexOf("=") + 1;
alternative.setStartDate(((row.substring(startPos,
row.indexOf("/")).trim()).replaceAll("\"",
"")).replaceAll("\\(", ""));
alternative.setEndDate(((row.substring(row
.indexOf("/") + 1).trim()).replaceAll("\"",
"")).replaceAll("\\)", ""));
}
}
alternatives.trimToSize();
var.setAlternatvies(alternatives);
}
}
} catch (ClassNotFoundException cnfe) {
log.log(Level.ERROR, "Unable to locate element class", cnfe);
}
}
if (arry[HELPTEXTCOLUMN] != null) {
var.setHelpTextID(arry[HELPTEXTCOLUMN].toString().trim()
.replaceAll("\"", "")
.replaceAll(" :", " "));
}
if (arry[TYPECOLUMN] != null) {
var.setType(arry[TYPECOLUMN].toString());
}
if (arry[TABLECOLUMN] != null) {
var.setTable(arry[TABLECOLUMN].toString());
}
// sets lang id for this variable
var.setLanguageid(languageid);
variables.add(var);
}
// lastBoundry = nextBoundry;
// nextBoundry = input.indexOf(boundry, (lastBoundry + boundry