ReportOptions.java [src/SwmmObjects] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SwmmObjects;

import java.util.HashMap;
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author Lucas Yaege
 */
public class ReportOptions
{

    HashMap<String, String> reportOptions;

    public ReportOptions()
    {
        reportOptions = new HashMap<String, String>();
    }

    public void addDefaultOptions()
    {
        //reportOptions.put("CONTROLS", "ALL");
        reportOptions.put("SUBCATCHMENTS", "ALL");
        reportOptions.put("NODES", "ALL");
        //reportOptions.put("LINKS", "ALL");
    }

    public void setReportOption(String line)
    {
        String id = line.substring(0, line.indexOf(" "));
        String value = line.substring(
                (line.lastIndexOf(" ") + 1),
                (line.length()));
        reportOptions.put(id, value);
    }

    @Override
    public String toString()
    {
        StringBuilder builder = new StringBuilder();

        //get longest key in the reportOptions hashmap.
        int maxValueLength = 0;
        for (String key : reportOptions.keySet())
        {
            if (key.length() > maxValueLength)
            {
                maxValueLength = key.length();
            }
        }

        builder.append("[REPORT]\n");
        builder.append(StringUtils.rightPad(";;Reporting Options", maxValueLength + 2));
        builder.append("\n");
        
        for (String key : reportOptions.keySet())
        {
            String value = reportOptions.get(key);
            //use rightpad for proper alignment.
            builder.append(StringUtils.rightPad(key, maxValueLength + 2)).append(value).append("\n");
        }

        builder.append("\n");

        return builder.toString();
    }

}