View Javadoc

1   /* Copyright (2006-2007) Schibsted Søk AS
2    * This file is part of SESAT.
3    *
4    *   SESAT is free software: you can redistribute it and/or modify
5    *   it under the terms of the GNU Affero General Public License as published by
6    *   the Free Software Foundation, either version 3 of the License, or
7    *   (at your option) any later version.
8    *
9    *   SESAT is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *   GNU Affero General Public License for more details.
13   *
14   *   You should have received a copy of the GNU Affero General Public License
15   *   along with SESAT.  If not, see <http://www.gnu.org/licenses/>.
16  
17   */
18  package no.sesat.search.view.output;
19  
20  import java.util.Iterator;
21  import no.sesat.search.datamodel.DataModel;
22  import no.sesat.search.result.ResultItem;
23  import no.sesat.search.result.handler.ResultHandler;
24  import org.apache.log4j.Logger;
25  
26  /** TODO rename to DebugOutputResultHandler
27   *
28   *
29   * @version <tt>$Id: TextOutputResultHandler.java 6596 2008-05-10 10:05:48Z ssmiweve $</tt>
30   */
31  public final class TextOutputResultHandler implements ResultHandler {
32  
33      private static final Logger LOG = Logger.getLogger(TextOutputResultHandler.class);;
34  
35      public void handleResult(final Context cxt, final DataModel datamodel) {
36          LOG.info("--- --- --- ---");
37  
38          for (ResultItem basicSearchResultItem : cxt.getSearchResult().getResults()) {
39  
40              for (String name : basicSearchResultItem.getFieldNames()) {
41                  LOG.info(name + " => " + basicSearchResultItem.getField(name));
42              }
43  
44              LOG.info("--- --- --- ---");
45          }
46      }
47  }