RepositoryJavadoc

code format="java" package faceplace;

/**
 * Used to store and maintain User, Group, and Event objects representing
 * user accounts, groups, and events for the faceplace webapp. It can add
 * new Users, Groups, and Events, as well as delete and search them.

import java.util.ArrayList; import java.util.Hashtable; import java.io.File; import java.io.FilenameFilter;

public class Repository {

private static Repository theInstance; private static Hashtable users; private static Hashtable groups; private static Hashtable events;

private Repository { users = new Hashtable; groups = new Hashtable; events = new Hashtable;

}

/**    public static Repository instance {
 * Returns a Repository, which is the only instance of a Repository object
 * as it is a singleton class. It also creates the single instance if no
 * Repository has been previously instantiated.
 * @returns a Repository that is the only instance of a Repository object.

}

/**    public User createNewUser(String username, String email, String password) { User newUser = new User(username, email, password); users.put(username, newUser); return getUser(username); }
 * Creates a new User object, which is stored in the Repository, and is
 * then returned.
 * @params username a String containing the username of the User
 * to be created.
 * @params email a String containing the email address of the User
 * to be created.
 * @params password a String containing the password of the User
 * to be created.
 * @returns the newly created User object.

/**    public User getUser(String username) { return users.get(username); }
 * Returns a specified User, if it exists, from the single instance of
 * the Repository.
 * @params username a String that contains the username of the
 * User that is to be returned.
 * @returns the User whose username matches the given
 * username, if such User exists. Otherwise null is returned.

/**    public Group createNewGroup(String groupName, String description) { Group newGroup = new Group(groupName, description); groups.put(groupName, newGroup); return getGroup(groupName); }
 * Creates a new Group object, which is stored in the Repository, and is
 * then returned.
 * @params groupName a String containing the name of the Group
 * to be created.
 * @params description a String containing a description of the Group
 * to be created. This is text that is to describe the purpose of the newly
 * created Group.
 * @returns the newly created Group object.

/**    public Group getGroup(String groupName) { return groups.get(groupName); }
 * Returns a specified Group, if it exists, from the single instance of
 * the Repository.
 * @params groupName a String that contains the name of the
 * Group that is to be returned.
 * @returns the Group whose name matches the given
 * group name, if such Group exists. Otherwise null is returned.

/**    public Event createNewEvent(String eventName, String description, long date) { Event newEvent = new Event(eventName, description, date); events.put(eventName, newEvent); return getEvent(eventName); }
 * Creates a new Event object, which is stored in the Repository, and is
 * then returned.
 * @params eventName a String containing the name of the Event
 * to be created.
 * @params description a String containing a description of the Event
 * to be created. This is text that is to describe the purpose of the newly
 * created Event.
 * @params date a long containing the date and time the Event
 * that is to be created will occur.
 * @returns the newly created Event object.

/**    public Event getEvent(String eventName) { return events.get(eventName); }
 * Returns a specified Event, if it exists, from the single instance of
 * the Repository.
 * @params eventName a String that contains the name of the
 * Event that is to be returned.
 * @returns the Event whose name matches the given
 * eventName, if such Event exists. Otherwise null is returned.

/**    public ArrayList searchUser(String searchItem) {
 * Searches through the Hashtable of User objects looking for the
 * occurrence of a specified name and returns an ArrayList of any
 * User object who's username contains the searched for name.
 * @params searchItem a String which contains a name that is to be
 * compared to the usernames of each User object to look for which
 * usernames contain the searched for name.
 * @returns an ArrayList of User objects with usernames containing the
 * searched for name. The usernames can be exact matches or just contain
 * the searched for name as only part of the username.

}

/**    public ArrayList searchGroup(String searchItem) {
 * Searches through the Hashtable of Group objects looking for the
 * occurrence of a specified name and returns an ArrayList of any
 * Group object who's group name contains the searched for name.
 * @params searchItem a String which contains a name that is to be
 * compared to the names of each Group object to look for which
 * group names contain the searched for name.
 * @returns an ArrayList of Group objects with names containing the
 * searched for name. The group names can be exact matches or just contain
 * the searched for name as only part of the group name.

}

/**    public ArrayList searchEvent(String searchItem) {
 * Searches through the Hashtable of Event objects looking for the
 * occurrence of a specified name and returns an ArrayList of any
 * Event object who's event name contains the searched for name.
 * @params searchItem a String which contains a name that is to be
 * compared to the event names of each Event object to look for which
 * names contain the searched for name.
 * @returns an ArrayList of Event objects with names containing the
 * searched for name. The event names can be exact matches or just contain
 * the searched for name as only part of the event name.

}

} code