jess
Class ValueFactory

java.lang.Object
  extended by jess.ValueFactory
All Implemented Interfaces:
java.io.Serializable

public class ValueFactory
extends java.lang.Object
implements java.io.Serializable

A ValueFactory creates and possibly caches Value instances, and instances of its subclasses. Each Rete engine has its own ValueFactory. You can obtain a reference to a Rete object's ValueFactory and use it to create your own instances. Using the factory allows for large memory savings, especially when parsing a lot of redundant data. You can create a custom subclass to implement your own strategies. (C) 2013 Sandia Corporation

See Also:
Serialized Form

Constructor Summary
ValueFactory()
          Create a new ValueFactory.
 
Method Summary
 Value get(boolean v)
          Returns one of the contants Funcall.TRUE or Funcall.FALSE.
 Value get(double v, int type)
          Return a numeric Value object of the given type.
 Value get(int v)
          Returns a Value of type RU.INTEGER.
 Value get(int v, int type)
          Return a Value appropriate to the type argument.
 Value get(long v)
          Returns a LongValue representing the argument.
 Value get(java.lang.Object v)
          Return a new Value of type RU.JAVA_OBJECT.
 Value get(java.lang.String v, int type)
          Create a STRING, SYMBOL, VARIABLE or MULTIVARIABLE value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueFactory

public ValueFactory()
Create a new ValueFactory. Provided so that users might subclass this class; there's no reason to create your own ValueFactory objects otherwise.

See Also:
Rete.getValueFactory()
Method Detail

get

public Value get(java.lang.String v,
                 int type)
          throws JessException
Create a STRING, SYMBOL, VARIABLE or MULTIVARIABLE value.

Parameters:
v - the contents as a String
type - STRING, SYMBOL, VARIABLE or MULTIVARIABLE
Returns:
a new Value, or a previously cached one
Throws:
JessException - if anything goes wrong

get

public Value get(double v,
                 int type)
          throws JessException
Return a numeric Value object of the given type. Allowed types are RU.LONG, RU.INTEGER, and RU.FLOAT.

Parameters:
v - a numberic value
type - one of RU.INTEGER, RU.FLOAT, or RU.LONG
Returns:
a Value or LongValue containing the given value
Throws:
JessException

get

public Value get(int v,
                 int type)
          throws JessException
Return a Value appropriate to the type argument.

Parameters:
v - an integer
type - one of RU.INTEGER, RU.NONE
Returns:
a Value of the given type with the given value
Throws:
JessException

get

public Value get(int v)
          throws JessException
Returns a Value of type RU.INTEGER. You need to watch out for autoboxing; you'll get different results from an int vs. an Integer.

Parameters:
v - an int
Returns:
a Value of type RU.INTEGER
Throws:
JessException - if anything goes wrong

get

public Value get(long v)
          throws JessException
Returns a LongValue representing the argument.

Parameters:
v - a long value
Returns:
a LongValue object
Throws:
JessException - if anything goes wrong

get

public Value get(boolean v)
          throws JessException
Returns one of the contants Funcall.TRUE or Funcall.FALSE.

Parameters:
v - a boolean value
Returns:
Funcall.TRUE or Funcall.FALSE
Throws:
JessException - if anything goes wrong

get

public Value get(java.lang.Object v)
          throws JessException
Return a new Value of type RU.JAVA_OBJECT. If the argument is null, returns the constant Funcall.NIL.

Parameters:
v - any Java object
Returns:
a Value of type JAVA_OBJECT
Throws:
JessException - if anything goes wrong

2013 Sandia Corporation