package edu.hawaii.ics.yucheng; import java.util.Properties; /** * A pair of numbers from from the configuration file. * * @author Cheng Jade * @assignment ICS 421 Assignment 2-2 * @date Feb 29, 2010 * @bugs None */ public class ParameterPair { /** The first parameter value. */ public final String param1; /** The second parameter value. */ public final String param2; /** * Initializes a new instance of the ParameterPair class. * *@param properties * The properties object. * *@param index * The node index. * *@throws NullPointerException *@throws ProgramException * Thrown if there is a problem reading the properties. */ public ParameterPair( final Properties properties, final int index) throws ProgramException { if (properties == null) throw new NullPointerException("properties"); // Read the corresponding lines from the properties object this.param1 = properties.getProperty("partition.node" + index + ".param1"); this.param2 = properties.getProperty("partition.node" + index + ".param2"); } /** * Initializes a new instance of the ParameterPair class. * *@param properties * The properties object. * *@param param1 * The first parameter value. * *@throws NullPointerException *@throws ProgramException * Thrown if there is a problem reading the properties. */ public ParameterPair(final String param1) { if (param1 == null) throw new NullPointerException("param1"); // Assign the parameter values to the class fields. this.param1 = param1; this.param2 = null; } /** * Returns the string representation of the class data. * * @return The string representation of the class data. */ public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(" partition param1: "); builder.append(this.param1); builder.append("\n"); builder.append(" partition param2: "); builder.append(this.param2); return builder.toString(); } }