/* ===================================================================
 * UserCriteriaImpl.java
 * 
 * Created Mar 9, 2005 2:06:20 PM
 * 
 * Copyright (c) 2005 Matt Magoffin (spamsqr@msqr.us)
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
 * 02111-1307 USA
 * ===================================================================
 * $Id: UserCriteriaImpl.java 24 2009-05-03 23:17:13Z msqr $
 * ===================================================================
 */

package magoffin.matt.ieat.util;

import java.util.LinkedHashSet;
import java.util.Set;

import magoffin.matt.ieat.biz.RecipeSearchBiz.UserCriteria;
import magoffin.matt.lucene.SearchCriteria;


/**
 * Implementation of UserCriteria.
 * 
 * @author Matt Magoffin (spamsqr@msqr.us)
 * @version $Revision: 24 $ $Date: 2009-05-04 11:17:13 +1200 (Mon, 04 May 2009) $
 */
public class UserCriteriaImpl implements UserCriteria, SearchCriteria {
	
	private int searchMode = UserCriteria.MODE_USERS_BY_ID;
	private Set<Integer> userIdList = new LinkedHashSet<Integer>();
	private String query = null;
	private int maxResults = -1;
	private int pageSize = -1;
	private int page = 1;
	private boolean countOnly = false;

	/**
	 * Set the search mode.
	 * 
	 * <p>This defaults to {@link UserCriteria#MODE_USERS_BY_ID}.</p>
	 * @param searchMode the seach mode
	 */
	public void setSearchMode(int searchMode) {
		this.searchMode = searchMode;
	}
	
	/**
	 * Add a user ID to the user ID list.
	 * @param userId the user ID to add
	 */
	public void addUserId(Integer userId) {
		userIdList.add(userId);
	}
	
	/**
	 * Clear out the user ID list so that it is empty.
	 */
	public void clearUserIds() {
		userIdList.clear();
	}
	
	/* (non-Javadoc)
	 * @see magoffin.matt.ieat.biz.RecipeSearchBiz.UserCriteria#getSearchMode()
	 */
	public int getSearchMode() {
		return searchMode;
	}

	/* (non-Javadoc)
	 * @see magoffin.matt.ieat.biz.RecipeSearchBiz.UserCriteria#getUserIds()
	 */
	public Integer[] getUserIds() {
		return userIdList.toArray(new Integer[userIdList.size()]);
	}
	
	/**
	 * @return the query
	 */
	public String getQuery() {
		return query;
	}
	
	/**
	 * @param query the query to set
	 */
	public void setQuery(String query) {
		this.query = query;
	}

	/**
	 * @return the maxResults
	 */
	public int getMaxResults() {
		return maxResults;
	}

	/**
	 * @param maxResults the maxResults to set
	 */
	public void setMaxResults(int maxResults) {
		this.maxResults = maxResults;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the page
	 */
	public int getPage() {
		return page;
	}

	/**
	 * @param page the page to set
	 */
	public void setPage(int page) {
		this.page = page;
	}

	/**
	 * @return the countOnly
	 */
	public boolean isCountOnly() {
		return countOnly;
	}

	/**
	 * @param countOnly the countOnly to set
	 */
	public void setCountOnly(boolean countOnly) {
		this.countOnly = countOnly;
	}
	
}
