KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > rendering > pagers > SearchResultsPager


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. The ASF licenses this file to You
4  * under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. For additional information regarding
15  * copyright in this work, please see the NOTICE file in the top level
16  * directory of this distribution.
17  */

18
19 package org.apache.roller.ui.rendering.pagers;
20
21 import java.util.Map JavaDoc;
22 import java.util.ResourceBundle JavaDoc;
23 import org.apache.roller.pojos.WebsiteData;
24 import org.apache.roller.ui.rendering.util.WeblogSearchRequest;
25 import org.apache.roller.util.URLUtilities;
26
27
28 /**
29  * Pager for navigating through search results.
30  */

31 public class SearchResultsPager implements WeblogEntriesPager {
32     
33     private Map JavaDoc entries = null;
34     
35     private WebsiteData weblog = null;
36     private String JavaDoc locale = null;
37     private String JavaDoc query = null;
38     private String JavaDoc category = null;
39     private int page = 0;
40     private boolean moreResults = false;
41     
42     private static ResourceBundle JavaDoc bundle =
43             ResourceBundle.getBundle("ApplicationResources");
44     
45     
46     public SearchResultsPager() {}
47     
48     public SearchResultsPager(WeblogSearchRequest searchRequest, Map JavaDoc entries, boolean more) {
49         
50         // store search results
51
this.entries = entries;
52         
53         // data from search request
54
this.weblog = searchRequest.getWeblog();
55         this.query = searchRequest.getQuery();
56         this.category = searchRequest.getWeblogCategoryName();
57         this.locale = searchRequest.getLocale();
58         this.page = searchRequest.getPageNum();
59         
60         // does this pager have more results?
61
this.moreResults = more;
62     }
63     
64     
65     public Map JavaDoc getEntries() {
66         return entries;
67     }
68     
69     
70     public String JavaDoc getHomeLink() {
71         return URLUtilities.getWeblogURL(weblog, locale, false);
72     }
73
74     public String JavaDoc getHomeName() {
75         return bundle.getString("searchPager.home");
76     }
77
78     
79     public String JavaDoc getNextLink() {
80         if(moreResults) {
81             return URLUtilities.getWeblogSearchURL(weblog, locale, query, category, page + 1, false);
82         }
83         return null;
84     }
85
86     public String JavaDoc getNextName() {
87         if (getNextLink() != null) {
88             return bundle.getString("searchPager.next");
89         }
90         return null;
91     }
92
93     public String JavaDoc getPrevLink() {
94         if(page > 0) {
95             return URLUtilities.getWeblogSearchURL(weblog, locale, query, category, page - 1, false);
96         }
97         return null;
98     }
99
100     public String JavaDoc getPrevName() {
101         if (getPrevLink() != null) {
102             return bundle.getString("searchPager.prev");
103         }
104         return null;
105     }
106
107     
108     public String JavaDoc getNextCollectionLink() {
109         return null;
110     }
111
112     public String JavaDoc getNextCollectionName() {
113         return null;
114     }
115
116     public String JavaDoc getPrevCollectionLink() {
117         return null;
118     }
119
120     public String JavaDoc getPrevCollectionName() {
121         return null;
122     }
123     
124 }
125
Popular Tags