KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > search > PageSearcher


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
//
14
//
15

16 package org.jahia.services.search;
17
18 import org.jahia.data.search.JahiaSearchResult;
19 import org.jahia.exceptions.JahiaException;
20 import org.jahia.params.ParamBean;
21 import org.jahia.registries.ServicesRegistry;
22
23 import java.util.ArrayList JavaDoc;
24
25
26 /**
27  * Handle pages search.
28  * The result for this searcher is an instance of JahiaSearchResult and is a vector of matching pages.
29  *
30  * @author Khue Nguyen <a HREF="mailto:khue@jahia.org">khue@jahia.org</a>
31  */

32
33 public class PageSearcher extends JahiaSearcher {
34
35     private static final String JavaDoc CLASS_NAME = PageSearcher.class.getName ();
36     private ArrayList JavaDoc languageCodes = new ArrayList JavaDoc ();
37     private int[] siteIds = new int[]{};
38
39     //--------------------------------------------------------------------------
40
/**
41      * Constructor
42      */

43     public PageSearcher (int[] siteIds) {
44         this.siteIds = siteIds;
45     }
46
47     //--------------------------------------------------------------------------
48
/**
49      * Constructor
50      */

51     public PageSearcher (int[] siteIds, ArrayList JavaDoc languageCodes) {
52         this(siteIds);
53         if (languageCodes != null) {
54             this.languageCodes = languageCodes;
55         }
56     }
57
58     //--------------------------------------------------------------------------
59
/**
60      * Perform the search for a given query as String.
61      * The expected result is a JahiaSearchResult object containing a vector of matching pages.
62      *
63      * @param String query, a valid query.
64      * @param ParamBean jParams, the param bean.
65      *
66      * @return JahiaSearchResult result, the expected result as an instance of JahiaSearchResult object
67      */

68     public JahiaSearchResult search (String JavaDoc query, ParamBean jParams)
69             throws JahiaException {
70         JahiaSearchResult result = null;
71
72         // Must set the query first.
73
setQuery (query);
74
75         // Perform the search.
76
ServicesRegistry sReg = ServicesRegistry.getInstance ();
77         result = sReg.getJahiaSearchService ().search (this, jParams);
78
79         // Store the result.
80
setResult (result);
81
82         return result;
83     }
84
85     //--------------------------------------------------------------------------
86
/**
87      * Return the searcher name which value is JahiaSearcher.PAGE_SEARCHER.
88      * The search service must return a result of JahiaSearchResult type for this searcher.
89      *
90      * @return String name, the searcher name.
91      */

92     public String JavaDoc getName () {
93         return PageSearcher.PAGE_SEARCHER;
94     }
95
96     /**
97      * @return the list of languages code to search.
98      */

99     public ArrayList JavaDoc getLanguageCodes () {
100         return this.languageCodes;
101     }
102
103     public int[] getSiteIds() {
104         return siteIds;
105     }
106
107     public void setSiteIds(int[] siteIds) {
108         this.siteIds = siteIds;
109     }
110
111 }
112
Popular Tags