1 |
dpavlin |
9 |
/************************************************************************************************* |
2 |
|
|
* Java interface of Hyper Estraier |
3 |
|
|
* Copyright (C) 2004-2005 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; |
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* Abstraction of connection to P2P node. |
36 |
|
|
*/ |
37 |
|
|
public interface Node { |
38 |
|
|
//---------------------------------------------------------------- |
39 |
|
|
// public methods |
40 |
|
|
//---------------------------------------------------------------- |
41 |
|
|
/** |
42 |
|
|
* Get the status code of the last request. |
43 |
|
|
* @return the status code of the last request. |
44 |
|
|
*/ |
45 |
|
|
int status(); |
46 |
|
|
/** |
47 |
|
|
* Set the URL of a node server. |
48 |
|
|
* @param url the URL of a node server. |
49 |
|
|
*/ |
50 |
|
|
void set_url(String url); |
51 |
|
|
/** |
52 |
|
|
* Set the proxy information. |
53 |
|
|
* @param host the host name of a proxy server. |
54 |
|
|
* @param port the port number of the proxy server. |
55 |
|
|
*/ |
56 |
|
|
void set_proxy(String host, int port); |
57 |
|
|
/** |
58 |
|
|
* Set timeout. |
59 |
|
|
* @param msec timeout in seconds. |
60 |
|
|
*/ |
61 |
|
|
void set_timeout(int msec); |
62 |
|
|
/** |
63 |
|
|
* Set the authentication information. |
64 |
|
|
* @param name the name of authentication. |
65 |
|
|
* @param password the password of the authentication. |
66 |
|
|
*/ |
67 |
|
|
void set_auth(String name, String password); |
68 |
|
|
/** |
69 |
|
|
* Add a document. |
70 |
|
|
* @param doc a document object to register. |
71 |
|
|
* @return true if success, else it is false. |
72 |
|
|
*/ |
73 |
|
|
boolean put_doc(Document doc); |
74 |
|
|
/** |
75 |
|
|
* Remove a document. |
76 |
|
|
* @param id the ID number of a registered document. |
77 |
|
|
* @return true if success, else it is false. |
78 |
|
|
*/ |
79 |
|
|
boolean out_doc(int id); |
80 |
|
|
/** |
81 |
|
|
* Remove a document specified by URI. |
82 |
|
|
* @param uri the URI of a registered document. |
83 |
|
|
* @return true if success, else it is false. |
84 |
|
|
*/ |
85 |
|
|
boolean out_doc_by_uri(String uri); |
86 |
|
|
/** |
87 |
|
|
* Retrieve a document. |
88 |
|
|
* @param id the ID number of a registered document. |
89 |
|
|
* @return a document object. On error, null is returned. |
90 |
|
|
*/ |
91 |
|
|
Document get_doc(int id); |
92 |
|
|
/** |
93 |
|
|
* Retrieve a document specified by URI. |
94 |
|
|
* @param uri the URI of a registered document. |
95 |
|
|
* @return a document object. On error, null is returned. |
96 |
|
|
*/ |
97 |
|
|
Document get_doc_by_uri(String uri); |
98 |
|
|
/** |
99 |
|
|
* Retrieve the value of an attribute of a document. |
100 |
|
|
* @param id the ID number of a registered document. |
101 |
|
|
* @param name the name of an attribute. |
102 |
|
|
* @return the value of the attribute or null if it does not exist. |
103 |
|
|
*/ |
104 |
|
|
String get_doc_attr(int id, String name); |
105 |
|
|
/** |
106 |
|
|
* Retrieve the value of an attribute of a document specified by URI |
107 |
|
|
* @param uri the URI of a registered document. |
108 |
|
|
* @param name the name of an attribute. |
109 |
|
|
* @return the value of the attribute or null if it does not exist. |
110 |
|
|
*/ |
111 |
|
|
String get_doc_attr_by_uri(String uri, String name); |
112 |
|
|
/** |
113 |
|
|
* Get the ID of a document spacified by URI. |
114 |
|
|
* @param uri the URI of a registered document. |
115 |
|
|
* @return the ID of the document. On error, -1 is returned. |
116 |
|
|
*/ |
117 |
|
|
int uri_to_id(String uri); |
118 |
|
|
/** |
119 |
|
|
* Get the name. |
120 |
|
|
* @return the name. On error, null is returned. |
121 |
|
|
*/ |
122 |
|
|
String name(); |
123 |
|
|
/** |
124 |
|
|
* Get the label. |
125 |
|
|
* @return the label. On error, null is returned. |
126 |
|
|
*/ |
127 |
|
|
String label(); |
128 |
|
|
/** |
129 |
|
|
* Get the number of documents. |
130 |
|
|
* @return the number of documents. On error, -1 is returned. |
131 |
|
|
*/ |
132 |
|
|
int doc_num(); |
133 |
|
|
/** |
134 |
|
|
* Get the number of unique words. |
135 |
|
|
* @return the number of unique words. On error, -1 is returned. |
136 |
|
|
*/ |
137 |
|
|
int word_num(); |
138 |
|
|
/** |
139 |
|
|
* Get the size of the datbase of a node. |
140 |
|
|
* @return the size of the datbase of the node. On error, -1.0 is returned. |
141 |
|
|
*/ |
142 |
|
|
double size(); |
143 |
|
|
/** |
144 |
|
|
* Search documents corresponding a condition. |
145 |
|
|
* @param cond a condition object. |
146 |
|
|
* @param depth the depth of meta search. |
147 |
|
|
* @return a node result object. On error, null is returned. |
148 |
|
|
*/ |
149 |
|
|
NodeResult search(Condition cond, int depth); |
150 |
|
|
/** |
151 |
|
|
* Manage a user account. |
152 |
|
|
* @param name the name of a user. |
153 |
|
|
* @param mode the operation mode. 0 means to delete the account. 1 means to set the |
154 |
|
|
* account as an administrator. 2 means to set the account as a normal user. |
155 |
|
|
* @return true if success, else it is false. |
156 |
|
|
*/ |
157 |
|
|
boolean set_user(String name, int mode); |
158 |
|
|
/** |
159 |
|
|
* Manage a link. |
160 |
|
|
* @param url the URL of the target node of a link. |
161 |
|
|
* @param label the label of the link. |
162 |
|
|
* @param credit the credit of the link. If it is negative, the link is removed. |
163 |
|
|
* @return true if success, else it is false. |
164 |
|
|
*/ |
165 |
|
|
boolean set_link(String url, String label, int credit); |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
/* END OF FILE */ |