001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004:
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008:
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * This file creation date: 25/02/2004 - 19:16:25
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.search;
044:
045: import java.util.Date;
046:
047: import net.jforum.util.preferences.ConfigKeys;
048: import net.jforum.util.preferences.SystemGlobals;
049:
050: /**
051: * @author Rafael Steil
052: * @version $Id: SearchArgs.java,v 1.5 2007/07/30 21:59:21 rafaelsteil Exp $
053: */
054: public class SearchArgs {
055: private String keywords;
056: private int author;
057: private String orderDir = "DESC";
058: private String orderBy;
059: private boolean matchAllKeywords;
060: private int forumId;
061: private int initialRecord;
062: private Date fromDate;
063: private Date toDate;
064: private String matchType;
065:
066: public void setMatchType(String matchType) {
067: this .matchType = matchType;
068: }
069:
070: public String getMatchType() {
071: return this .matchType;
072: }
073:
074: public void setDateRange(Date fromDate, Date toDate) {
075: this .fromDate = fromDate;
076: this .toDate = toDate;
077: }
078:
079: public Date getFromDate() {
080: return this .fromDate;
081: }
082:
083: public Date getToDate() {
084: return this .toDate;
085: }
086:
087: public int fetchCount() {
088: return SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
089: }
090:
091: public void startFetchingAtRecord(int initialRecord) {
092: this .initialRecord = initialRecord;
093: }
094:
095: public int startFrom() {
096: return this .initialRecord;
097: }
098:
099: public void setKeywords(String keywords) {
100: this .keywords = keywords;
101: }
102:
103: public void matchAllKeywords() {
104: this .matchAllKeywords = true;
105: }
106:
107: public void setAuthor(int author) {
108: this .author = author;
109: }
110:
111: public void setForumId(int forumId) {
112: this .forumId = forumId;
113: }
114:
115: public void setOrderBy(String orderBy) {
116: this .orderBy = orderBy;
117: }
118:
119: public void setOrderDir(String orderDir) {
120: this .orderDir = orderDir;
121: }
122:
123: public String[] getKeywords() {
124: if (this .keywords == null || this .keywords.trim().length() == 0) {
125: return new String[] {};
126: }
127:
128: return this .keywords.trim().split(" ");
129: }
130:
131: public String rawKeywords() {
132: if (this .keywords == null) {
133: return "";
134: }
135:
136: return this .keywords.trim();
137: }
138:
139: public boolean shouldMatchAllKeywords() {
140: return this .matchAllKeywords;
141: }
142:
143: public int getAuthor() {
144: return this .author;
145: }
146:
147: public int getForumId() {
148: return this .forumId;
149: }
150:
151: public String getOrderDir() {
152: if (!"ASC".equals(this .orderDir)
153: && !"DESC".equals(this .orderDir)) {
154: return "DESC";
155: }
156:
157: return this .orderDir;
158: }
159:
160: public String getOrderBy() {
161: return this.orderBy;
162: }
163: }
|