GroundwaterData_User.java [src/WaterData] Revision: default  Date:
package WaterData;

import java.util.ArrayList;

/**
* Last Updated: 20-November-2018
* @author Tyler Wible
* @since 12-July-2012
*/
public class GroundwaterData_User implements GroundwaterDataInterface{
    public String database = "UserData";
    /**
     * * @param userDataRaw  The tab-delimited string of user data with header  
     * The expected format of the string is a tab-delimited text file 
     * (\n separating lines) with dates in the first column and daily 
     * average cfs values in the second column (\t separating columns).  
     * (Acceptable date formats for the first column are:
     * yyyy-mm-dd, 
     * yyyy-mm-d, 
     * yyyy-m-dd, 
     * yyyy-m-d, 
     * yyyy/mm/dd, 
     * yyyy/mm/d, 
     * yyyy/m/dd, 
     * yyyy/m/d)
     * (ex. "Date\tFlow\n1999-04-29\t8.3\n1999-05-09\t60.2\n1999-05-29\t20.1")
     */
    String userDataRaw = null;
    public GroundwaterData_User(String userDataProvided) {
        userDataRaw = userDataProvided;
    }

    @Override
    public ArrayList<String> extractWaterQualityData_raw(String stationId, String startDate, String endDate, String wqTest) throws WaterDataException {
        //Parse flow data from the raw user data string
        ArrayList<String> stationData = UserData.parseUserDataRaw(userDataRaw, startDate, endDate, wqTest);
        return stationData;
    }

    @Override
    public String[][] extractWaterQualityData_formatted(String stationId, String startDate, String endDate, String wqTest) throws WaterDataException {
        //Fetch water quality data
        ArrayList<String> stationData = extractWaterQualityData_raw(stationId, startDate, endDate, wqTest);
        
        //Reformat data
        String[][] returnArray = new String[stationData.size()][2];
        for(int i=0; i<returnArray.length; i++){
            String[] currentColumns = stationData.get(i).split("\t");
            //currentColumns[0] = date
            //currentColumns[1] = value
            returnArray[i][0] = currentColumns[0];
            returnArray[i][1] = currentColumns[1];
        }
        return returnArray;
    }

    @Override
    public ArrayList<String> extractWaterTableElevation_raw(String stationId, String startDate, String endDate) throws WaterDataException {
        //Parse water quality data from the raw user data string
        ArrayList<String> stationData = UserData.parseUserDataRaw(userDataRaw, startDate, endDate, "height");
        return stationData;
    }

    @Override
    public String[][] extractWaterTableElevation_formatted(String stationId, String startDate, String endDate) throws WaterDataException {
        //Fetch water table elevation (height) data
        ArrayList<String> stationData = extractWaterTableElevation_raw(stationId, startDate, endDate);
        
        //Reformat data
        String[][] returnArray = new String[stationData.size()][2];
        for(int i=0; i<returnArray.length; i++){
            String[] currentColumns = stationData.get(i).split("\t");
            //currentColumns[0] = date
            //currentColumns[1] = value
            returnArray[i][0] = currentColumns[0];
            returnArray[i][1] = currentColumns[1];
        }
        return returnArray;
    }

    @Override
    public ArrayList<String> extractDepthToWaterTable_raw(String stationId, String startDate, String endDate) throws WaterDataException {
        //Parse water quality data from the raw user data string
        ArrayList<String> stationData = UserData.parseUserDataRaw(userDataRaw, startDate, endDate, "depth");
        return stationData;
    }

    @Override
    public String[][] extractDepthToWaterTable_formatted(String stationId, String startDate, String endDate) throws WaterDataException {
        //Fetch depth to water table data
        ArrayList<String> stationData = extractDepthToWaterTable_raw(stationId, startDate, endDate);
        
        //Reformat data
        String[][] returnArray = new String[stationData.size()][2];
        for(int i=0; i<returnArray.length; i++){
            String[] currentColumns = stationData.get(i).split("\t");
            //currentColumns[0] = date
            //currentColumns[1] = value
            returnArray[i][0] = currentColumns[0];
            returnArray[i][1] = currentColumns[1];
        }
        return returnArray;
    }
    
}