1 13 package org.jahia.data.search; 18 19 import java.util.BitSet ; 20 import java.util.Collection ; 21 import java.util.Map ; 22 import java.util.HashMap ; 23 import java.util.Vector ; 24 import org.jahia.services.search.JahiaSearchResultHandler; 25 26 34 public class JahiaSearchResult 35 { 36 37 40 private Vector results = new Vector (); 42 46 private BitSet bits = new BitSet (); 48 52 private Collection parsedObjects; 54 57 private Map hitsByPage = new HashMap (); 58 59 private JahiaSearchResultHandler searchResultHandler; 60 61 64 private int hitcount ; 65 66 public JahiaSearchResult(JahiaSearchResultHandler searchResultHandler){ 67 this.searchResultHandler = searchResultHandler; 68 } 69 70 public JahiaSearchResult(JahiaSearchResultHandler searchResultHandler, 71 Collection parsedObjects){ 72 this.searchResultHandler = searchResultHandler; 73 this.parsedObjects = parsedObjects; 74 } 75 76 83 public void addHit(JahiaSearchHit hit ){ 84 if ( hit == null ) 85 return; 86 87 results.add(hit); 88 bits.set(((JahiaSearchHit)hit).id); 89 hitcount++; 90 } 91 92 98 public Vector results(){ 99 if ( results == null ){ 100 results = new Vector (); 101 } 102 return results; 103 } 104 105 111 public BitSet bits(){ 112 return bits; 113 } 114 115 121 public Collection parsedObjects(){ 122 if ( parsedObjects == null ){ 123 this.parsedObjects = new Vector (); 124 } 125 return this.parsedObjects; 126 } 127 128 133 public void setParsedObjects(Collection parsedObjects){ 134 this.parsedObjects = parsedObjects; 135 } 136 137 143 public int getHitCount(){ 144 return hitcount; 145 } 146 147 153 public Map getHitsByPage(){ 154 if ( this.hitsByPage == null ){ 155 this.hitsByPage = this.searchResultHandler.groupResultByPage(this); 156 if ( this.hitsByPage == null ){ 157 this.hitsByPage = new HashMap (); 158 } 159 } 160 return this.hitsByPage; 161 } 162 163 169 175 public Vector pages = new Vector (); 177 181 public int pagecount = 0; 182 } 183 | Popular Tags |