Infiltration.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.text.DecimalFormat;
import org.apache.commons.lang3.StringUtils;
import static utils.StringHelpers.splitWithQuotes;
/**
*
* @author Lucas Yaege
*/
public class Infiltration {
String subcatchment;
double maxRate;
double minRate;
double decay;
double dryTime;
double maxInfil;
DecimalFormat df = new DecimalFormat( "#.###" );
public Infiltration()
{
}
public Infiltration( String line )
{
String[] params = splitWithQuotes( line );
this.subcatchment = params[0];
this.maxRate = Double.parseDouble( params[1] );
this.minRate = Double.parseDouble( params[2] );
this.decay = Double.parseDouble( params[3] );
this.dryTime = Double.parseDouble( params[4] );
this.maxInfil = Double.parseDouble( params[5] );
}
public Infiltration( String subcatchment,
double maxRate,
double minRate,
double decay,
double dryTime,
double maxInfil )
{
this.subcatchment = subcatchment;
this.maxRate = maxRate;
this.minRate = minRate;
this.decay = decay;
this.dryTime = dryTime;
this.maxInfil = maxInfil;
}
@Override
public String toString()
{
return toString( 17, 40 );
}
public String toString( int padDistance, int namePadDistance )
{
StringBuilder sb = new StringBuilder();
sb.append( StringUtils.rightPad( this.subcatchment, namePadDistance ) );
sb.append( StringUtils.rightPad( df.format( this.maxRate ), padDistance ) );
sb.append( StringUtils.rightPad( df.format( this.minRate ), padDistance ) );
sb.append( StringUtils.rightPad( df.format( this.decay ), padDistance ) );
sb.append( StringUtils.rightPad( df.format( this.dryTime ), padDistance ) );
sb.append( StringUtils.rightPad( df.format( this.maxInfil ), padDistance ) );
sb.append( "\n" );
return sb.toString();
}
}