package org.apache.struts.webapp.example;

import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;


public final class Project implements Serializable {


    // --------------------------------------------------- Instance Variables


    /**
     * Should we auto-connect at startup time?
     */
    private boolean autoConnect = false;


    /**
     * The Project ID.
     */
    private String prjId = null;


    /**
     * The Project name.
     */
    private String prjName = null;


    /**
     * The Module Id.
     */
    private String modId = null;

    /**
     * The set of Subscriptions associated with this User.
     */
    private Hashtable projects = new Hashtable();


    // ----------------------------------------------------------- Properties

    /**
     * Return the auto-connect flag.
     */
    public boolean getAutoConnect() {

        return (this.autoConnect);

    }

    /**
     * Return the Project ID.
     */
    public String getPrjId() {

	return (this.prjId);

    }


    /**
     * Set the Project Id.
     *
     */
    public void setPrjId(String prjId) {

        this.prjId = prjId;

    }

    /**
     * Return the Project Name.
     */
    public String getPrjName() {

	return (this.prjName);

    }


    /**
     * Set the Project Name.
     *
     */
    public void setPrjName(String prjName) {

        this.prjName = prjName;

    }

    /**
     * Return the Module Id.
     */
    public String getModId() {

	return (this.modId);

    }


    /**
     * Set the Module Id.
     *
     */
    public void setModId(String modId) {

        this.modId = modId;

    }

    // --------------------------------------------------------- Public Methods


    /**
     * Return a String representation of this object.
     */
/*    public String toString() {

        StringBuffer sb = new StringBuffer("Subscription[prjId=");
        sb.append(prjId);
        if (prjId != null) {
            sb.append(", prjId=");
            sb.append(prjId);
        }
        if (prjName != null) {
            sb.append(", prjName=");
            sb.append(user.getprjName());
        }
        sb.append(", autoConnect=");
        sb.append(autoConnect);
        sb.append("]");
        return (sb.toString());

    }
*/
    /**
     * Find and return all Subscriptions associated with this user.  If there
     * are none, a zero-length array is returned.
     */
    public Project[] getProjects() {

	synchronized (projects) {
	    Project results[] = new Project[projects.size()];
	    Enumeration pros = projects.elements();
	    int n = 0;
	    while (pros.hasMoreElements()) {
		results[n++] = (Project) pros.nextElement();
	    }
	    return (results);
	}

    }

}
