it.ssc.step.readdata.ReadDataFromObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsr331-ssc Show documentation
Show all versions of jsr331-ssc Show documentation
This is a JSR331 interface for SSC (Software for the Calculation of the Simplex) is a java library for solving linear programming problems v. 3.0.1.
SSC was designed and developed by Stefano Scarioli.
The newest version!
package it.ssc.step.readdata;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import it.ssc.log.SscLogger;
import it.ssc.parser.InputDichiarationInfo;
import it.ssc.parser.InputSubDichiarationInterface;
import it.ssc.parser.InputSubDichiarationVar;
import it.ssc.parser.exception.InvalidDateFormatException;
import it.ssc.pdv.PDV;
import it.ssc.pdv.PDVAll;
import it.ssc.pdv.PDVField;
import it.ssc.ref.Input;
import it.ssc.ref.InputRows;
import it.ssc.step.exception.ErrorStepInvocation;
import it.ssc.step.exception.InvalidObjectException;
/**
* Leggo una stringa di input, la suddivido in token Mantengo sempre la stringa
* originaria. Vedo se il primo campo e a lettura libera o no. Se si prendo il
* primo token, altrimenti faccio substring della stringa originaria. Leggo il
* valore e lo memorizzo nel PDV.
*
* @author Stefano Scarioli
*
*/
class ReadDataFromObject implements ReadDataInterface {
private static final Logger logger = SscLogger.getLogger();
private InputRows ref_string;
private InputDichiarationInfo info_input_step;
private OptionsRead options_read;
/* RICORDARSI DELLA GESTIONE DEI MISSING */
ReadDataFromObject(Input ref, OptionsRead options_read) {
/*
* Posso tranquillamente fare il cast perche ho controllato a monte,
* nella classe read data, che e' di tipo InputObject
*/
this.ref_string = ((InputRows) ref);
this.info_input_step = ref_string.getInputDichiarationInfo();
this.options_read = options_read;
}
public PDV createPDV() throws InvalidDateFormatException {
int num_var = info_input_step.getColumnCount();
PDV pdv = new PDV();
pdv.setTokenMissing(this.ref_string.getMissingValue());
for (int _a = 0; _a < num_var; _a++) {
String name_var = info_input_step.getDichiarationVar(_a + 1).getNameVar();
Class> type_var = info_input_step.getDichiarationVar(_a + 1).getTypeVar();
PDVField> pdv_field = pdv.addNewField(name_var, type_var);
pdv_field.lentgh_field = info_input_step.getDichiarationVar(_a + 1).getLengthVar();
// System.out.println("LLL:"+pdv_field.lentgh_field );
pdv_field.date_format_input = info_input_step.getDichiarationVar(_a + 1).getFormatDate();
pdv_field.manager_missing_value = info_input_step.getDichiarationVar(_a + 1).getSettingMissing();
pdv_field.type_sql = info_input_step.getDichiarationVar(_a + 1).getTypeSql();
}
return pdv;
}
public SourceDataInterface getSourceData() throws IOException {
return new SourceData(ref_string.getListObject());
}
private final class SourceData implements SourceDataInterface {
private ArrayList list_input_step;
private ArrayList