server
Interface DAO<K,V>

Type Parameters:
K - The type of the key of the elements stored in the database.
V - The values stored in the database.
All Known Implementing Classes:
ConnectionHandlerThread, DaoImpl

public interface DAO<K,V>

The Data Object Interface (DAO) works as a layer between the application logic and the database.

Author:
Fernando

Field Summary
static int ADD
          Constant for the operation of adding a new element in the database.
static int DELETE
          Constant for the operation of deleting a new operation from the database.
static int GET
          The constant that denotes the operation of getting an element from the database.
static java.lang.String HOST
          The address of the host that we must use, whenever we are testing the client and server applications on the same machine.
static int PORT
          The port in which the server will be waiting for connections.
static int SIZE
          Constant for the operation of asking for the size of the database.
static int UPDATE
          Constant for the operation of putting a new element in the database.
 
Method Summary
 void add(K key, V value)
          Adds a new object into the database.
 void delete(K key)
          Removes an object from the database.
 V get(K key)
          Returns a value, given a key.
 int size()
          Informs the number of elements stored in the database.
 void update(K key, V value)
          Updates an object in the database.
 

Field Detail

GET

static final int GET
The constant that denotes the operation of getting an element from the database.

See Also:
Constant Field Values

ADD

static final int ADD
Constant for the operation of adding a new element in the database.

See Also:
Constant Field Values

DELETE

static final int DELETE
Constant for the operation of deleting a new operation from the database.

See Also:
Constant Field Values

UPDATE

static final int UPDATE
Constant for the operation of putting a new element in the database.

See Also:
Constant Field Values

SIZE

static final int SIZE
Constant for the operation of asking for the size of the database.

See Also:
Constant Field Values

PORT

static final int PORT
The port in which the server will be waiting for connections.

See Also:
Constant Field Values

HOST

static final java.lang.String HOST
The address of the host that we must use, whenever we are testing the client and server applications on the same machine.

See Also:
Constant Field Values
Method Detail

get

V get(K key)
Returns a value, given a key.

Parameters:
key - the id of the object that must be found.
Returns:
V the value associated with the key K.

add

void add(K key,
         V value)
Adds a new object into the database.

Parameters:
key - the id of the object that will be inserted into the database.
value - the value associated with the key K.

delete

void delete(K key)
Removes an object from the database.

Parameters:
key - the id of the object that will be removed.

update

void update(K key,
            V value)
Updates an object in the database.

Parameters:
key - the id of the object that will be replaced.
value - the new value of the object associated with the given key.

size

int size()
Informs the number of elements stored in the database.

Returns:
an integer number that tells how many objects are currently stored in the database.