public Object construct() {
int i, maxInd, j, k;
boolean[] catchVal = new boolean[param.getOptions()[0]];
boolean[] sel = param.getVarSelected();
FileWriter w = null;
PatternMatcherInput input = new PatternMatcherInput("");
Perl5Compiler myComp = new Perl5Compiler();
Perl5Matcher myMatch = new Perl5Matcher();
String line = "";
String[] regExp = param.getRegularExp();
String[] separator = param.getSeparator();
double[] lineValue = new double[param.getNumVarSelected()];
String[] lineToken = new String[param.getNumVar()];
String parseToken = null;
MatrixOsservazioni m = null;
try {
w = new FileWriter(MacroReplacer.replace(LOG_FILE_NAME));
} catch (IOException e1) {
e1.printStackTrace();
}
try {
initShow(param.getOptions()[1] + 1);
maxInd = generateRandom(param.getOptions()[0], param.getOptions()[1], catchVal);
countObs = 0;
totalRaw = 0;
line = reader.readLine();
for (k = 0; k <= maxInd; k++) {
if (isCanceled()) {
try {
w.close();
} catch (IOException e) {
e.printStackTrace();
}
valori = null;
msg = INPUT_MSG_ABORT;
return null;
}
if (!catchVal[k]) {
line = reader.readLine();
continue;
}
input.setInput(line);
totalRaw++;
countObs++;
if (totalRaw % getStep() == 0) {
updateInfos(totalRaw, "<HTML># observations read: " + totalRaw + "<p># errors: " + (totalRaw - countObs) + "</HTML>", false);
}
//Legge le stringhe e ne controlla il formato
for (i = 0; i < param.getNumVar(); i++) {
//Leggo il token con i separatori (se definiti) qualunque cosa ci sia dentro
if (separator[i] != null) {
parseToken = separator[i];
} else {
parseToken = regExp[i];
}
if (myMatch.contains(input, myComp.compile(parseToken))) {
if (sel[i]) {
//Prendo il token
lineToken[i] = myMatch.getMatch().toString();
if (separator[i] != null) {
// Se il token aveva dei separatori li tolgo
lineToken[i] = lineToken[i].substring(1, lineToken[i].length() - 1);
//E prendo quello che mi interessa di cio che rimane
if (myMatch.contains(lineToken[i], myComp.compile(regExp[i]))) {
lineToken[i] = myMatch.getMatch().toString();
} else {
//Riga sbagliata, decremento il num di oss
countObs--;
try {
w.write("Error in row " + k + " : Element " + i + " is wrong\n");
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
}
} else {
//Riga sbagliata, decremento il num di oss
countObs--;
try {
w.write("Error in row " + k + " : Line doesn't match format (element " + i + " not found)\n");
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
j = 0;
//Riga Corretta
if (i == param.getNumVar()) {
if (input.endOfInput()) {
//Converte i valori (stringa) letti
for (i = 0; i < param.getNumVar(); i++) {
if (sel[i]) {
if (map[i] == null) {
lineValue[j++] = Double.parseDouble(lineToken[i]);