1 /*************************************************************************************************
2  * Pure Java interface of Hyper Estraier
3  *                                                      Copyright (C) 2004-2007 Mikio Hirabayashi
4  *                                                                           All rights reserved.
5  * This file is part of Hyper Estraier.
6  * Redistribution and use in source and binary forms, with or without modification, are
7  * permitted provided that the following conditions are met:
8  *
9  *   * Redistributions of source code must retain the above copyright notice, this list of
10  *     conditions and the following disclaimer.
11  *   * Redistributions in binary form must reproduce the above copyright notice, this list of
12  *     conditions and the following disclaimer in the documentation and/or other materials
13  *     provided with the distribution.
14  *   * Neither the name of Mikio Hirabayashi nor the names of its contributors may be used to
15  *     endorse or promote products derived from this software without specific prior written
16  *     permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26  * OF THE POSSIBILITY OF SUCH DAMAGE.
27  *************************************************************************************************/
28 
29 
30 package estraier.pure;
31 
32 import java.util.*;
33 import java.io.*;
34 import java.net.*;
35 
36 
37 
38 /**
39  * Abstraction of result set from node.
40  */
41 public class NodeResult {
42   //----------------------------------------------------------------
43   // private fields
44   //----------------------------------------------------------------
45   private List docs;
46   private Map hints;
47   //----------------------------------------------------------------
48   // constructors
49   //----------------------------------------------------------------
50   /**
51    * Create a node result object.
52    * @param docs a list object of result document objects.
53    * @param hints a map object of hints.
54    */
NodeResult(List docs, Map hints)55   NodeResult(List docs, Map hints){
56     this.docs = docs;
57     this.hints = hints;
58   }
59   //----------------------------------------------------------------
60   // public methods
61   //----------------------------------------------------------------
62   /**
63    * Get the number of documents.
64    * @return the number of documents.
65    */
doc_num()66   public int doc_num(){
67     return docs.size();
68   }
69   /**
70    * Get a result document object
71    * @param index the index of a document.
72    * @return a result document object or `null' if the index is out of bounds.
73    */
get_doc(int index)74   public ResultDocument get_doc(int index){
75     try {
76       return (ResultDocument)docs.get(index);
77     } catch(IndexOutOfBoundsException e){
78       return null;
79     }
80   }
81   /**
82    * Get the value of hint information.
83    * @param key the key of a hint.  "VERSION", "NODE", "HIT", "HINT#n", "DOCNUM", "WORDNUM",
84    * "TIME", "TIME#n", "LINK#n", and "VIEW" are provided for keys.
85    * @return the value of the hint or `null' if the key does not exist.
86    */
hint(String key)87   public String hint(String key){
88     return (String)hints.get(key);
89   }
90 }
91 
92 
93 
94 /* END OF FILE */
95