Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/intabulas/sandler/api/impl/SearchResultsImpl.java


1   /**
2    * Copyright (c) 2003, Mark Lussier
3    * All rights reserved.
4    *
5    * Portions Copyright (c) 2003 by David A. Czarnecki
6    *
7    * Redistribution and use in source and binary forms, with or without
8    * modification, are permitted provided that the following conditions are met:
9    *
10   * Redistributions of source code must retain the above copyright notice,
11   *      this list of conditions and the following disclaimer.
12   * Redistributions in binary form must reproduce the above copyright notice,
13   *      this list of conditions and the following disclaimer in the documentation
14   *      and/or other materials provided with the distribution.
15   * Neither the name of the "Mark Lussier" and "Sandler" nor the names of
16   * its contributors may be used to endorse or promote products derived from
17   * this software without specific prior written permission.
18   * Products derived from this software may not be called "Sandler",
19   * nor may "Sandler" appear in their name, without prior written permission of
20   * Mark Lussier
21   *
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23   * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
26   * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
27   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29   * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31   * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35   */
36  package org.intabulas.sandler.api.impl;
37  
38  import org.intabulas.sandler.api.SearchResults;
39  import org.intabulas.sandler.elements.AtomElement;
40  import org.intabulas.sandler.elements.Entry;
41  
42  import java.util.ArrayList;
43  import java.util.List;
44  
45  /**
46   * SearchResults
47   *
48   * @author Mark Lussier
49   * @version $Id: SearchResultsImpl.java,v 1.1 2003/09/10 16:48:41 intabulas Exp $
50   */
51  public class SearchResultsImpl implements SearchResults, AtomElement {
52  
53      private List _entryList;
54  
55      public SearchResultsImpl() {
56          _entryList = new ArrayList(1);
57      }
58  
59  
60      /**
61       *
62       * @return
63       */
64      public int getEntryCount() {
65          return _entryList.size();
66      }
67  
68      /**
69       *
70       * @param index
71       * @return
72       */
73      public Entry getEntry(int index) {
74          Entry result = null;
75          if (index >= 0 && index < _entryList.size()) {
76              result = (Entry) _entryList.get(index);
77          }
78          return result;
79      }
80  
81      /**
82       *
83       * @param entry
84       */
85      public boolean addEntry(Entry entry) {
86          return _entryList.add(entry);
87      }
88  
89      /**
90       *
91       * @param index
92       * @param entry
93       */
94      public void addEntry(int index, Entry entry) {
95          _entryList.add(index, entry);
96      }
97  
98  
99      /**
100      * Returns a string representation of the object.
101      *
102      * @return  a string representation of the object.
103      */
104     public String toString() {
105         StringBuffer buffer = new StringBuffer(HTMLTAG_START).append(ELEMENT_SEARCHRESULTS).append(" xmlns=");
106         buffer.append(ATOM_NAMESPACE).append(HTMLTAG_CLOSE);
107 
108 
109         if (_entryList.size() > 0) {
110             for (int x = 0; x < _entryList.size(); x++) {
111                 Entry entry = (Entry) _entryList.get(x);
112                 buffer.append(entry.toString());
113             }
114 
115         }
116 
117         buffer.append(HTMLTAG_BEGIN).append(ELEMENT_SEARCHRESULTS).append(HTMLTAG_CLOSE);
118 
119         return buffer.toString();
120     }
121 }