net.sourceforge.fuzzyservices.beans
Class FactBase

java.lang.Object
  extended by net.sourceforge.fuzzyservices.beans.FactBase
All Implemented Interfaces:
VetoableChangeListener, Serializable, EventListener

public class FactBase
extends Object
implements VetoableChangeListener, Serializable

This class represents a fact base according to JavaBeans conventions.

Version:
1.0
Author:
Uwe Weng
See Also:
FactBase, Serialized Form

Field Summary
static String FACTS_PROPERTY
          Bound property name for facts.
static String NAME_PROPERTY
          Bound property name for name.
 
Constructor Summary
FactBase()
          Default FactBase constructor.
FactBase(String newName)
          Constructs a new fact base with given name.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 Object clone()
           
 boolean equals(Object obj)
           
 Fact[] getFacts()
          Returns all facts of this fact base.
 Fact getFacts(int index)
          Gets the fact located at the specified index of this fact base.
 int getId()
          Returns the technical identifier (e.g. within a database).
 String getName()
          Returns the name of this fact base.
 int hashCode()
           
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void setFacts(Fact[] newFacts)
          Fills the fact base with facts.
 void setFacts(int index, Fact newFacts)
          Replaces the fact at the position index of the fact base.
 void setName(String newName)
          Sets the name of this fact base.
 String toString()
           
 String toString(boolean withFacts)
          Returns a textual representation of the fact base
 void vetoableChange(PropertyChangeEvent evt)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME_PROPERTY

public static final String NAME_PROPERTY
Bound property name for name.

See Also:
Constant Field Values

FACTS_PROPERTY

public static final String FACTS_PROPERTY
Bound property name for facts.

See Also:
Constant Field Values
Constructor Detail

FactBase

public FactBase()
Default FactBase constructor.


FactBase

public FactBase(String newName)
Constructs a new fact base with given name.

Parameters:
newName - The new value for the property.
Method Detail

getId

public int getId()
Returns the technical identifier (e.g. within a database).

Returns:
the ID

getName

public String getName()
Returns the name of this fact base.

Returns:
the name property
See Also:
setName(java.lang.String)

getFacts

public Fact[] getFacts()
Returns all facts of this fact base.

Returns:
the facts property
See Also:
setFacts(Fact[])

getFacts

public Fact getFacts(int index)
Gets the fact located at the specified index of this fact base.

Parameters:
index - the position of the fact to be returned.
Returns:
the fact located at the specified index.
See Also:
setFacts(Fact[])

setName

public void setName(String newName)
Sets the name of this fact base.

Parameters:
newName - The new value for the property.
See Also:
getName()

setFacts

public void setFacts(Fact[] newFacts)
              throws IllegalArgumentException
Fills the fact base with facts.

Parameters:
newFacts - An array with facts.
Throws:
IllegalArgumentException - if a linguistic variable of a fact is not defined or if at least two facts relates to one linguistic variable
See Also:
getFacts()

setFacts

public void setFacts(int index,
                     Fact newFacts)
              throws IllegalArgumentException,
                     ArrayIndexOutOfBoundsException
Replaces the fact at the position index of the fact base.

Parameters:
index - The index value into the property array.
newFacts - The new fact for the fact base.
Throws:
ArrayIndexOutOfBoundsException - if index is an invalid position
IllegalArgumentException - if a linguistic variable of a fact is not defined or if at least two facts relates to one linguistic variable
See Also:
getFacts()

vetoableChange

public void vetoableChange(PropertyChangeEvent evt)
                    throws PropertyVetoException
Specified by:
vetoableChange in interface VetoableChangeListener
Throws:
PropertyVetoException

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired in response to setting a bound property.

Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - the PropertyChangeListener to be removed

clone

public Object clone()
Overrides:
clone in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(boolean withFacts)
Returns a textual representation of the fact base

Parameters:
withFacts - true if all fact definitions are also returned, false otherwise.
Returns:
a string representation of the fact base
See Also:
Fact.toString()


Copyright © 2007-2012 Fuzzy Services. All Rights Reserved.