Interface IDataBaseAccess

All Known Implementing Classes:
Database

public interface IDataBaseAccess

The class implemting this interface will be used by the Caltella Name Server (CNS). It is designed as a layer of abstraction for access to any kind of database system, running behind the CNS.

Since the metaphor of the Domain Name Server is used, we implement bind(int, java.lang.String), unbind(int) and lookup(int).

See Also:
Caltella.org

Method Summary
 boolean bind(int id, String address)
          This binds the peers address to his id in the CNS, now he is marked as online.
 boolean checkPassword(int id, String password)
          This methode is used to check the peers identity.
 boolean connect()
          This methode connects the CNS to his DB.
 String getEmail(int id)
          Returns the email of the peer identified by id.
 String getFirstName(int id)
          Returns the first Name of the peer identified by id.
 String getImageURL(int id)
          Returns an URL to an image of the peer identified by id.
 String getLastName(int id)
          Returns the Last Name of the peer identified by id.
 String[] getSearchFields()
          This methode is used to get a list of searchable colums used for the search(java.lang.String, java.lang.String) method.
 boolean isOnline(int id)
          Returns true if the peer identified by id is online.
 String lookup(int id)
          Before we can send messages we need there address.
 int register(String firstName, String lastName, String email, String password, String Country, String url)
          The first time the user starts an Caltella client, we has to register.
 boolean removePeer(int id)
          If ever called, this methode would remove the peer from the DB.
 int[] search(String column, String searchString)
          Search the DB for one or more peers and return there ID's
 boolean setAllAtOnce(int id, String newFirstName, String newLastName, String newEmail, String newPassword, String newImageURL)
          This is mainly used to decrease network and DB load by sending all data at once.
 boolean setEmail(int id, String newEmail)
           
 boolean setFirstName(int id, String newFirstName)
           
 boolean setImageURL(int id, String newImageURL)
           
 boolean setLastName(int id, String newLastName)
           
 boolean setPassword(int id, String newPassword)
           
 boolean unbind(int id)
          This methode will change the peers status to offline.
 

Method Detail

connect

public boolean connect()
This methode connects the CNS to his DB.


register

public int register(String firstName,
                    String lastName,
                    String email,
                    String password,
                    String Country,
                    String url)
The first time the user starts an Caltella client, we has to register. This methode does just that.

Returns:
id The unice identification of the user. required for basicly all requests to the CNS.

removePeer

public boolean removePeer(int id)
If ever called, this methode would remove the peer from the DB.


bind

public boolean bind(int id,
                    String address)
This binds the peers address to his id in the CNS, now he is marked as online.

No password is needed since the other methodes don't need them ether.

Parameters:
id - The peers id number address A String of the form host:port we get host using the InetAddress.getLocalHost() methode.
Returns:
true if binding was successful
See Also:
InetAddress, unbind(int), lookup(int)

unbind

public boolean unbind(int id)
This methode will change the peers status to offline.

See Also:
unbind(int)

lookup

public String lookup(int id)
Before we can send messages we need there address. This methode those just that. You may use the search(java.lang.String, java.lang.String) methode to get the id.

Returns:
A String representing the address (in the form of host:port) of the peer
See Also:
bind(int, String)

setFirstName

public boolean setFirstName(int id,
                            String newFirstName)

setLastName

public boolean setLastName(int id,
                           String newLastName)

setEmail

public boolean setEmail(int id,
                        String newEmail)

setPassword

public boolean setPassword(int id,
                           String newPassword)

setImageURL

public boolean setImageURL(int id,
                           String newImageURL)

setAllAtOnce

public boolean setAllAtOnce(int id,
                            String newFirstName,
                            String newLastName,
                            String newEmail,
                            String newPassword,
                            String newImageURL)
This is mainly used to decrease network and DB load by sending all data at once.

Returns:
true if successful

getFirstName

public String getFirstName(int id)
Returns the first Name of the peer identified by id.


getLastName

public String getLastName(int id)
Returns the Last Name of the peer identified by id.


getEmail

public String getEmail(int id)
Returns the email of the peer identified by id.


getImageURL

public String getImageURL(int id)
Returns an URL to an image of the peer identified by id.


isOnline

public boolean isOnline(int id)
Returns true if the peer identified by id is online.


checkPassword

public boolean checkPassword(int id,
                             String password)
This methode is used to check the peers identity. It should be called before any write accsess to the DB.


search

public int[] search(String column,
                    String searchString)
Search the DB for one or more peers and return there ID's

Returns:
An array of id's of all peers matching the searchString in the specified colum.
See Also:
getSearchFields()

getSearchFields

public String[] getSearchFields()
This methode is used to get a list of searchable colums used for the search(java.lang.String, java.lang.String) method.

Returns:
An array of String representing the names of the colums where a search is possible.