import java.util.Properties;

/**
 * This class provides a standard set of configuration properties and
 * defaults for the PopFetcher classes.
 *
 * @author      Simon Pollard
 * @see         java.util.Properties
 */

public class PopProperties {
  // property name constants
  /** The name of the property containing the POP3 server name */
  public static final String SERVER = "Server";
  /** The name of the property containing the POP3 username */
  public static final String USERNAME = "Username";
  /** The name of the property containing the POP3 password */
  public static final String PASSWORD = "Password";
  /** The name of the property containing the mail checking interval */
  public static final String FETCHTIME = "Check Interval (s)";

  // default properties
  private static final String SERVERDEFAULT = "POPServer";
  private static final String USERNAMEDEFAULT = "Username";
  private static final String PASSWORDDEFAULT = "Password";
  // so unconfigured setups won't try to pick up for a long time
  private static final String FETCHTIMEDEFAULT = "9999";

  /**
   * Empty constructor - this class should never be instantiated
   */
  PopProperties() { }

  // set default property values where necessary
  /**
   * Sets the default values on a given set of properties, if that
   * set doesn't contain a value for that property already.
   *
   * @param     checkProperties the set of Properties to check
   * @see       java.util.Properties
   */
  public static void setPopDefaults(Properties checkProperties) {
    if(checkProperties.getProperty(SERVER) == null)
      checkProperties.setProperty(SERVER, SERVERDEFAULT);
    if(checkProperties.getProperty(USERNAME) == null)
      checkProperties.setProperty(USERNAME, USERNAMEDEFAULT);
    if(checkProperties.getProperty(PASSWORD) == null)
      checkProperties.setProperty(PASSWORD, PASSWORDDEFAULT);
    if(checkProperties.getProperty(FETCHTIME) == null)
      checkProperties.setProperty(FETCHTIME, FETCHTIMEDEFAULT);
  }
}
