View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not 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.
15   */
16  
17  package org.apache.portals.graffito.search;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  import java.util.List;
22  
23  import org.apache.portals.graffito.model.CmsObject;
24  
25  
26  /***
27   * Container for search result entries
28   *
29   * @author <a href="mailto:taylor@apache.org">David Sean taylor</a>
30   * @version $Id: SearchResults.java,v 1.1 2004/12/22 21:16:12 christophe Exp $
31   */
32  public class SearchResults
33  {
34      private List results = null;
35  
36      /***
37       */
38      public SearchResults()
39      {
40          init(0);
41      }
42  
43      /***
44       * 
45       * @param initialCapacity
46       */
47      public SearchResults(int initialCapacity)
48      {
49          init(initialCapacity);
50      }
51  
52      /***
53       * 
54       * @param initialCapacity
55       */
56      private void init(int initialCapacity)
57      {
58          results = new ArrayList(initialCapacity);
59      }
60  
61      /***
62       * 
63       * @param searchResult
64       * @return 
65       */
66      public boolean add(CmsObject cmsObject)
67      {
68          return results.add(cmsObject);
69      }
70  
71      /***
72       * 
73       * @param index
74       * @param searchResult
75       */
76      public void add(int index, CmsObject cmsObject)
77      {
78          results.add(index, cmsObject);
79          return;
80      }
81      
82      /***
83       * 
84       * @param index
85       * @param searchResult
86       */
87      public void addAll(Collection cmsObjects)
88      {
89          results.addAll(cmsObjects);
90          return;
91      }
92      
93  
94      /***
95       * 
96       * @param index
97       * @return 
98       */
99      public CmsObject get(int index)
100     {
101         return(CmsObject) results.get(index);
102     }
103 
104     /***
105      * 
106      * @return 
107      */
108     public int size()
109     {
110         return results.size();
111     }
112 
113     /***
114      * 
115      * @return 
116      */
117     public List getResults()
118     {
119         return this.results;
120     }
121     
122 }