SelectOrJoinConfiguration.java

package edu.hawaii.ics.yucheng;

import java.util.Properties;

/**
 * An immutable class that contains the configuration information for a cluster
 * of nodes and a catalog. They are parsed from the 'clustercfg' file, and works
 * specifically as the configuration for executing select and join statements on
 * this distributed system.
 * 
 * @author Cheng Jade
 * @assignment ICS 421 Project
 * @date Mar 19, 2010
 * @bugs None
 */
public class SelectOrJoinConfiguration {

    // The catalog node configuration
    public final ConfigurationNode catalog;

    // The local node configuration
    public final ConfigurationNode localNode;

    /**
     * return a string with class data.
     */
    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
        builder.append("- catalog:\n" + this.catalog);
        builder.append("\n- local node:\n " + this.localNode);
        return builder.toString();
    }

    /**
     * initialize an instance of this object
     */
    public SelectOrJoinConfiguration(final Properties properties, final ConfigurationNode catalog) throws ProgramException {
        // Throw an exception if the specified properties is null.
        if (null == properties)
            throw new NullPointerException("properties");

        this.catalog = catalog;
        ConfigurationNode tryLocalNode;
        try {
            tryLocalNode = new ConfigurationNode(properties, "localnode");
        } catch (final ProgramException e) {
            tryLocalNode = catalog;
        }
        this.localNode = tryLocalNode;
    }
}
Valid HTML 4.01 Valid CSS