nenok.net
Class Knowledgebase

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

public class Knowledgebase
extends Object
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:
1.2
Author:
Marc Pouly
See Also:
Serialized Form

Constructor Summary
Knowledgebase()
          Constructor:
Knowledgebase(Locator[] locators)
          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.
 Class getContentClass()
          Loads dynamically the class type of the valuations referenced by this knowledgebase.
 Domain getDomain()
           
 String getName()
           
 Predictor getPredictor()
           
 Iterator<Locator> iterator()
           
 boolean remove(Locator loc)
          Removes a given locator from this knowledgebase.
 void setName(String name)
          Sets the name of this knowledgebase.
 int size()
           
 Locator[] toArray()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Knowledgebase

public Knowledgebase()
Constructor:


Knowledgebase

public Knowledgebase(Locator[] locators)
Constructor:

Parameters:
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()
Returns:
The size of this knowledgebase.

toArray

public Locator[] toArray()
Returns:
The knowledgebase transformed into an array of locators.

setName

public void setName(String name)
Sets the name of this knowledgebase.

Parameters:
name - The name of the knoelwedgebase.

getName

public String getName()
Returns:
The name of this knowledgebase.

iterator

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

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

getDomain

public Domain getDomain()
Returns:
The union domain of all locators' domains within this knowledgebase.

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.

getContentClass

public Class getContentClass()
                      throws RemoteException
Loads dynamically the class type of the valuations referenced by this knowledgebase.

Returns:
The class of the valuations referenced by the locators within this knowledgebase. Returns null, if this knowledgebase is empty.
Throws:
RemoteException - This operation performs remote calls and therefore forewards RemoteExceptions.