All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.ssc.ref.FactoryOutputRefFromLibrary Maven / Gradle / Ivy

Go to download

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.ref;

import it.ssc.context.SessionIPRIV;
import it.ssc.context.exception.InvalidSessionException;
import it.ssc.dataset.exception.InvalidNameDataset;
import it.ssc.library.Library;
import it.ssc.library.exception.InvalidLibraryException;
import it.ssc.library.exception.LibraryNotFoundException;
import it.ssc.util.ParseLibDotDs;
import it.ssc.util.TestValidName;

public class FactoryOutputRefFromLibrary {
	
	public static OutputRefInterface createOutputRef(String lib_dot_dataset,SessionIPRIV parent_session) throws InvalidNameDataset, InvalidSessionException, LibraryNotFoundException, InvalidLibraryException {
		
		//A seconda del tipo di libreria crea un OutputrefDb o un outputreffmt
		//ALLA LIBRERIA LOCICA VERRA SOSTITUITO IL PATH FISOCO DI QUELLA LIBRERIA
		// E DAL NOME DEL DATASET IL NOME DEL FILE CON L'ESTENSIONE 
		// fa i controlli sull'esistenza della libreira 
		
		ParseLibDotDs pars_lib_dot_ds=new ParseLibDotDs(lib_dot_dataset);
		pars_lib_dot_ds.parse();
		String name_library=pars_lib_dot_ds.getLibrary();
		String name_dataset=pars_lib_dot_ds.getNameDs();	
		
		boolean exist_lib=parent_session.getFactoryLibraries().existLibrary(name_library);
		if(!exist_lib) throw new  LibraryNotFoundException(name_library);
		boolean test_name_ds=TestValidName.isValidNameDataset(name_dataset);
		if(!test_name_ds) throw new InvalidNameDataset(name_dataset);
		
		Library library=parent_session.getFactoryLibraries().getLibrary(name_library);
		if(library.isFmtLibrary()) {
			return new OutputRefFmt(library, name_dataset); 
		}
		else if(library.isDbLibrary()) {
			return new OutputRefDB(library, name_dataset); 
		}
		else {
			throw new InvalidLibraryException("ERRORE. Tipologia di libreria non considerata.");
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy