nenok.net.registry
Class RemoteKB

java.lang.Object
  extended by nenok.Knowledgebase
      extended by nenok.net.registry.RemoteKB
All Implemented Interfaces:
Serializable, Iterable<Locator>

public class RemoteKB
extends Knowledgebase
implements Serializable, Iterable<Locator>

A knowledgebase is basically a set of Locator objects. Because each locator identifies unambigously a valuation object stored on a Nenok processor, this represents indeed the mathematical idea of a distributed knowledgebase.

Knowledgebases contain only elements of the same type. However, because Locator objects are only pointer on the storage place (processor) of a valuation, this type checking cannot be done at compile-time. So, the first added element determines which type this knowledgebase accepts. If this constraint is not satisfied, an IllegalArgumentException is thrown.

Version:
$LastChangedRevision: 556 $
$LastChangedDate: 2008-03-26 14:21:45 +0100 (Mi, 26 Mrz 2008) $
Author:
Marc Pouly
See Also:
Serialized Form

Constructor Summary
  RemoteKB(Locator[] locators, String name)
          Constructor:
protected RemoteKB(String name)
          Constructor:
 
Method Summary
 boolean add(Locator loc)
          Adds a new locator to this knowledgebase.
 boolean addAll(Collection<Locator> locators)
          Adds a new collection of locators to this knowledgebase.
 boolean addAll(Locator[] locators)
          Adds a new array of locators to this knowledgebase.
 boolean contains(Locator loc)
          Looks for a given locator within this knowledgebase.
 Domain getDomain()
           
 Predictor getPredictor()
           
 Class getType()
          Loads dynamically the class type of the valuations referenced by this knowledgebase.
 Valuation[] getValuations()
           
 Iterator<Locator> iterator()
           
 boolean remove(Locator loc)
          Removes a given locator from this knowledgebase.
 int size()
           
 Locator[] toArray()
           
 
Methods inherited from class nenok.Knowledgebase
create, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteKB

protected RemoteKB(String name)
Constructor:

Parameters:
name - The knowledgebase's name.

RemoteKB

public RemoteKB(Locator[] locators,
                String name)
Constructor:

Parameters:
name - The knowledgebase's name.
locators - The locators to add to the new knowledgebase.
Method Detail

add

public boolean add(Locator loc)
Adds a new locator to this knowledgebase.

Parameters:
loc - The locator to add.
Returns:
true, it the locator has been added successfully.

addAll

public boolean addAll(Collection<Locator> locators)
Adds a new collection of locators to this knowledgebase.

Parameters:
locators - The locators to add.
Returns:
true, it all locators have been added successfully.

addAll

public boolean addAll(Locator[] locators)
Adds a new array of locators to this knowledgebase.

Parameters:
locators - The locators to add.
Returns:
true, it all locators have been added successfully.

remove

public boolean remove(Locator loc)
Removes a given locator from this knowledgebase.

Parameters:
loc - The locator to remove.
Returns:
true, if the locator has been removed successfully.

contains

public boolean contains(Locator loc)
Looks for a given locator within this knowledgebase.

Parameters:
loc - The locator to search.
Returns:
true, if the locator has been found.

size

public int size()
Specified by:
size in class Knowledgebase
Returns:
The size of this knowledgebase.
See Also:
Knowledgebase.size()

toArray

public Locator[] toArray()
Specified by:
toArray in class Knowledgebase
Returns:
The content of this knowledgebase as an array of transmissibles.
See Also:
Knowledgebase.toArray()

getValuations

public Valuation[] getValuations()
                          throws RemoteException
Specified by:
getValuations in class Knowledgebase
Returns:
The set of valuations that belong to this knowledgebase.
Throws:
RemoteException - Exception caused by communication problems if valuations are read from a remote processor.
See Also:
Knowledgebase.getValuations()

getPredictor

public Predictor getPredictor()
                       throws RemoteException
Returns:
The predictor of this knowledgebase of null, if it doesn't exist.
Throws:
RemoteException - This operation performs remote calls and therefore forewards RemoteExceptions.

iterator

public Iterator<Locator> iterator()
Specified by:
iterator in interface Iterable<Locator>
Returns:
The iterator for this knowledgebase.
See Also:
Iterable.iterator()

getDomain

public Domain getDomain()
Specified by:
getDomain in class Knowledgebase
Returns:
The total domain of this knowledgebase.
See Also:
Knowledgebase.getDomain()

getType

public Class getType()
              throws RemoteException
Loads dynamically the class type of the valuations referenced by this knowledgebase. Returns null, if this knowledgebase is empty.

Specified by:
getType in class Knowledgebase
Returns:
The type of valuations that is contained in this knowledgebase.
Throws:
RemoteException
See Also:
Knowledgebase.getType()