estraier.pure
Class Node

java.lang.Object
  extended by estraier.pure.Node

public class Node
extends java.lang.Object

Abstraction of connection to P2P node.


Constructor Summary
Node()
          Create a node connection object.
 
Method Summary
 java.util.List admins()
          Get a list of names of administrators.
 double cache_usage()
          Get the usage ratio of the cache.
 int doc_num()
          Get the number of documents.
 boolean edit_doc(Document doc)
          Edit attributes of a document.
 java.util.Map etch_doc_by_uri(java.lang.String uri)
          Extract keywords of a document specified by URI.
 java.util.Map etch_doc(int id)
          Extract keywords of a document.
 java.lang.String get_doc_attr_by_uri(java.lang.String uri, java.lang.String name)
          Retrieve the value of an attribute of a document specified by URI
 java.lang.String get_doc_attr(int id, java.lang.String name)
          Retrieve the value of an attribute of a document.
 Document get_doc_by_uri(java.lang.String uri)
          Retrieve a document specified by URI.
 Document get_doc(int id)
          Retrieve a document.
 java.lang.String label()
          Get the label.
 java.util.List links()
          Get a list of expressions of links.
 java.lang.String name()
          Get the name.
 boolean optimize()
          Optimize the database.
 boolean out_doc_by_uri(java.lang.String uri)
          Remove a document specified by URI.
 boolean out_doc(int id)
          Remove a document.
 boolean put_doc(Document doc)
          Add a document.
 NodeResult search(Condition cond, int depth)
          Search for documents corresponding a condition.
 void set_auth(java.lang.String name, java.lang.String password)
          Set the authentication information.
 boolean set_link(java.lang.String url, java.lang.String label, int credit)
          Manage a link.
 void set_proxy(java.lang.String host, int port)
          Set the proxy information.
 void set_snippet_width(int wwidth, int hwidth, int awidth)
          Set width of snippet in the result.
 void set_timeout(int sec)
          Set timeout.
 void set_url(java.lang.String url)
          Set the URL of a node server.
 boolean set_user(java.lang.String name, int mode)
          Manage a user account.
 double size()
          Get the size of the datbase.
 int status()
          Get the status code of the last request.
 boolean sync()
          Synchronize updating contents of the database.
 int uri_to_id(java.lang.String uri)
          Get the ID of a document specified by URI.
 java.util.List users()
          Get a list of names of users.
 int word_num()
          Get the number of unique words.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node()
Create a node connection object.

Method Detail

admins

public java.util.List admins()
Get a list of names of administrators.

Returns:
a list object of names of administrators. On error, `null' is returned.

cache_usage

public double cache_usage()
Get the usage ratio of the cache.

Returns:
the usage ratio of the cache. On error, -1.0 is returned.

doc_num

public int doc_num()
Get the number of documents.

Returns:
the number of documents. On error, -1 is returned.

edit_doc

public boolean edit_doc(Document doc)
Edit attributes of a document.

Parameters:
doc - a document object.
Returns:
true if success, else it is false.

etch_doc_by_uri

public java.util.Map etch_doc_by_uri(java.lang.String uri)
Extract keywords of a document specified by URI.

Parameters:
uri - the URI of a registered document.
Returns:
a map object of keywords and their scores in decimal string or `null' on error.

etch_doc

public java.util.Map etch_doc(int id)
Extract keywords of a document.

Parameters:
id - the ID number of a registered document.
Returns:
a map object of keywords and their scores in decimal string or `null' on error.

get_doc_attr_by_uri

public java.lang.String get_doc_attr_by_uri(java.lang.String uri,
                                            java.lang.String name)
Retrieve the value of an attribute of a document specified by URI

Parameters:
uri - the URI of a registered document.
name - the name of an attribute.
Returns:
the value of the attribute or `null' if it does not exist.

get_doc_attr

public java.lang.String get_doc_attr(int id,
                                     java.lang.String name)
Retrieve the value of an attribute of a document.

Parameters:
id - the ID number of a registered document.
name - the name of an attribute.
Returns:
the value of the attribute or `null' if it does not exist.

get_doc_by_uri

public Document get_doc_by_uri(java.lang.String uri)
Retrieve a document specified by URI.

Parameters:
uri - the URI of a registered document.
Returns:
a document object. On error, `null' is returned.

get_doc

public Document get_doc(int id)
Retrieve a document.

Parameters:
id - the ID number of a registered document.
Returns:
a document object. On error, `null' is returned.

label

public java.lang.String label()
Get the label.

Returns:
the label. On error, `null' is returned.

links

public java.util.List links()
Get a list of expressions of links.

Returns:
a list object of expressions of links. Each element is a TSV string and has three fields of the URL, the label, and the score. On error, `null' is returned.

name

public java.lang.String name()
Get the name.

Returns:
the name. On error, `null' is returned.

optimize

public boolean optimize()
Optimize the database.

Returns:
true if success, else it is false.

out_doc_by_uri

public boolean out_doc_by_uri(java.lang.String uri)
Remove a document specified by URI.

Parameters:
uri - the URI of a registered document.
Returns:
true if success, else it is false.

out_doc

public boolean out_doc(int id)
Remove a document.

Parameters:
id - the ID number of a registered document.
Returns:
true if success, else it is false.

put_doc

public boolean put_doc(Document doc)
Add a document.

Parameters:
doc - a document object to register.
Returns:
true if success, else it is false.

search

public NodeResult search(Condition cond,
                         int depth)
Search for documents corresponding a condition.

Parameters:
cond - a condition object.
depth - the depth of meta search.
Returns:
a node result object. On error, `null' is returned.

set_auth

public void set_auth(java.lang.String name,
                     java.lang.String password)
Set the authentication information.

Parameters:
name - the name of authentication.
password - the password of the authentication.

set_link

public boolean set_link(java.lang.String url,
                        java.lang.String label,
                        int credit)
Manage a link.

Parameters:
url - the URL of the target node of a link.
label - the label of the link.
credit - the credit of the link. If it is negative, the link is removed.
Returns:
true if success, else it is false.

set_proxy

public void set_proxy(java.lang.String host,
                      int port)
Set the proxy information.

Parameters:
host - the host name of a proxy server.
port - the port number of the proxy server.

set_snippet_width

public void set_snippet_width(int wwidth,
                              int hwidth,
                              int awidth)
Set width of snippet in the result.

Parameters:
wwidth - whole width of a snippet. By default, it is 480. If it is 0, no snippet is sent. If it is negative, whole body text is sent instead of snippet.
hwidth - width of strings picked up from the beginning of the text. By default, it is 96. If it is negative 0, the current setting is not changed.
awidth - width of strings picked up around each highlighted word. By default, it is 96. If it is negative, the current setting is not changed.

set_timeout

public void set_timeout(int sec)
Set timeout.

Parameters:
sec - timeout in seconds.

set_url

public void set_url(java.lang.String url)
Set the URL of a node server.

Parameters:
url - the URL of a node server.

set_user

public boolean set_user(java.lang.String name,
                        int mode)
Manage a user account.

Parameters:
name - the name of a user.
mode - the operation mode. 0 means to delete the account. 1 means to set the account as an administrator. 2 means to set the account as a guest.
Returns:
true if success, else it is false.

size

public double size()
Get the size of the datbase.

Returns:
the size of the datbase. On error, -1.0 is returned.

status

public int status()
Get the status code of the last request.

Returns:
the status code of the last request. -1 means failure of connection.

sync

public boolean sync()
Synchronize updating contents of the database.

Returns:
true if success, else it is false.

uri_to_id

public int uri_to_id(java.lang.String uri)
Get the ID of a document specified by URI.

Parameters:
uri - the URI of a registered document.
Returns:
the ID of the document. On error, -1 is returned.

users

public java.util.List users()
Get a list of names of users.

Returns:
a list object of names of users. On error, `null' is returned.

word_num

public int word_num()
Get the number of unique words.

Returns:
the number of unique words. On error, -1 is returned.