SearchArgs.java
Upload User: gdxydsw
Upload Date: 2019-01-29
Package Size: 16721k
Code Size: 4k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright (c) JForum Team
  3.  * All rights reserved.
  4.  * Redistribution and use in source and binary forms, 
  5.  * with or without modification, are permitted provided 
  6.  * that the following conditions are met:
  7.  * 1) Redistributions of source code must retain the above 
  8.  * copyright notice, this list of conditions and the 
  9.  * following  disclaimer.
  10.  * 2)  Redistributions in binary form must reproduce the 
  11.  * above copyright notice, this list of conditions and 
  12.  * the following disclaimer in the documentation and/or 
  13.  * other materials provided with the distribution.
  14.  * 3) Neither the name of "Rafael Steil" nor 
  15.  * the names of its contributors may be used to endorse 
  16.  * or promote products derived from this software without 
  17.  * specific prior written permission.
  18.  * 
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
  20.  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
  21.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
  22.  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  23.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  24.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
  25.  * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
  26.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  27.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  28.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  29.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  30.  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  31.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
  32.  * IN CONTRACT, STRICT LIABILITY, OR TORT 
  33.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  34.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  35.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  36.  * 
  37.  * This file creation date: 25/02/2004 - 19:16:25
  38.  * The JForum Project
  39.  * http://www.jforum.net
  40.  */
  41. package net.jforum.search;
  42. import java.util.Date;
  43. import net.jforum.util.preferences.ConfigKeys;
  44. import net.jforum.util.preferences.SystemGlobals;
  45. /**
  46.  * @author Rafael Steil
  47.  * @version $Id: SearchArgs.java,v 1.5 2007/07/30 21:59:21 rafaelsteil Exp $
  48.  */
  49. public class SearchArgs 
  50. {
  51. private String keywords;
  52. private int author;
  53. private String orderDir = "DESC";
  54. private String orderBy;
  55. private boolean matchAllKeywords;
  56. private int forumId;
  57. private int initialRecord;
  58. private Date fromDate;
  59. private Date toDate;
  60. private String matchType;
  61. public void setMatchType(String matchType)
  62. {
  63. this.matchType = matchType;
  64. }
  65. public String getMatchType()
  66. {
  67. return this.matchType;
  68. }
  69. public void setDateRange(Date fromDate, Date toDate)
  70. {
  71. this.fromDate = fromDate;
  72. this.toDate = toDate;
  73. }
  74. public Date getFromDate()
  75. {
  76. return this.fromDate;
  77. }
  78. public Date getToDate()
  79. {
  80. return this.toDate;
  81. }
  82. public int fetchCount()
  83. {
  84. return SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
  85. }
  86. public void startFetchingAtRecord(int initialRecord)
  87. {
  88. this.initialRecord = initialRecord;
  89. }
  90. public int startFrom()
  91. {
  92. return this.initialRecord;
  93. }
  94. public void setKeywords(String keywords)
  95. {
  96. this.keywords = keywords;
  97. }
  98. public void matchAllKeywords()
  99. {
  100. this.matchAllKeywords = true;
  101. }
  102. public void setAuthor(int author)
  103. {
  104. this.author = author;
  105. }
  106. public void setForumId(int forumId)
  107. {
  108. this.forumId = forumId;
  109. }
  110. public void setOrderBy(String orderBy)
  111. {
  112. this.orderBy = orderBy;
  113. }
  114. public void setOrderDir(String orderDir)
  115. {
  116. this.orderDir = orderDir;
  117. }
  118. public String[] getKeywords()
  119. {
  120. if (this.keywords == null || this.keywords.trim().length() == 0) {
  121. return new String[] {};
  122. }
  123. return this.keywords.trim().split(" ");
  124. }
  125. public String rawKeywords()
  126. {
  127. if (this.keywords == null) {
  128. return "";
  129. }
  130. return this.keywords.trim();
  131. }
  132. public boolean shouldMatchAllKeywords()
  133. {
  134. return this.matchAllKeywords;
  135. }
  136. public int getAuthor()
  137. {
  138. return this.author;
  139. }
  140. public int getForumId()
  141. {
  142. return this.forumId;
  143. }
  144. public String getOrderDir()
  145. {
  146. if (!"ASC".equals(this.orderDir) && !"DESC".equals(this.orderDir)) {
  147. return "DESC";
  148. }
  149. return this.orderDir;
  150. }
  151. public String getOrderBy()
  152. {
  153. return this.orderBy;
  154. }
  155. }