Select Git revision
allvars.hpp
Subsurvey.java 3.30 KiB
import java.util.logging.Logger;
/* for loadSubsurveys from csv */
import com.opencsv.*;
import com.opencsv.exceptions.*;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
/* NOTE originally was in search/output : designed for serializing search output xml */
class Subsurvey
{
private static final Logger LOGGER = Logger.getLogger("Subsurvey");
String description;
String surveyname;
String species;
String transition;
double rf; // rest frequency
String rf_unit;
String vel_unit;
Dataset[] datasetArr;
Subsurvey() { datasetArr = null; }
Subsurvey(Subsurvey ss)
{
this.description = ss.description;;
this.surveyname = ss.surveyname;
this.species = ss.species;
this.transition = ss.transition;
this.rf = ss.rf;
this.rf_unit = ss.rf_unit;
this.vel_unit = ss.vel_unit;
this.datasetArr = null;
}
String id() { return (this.surveyname + " " + this.species + " " + this.transition); }
boolean matches(String id) { return id.equals(this.id()); }
static public Subsurvey findSubsurvey(Subsurvey[] dbSubsurveys, String subsurvey_id)
{
for(Subsurvey curr : dbSubsurveys)
{
if(curr.matches(subsurvey_id))
{
return curr;
}
}
throw new AssertionError(subsurvey_id + " not found in surveys table");
}
public static Subsurvey[] loadSubsurveys(String csvFilename)
{
List<Subsurvey> subsurveyList = new ArrayList<>();
try
{
// FIXME parser not robust:
// * eats space-character also within the field: , hu ha , --> "huha" not "hu ha"
// * double quote used inside string not escaped: ,"blabla 25\" res",
// * last record (line) is missing if that line is not closed with EOL