jess
Class HashCodeComputer

java.lang.Object
  extended by jess.HashCodeComputer

public class HashCodeComputer
extends java.lang.Object

The HashCodeComputer allows hash code values for objects to be computed depending on their status as instances of "value" or "non-value" classes.

See Also:

(C) 2013 Sandia Corporation


Constructor Summary
HashCodeComputer()
           
 
Method Summary
static int hashCode(java.lang.Object o)
          Return a hashCode value for an object.
static boolean isValueObject(java.lang.Object o)
          Report whether or not Jess considers an object to be a "value object." As far as Jess is concerned, an object can be considered a "value object" if the return value of its hashCode() method will never change during the time Jess is working with the object.
static void setIsValueClass(Rete engine, java.lang.String name, boolean status)
          Record whether the class by the given name is a value object class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashCodeComputer

public HashCodeComputer()
Method Detail

hashCode

public static int hashCode(java.lang.Object o)
Return a hashCode value for an object. If the argument is a "value object", the object's hashCode() is called. If the argument is not, then a constant value is returned. This effectively means that hashing on non-value objects degenerates to linear search.

Parameters:
o - the object
Returns:
a constant hashcode for the object
See Also:
isValueObject(Object)

isValueObject

public static boolean isValueObject(java.lang.Object o)
Report whether or not Jess considers an object to be a "value object." As far as Jess is concerned, an object can be considered a "value object" if the return value of its hashCode() method will never change during the time Jess is working with the object. By default, Map and Collection instances are known to be non-value objects, while all others are assumed to be value objects.

Parameters:
o - the object
Returns:
true if the object is a value object
See Also:
setIsValueClass(Rete, String, boolean)

setIsValueClass

public static void setIsValueClass(Rete engine,
                                   java.lang.String name,
                                   boolean status)
                            throws java.lang.ClassNotFoundException
Record whether the class by the given name is a value object class. Jess assumes all classes are value classes by default except for Maps and Collections. It's important that you tell Jess when a class is not a value object class; failure to do so can cause corruption of working memory and undefined results.

Parameters:
engine - the rule engine used to resolve the class name
name - the name of a class
status - true if class is a value class
Throws:
java.lang.ClassNotFoundException - if there's no class by this name

2013 Sandia Corporation