|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jess.Deftemplate
A Deftemplate defines a class of Jess facts. Its definition includes a list of properties or "slots", each of which can have a default value and a type. Deftemplates can be created by hand, but they usually come from executing the "deftemplate" construct or the "defclass" function in the Jess language. To build a useful template, you need to specify the name to the constructor, then add the named slots one by one:
Rete r = new Rete(); Deftemplate dt = new Deftemplate("point", "A 2D point", r); Value zero = new Value(0, RU.INTEGER); dt.addSlot("x", zero, "NUMBER"); dt.addSlot("y", zero, "NUMBER"); r.addDeftemplate(dt);(C) 2005 Sandia National Laboratories
Constructor Summary | |
Deftemplate(java.lang.String name,
java.lang.String docstring,
Deftemplate dt,
Rete engine)
Create a deftemplate 'derived from' another one. |
|
Deftemplate(java.lang.String name,
java.lang.String docstring,
Rete engine)
Create a template that extends the root template. |
Method Summary | |
java.lang.Object |
accept(Visitor v)
This class participates in the Visitor pattern. |
void |
addMultiSlot(java.lang.String name,
Value value)
Create a new multislot in this deftemplate. |
void |
addSlot(java.lang.String name,
Value value,
java.lang.String typename)
Create a new slot in this deftemplate. |
void |
doBackwardChaining(Rete engine)
Make this deftemplate backwards-chaining reactive. |
boolean |
equals(java.lang.Object o)
Compare this deftemplate to another one for equality. |
static Deftemplate |
getAccumTemplate()
The template for a special fact used internally by Jess. |
Deftemplate |
getBackchainingTemplate(Rete engine)
Return a new backward-chaining trigger template for this template. |
java.lang.String |
getBackchainingTemplateName()
Get the name of the backward chaining trigger template that would be associated with this template, whether it exists or not. |
boolean |
getBackwardChaining()
Get the backchaining reactivity of this deftemplate. |
java.lang.String |
getBaseName()
Get the name of this deftemplate unqualified by the module name. |
static Deftemplate |
getClearTemplate()
The template for a special fact used internally by Jess. |
java.lang.String |
getConstructType()
Return the String "deftemplate". |
java.lang.String |
getDocstring()
Get the docstring of this deftemplate. |
static Deftemplate |
getInitialTemplate()
The template for "initial-fact". |
java.lang.String |
getModule()
Return the name of the module this deftemplate is in. |
java.lang.String |
getName()
Get the name of this deftemplate. |
java.lang.String |
getNameWithoutBackchainingPrefix()
Return the undecorated template name. |
int |
getNSlots()
Return the number of slots in this deftemplate. |
static Deftemplate |
getNullTemplate()
The template for a special fact used internally by Jess. |
Deftemplate |
getParent()
Return the parent of this deftemplate. |
static Deftemplate |
getRootTemplate()
The root template that serves as the ultimate parent of all other templates. |
java.lang.String |
getShadowClassName()
If this is a template for shadow facts, return the Java class name. |
int |
getSlotDataType(int index)
Returns the slot data type (one of the constants in jess.RU) for the slot given by the zero-based index. |
Value |
getSlotDefault(int index)
Returns the default value of a slot given by the zero-based index. |
int |
getSlotIndex(java.lang.String slotname)
Return the index (0 through getNSlots()-1) of the named slot, or -1 if there is no such slot. |
java.lang.String |
getSlotName(int index)
Return the name of a given slot in this deftemplate. |
java.lang.String[] |
getSlotNames()
Return a new array containing the names of all the slots in this deftemplate. |
int |
getSlotType(int index)
Returns the slot type (RU.SLOT or RU.MULTISLOT) of the slot in this deftemplate given by the zero-based index. |
int |
getSlotType(java.lang.String name)
Returns the slot type (RU.SLOT or RU.MULTISLOT) of the slot in this deftemplate given by the zero-based index. |
static Deftemplate |
getSpecialTemplate(java.lang.String name)
Returns one of the special templates "test" or "initial-fact" by name. |
static Deftemplate |
getTestTemplate()
The template for a special fact used internally by Jess. |
int |
hashCode()
Return a hash code for this template. |
boolean |
isBackwardChainingTrigger()
Indicate whether this template is a backward chaining trigger. |
boolean |
isMultislot(int index)
Returns true if the slot at the given index is a multislot. |
boolean |
isOrdered()
Return true if this is an ordered template. |
boolean |
isShadowTemplate()
Return true if this is a template for shadow facts. |
boolean |
isSlotSpecific()
Query the slot-specific activation behavior for this template. |
static boolean |
isSpecialName(java.lang.String name)
Returns true if the argument is a special template name. |
void |
setSlotSpecific(boolean b)
Set the slot-specific activation behavior for this template. |
java.lang.String |
toString()
Turn this deftemplate into a String. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Deftemplate(java.lang.String name, java.lang.String docstring, Rete engine) throws JessException
name
- the deftemplate namedocstring
- the deftemplate's documentation stringengine
- the rule engine to create the template in
JessException
- if anything goes wrongpublic Deftemplate(java.lang.String name, java.lang.String docstring, Deftemplate dt, Rete engine) throws JessException
name
- the deftemplate namedocstring
- the deftemplate's documentation stringdt
- the 'parent' of this deftemplateengine
- the engine to create the template in
JessException
- if anything goes wrongMethod Detail |
public static Deftemplate getRootTemplate()
public static Deftemplate getInitialTemplate()
public static Deftemplate getClearTemplate()
public static Deftemplate getNullTemplate()
public static Deftemplate getTestTemplate()
public static Deftemplate getAccumTemplate()
public boolean equals(java.lang.Object o)
o
- another template to compare this this one
public int hashCode()
public Deftemplate getParent()
public final java.lang.String getName()
getName
in interface Named
public final java.lang.String getBaseName()
public final java.lang.String getDocstring()
getDocstring
in interface Named
public final void doBackwardChaining(Rete engine) throws JessException
engine
- the engine the new template is created in
JessException
- if anything goes wrongpublic final boolean getBackwardChaining()
public void addSlot(java.lang.String name, Value value, java.lang.String typename) throws JessException
name
- name of the slotvalue
- default value for the slottypename
- type of the slot: INTEGER, FLOAT, ANY, etc.
JessException
- If something goes wrongpublic void addMultiSlot(java.lang.String name, Value value) throws JessException
name
- name of the slotvalue
- default value for the slot
JessException
- if something goes wrongpublic int getSlotDataType(int index) throws JessException
index
- The zero-based index of the slot (0, 1, 2 ... getNSlots()-1)
JessException
- if anything goes wrongpublic Value getSlotDefault(int index) throws JessException
index
- The zero-based index of the slot (0, 1, 2 ... getNSlots()-1)
JessException
- if anything goes wrongpublic int getSlotType(int index) throws JessException
index
- The zero-based index of the slot (0, 1, 2 ... getNSlots()-1)
JessException
- if anything goes wrongpublic int getSlotType(java.lang.String name) throws JessException
name
- The name of the slot
JessException
- if anything goes wrongpublic boolean isMultislot(int index) throws JessException
index
- the index of the slot
JessException
- if the index is invalidpublic int getSlotIndex(java.lang.String slotname)
slotname
- The name of the slot
public java.lang.String getSlotName(int index) throws JessException
index
- The zero-based index of the slot (0, 1, 2 ... getNSlots()-1)
JessException
- If something is horribly wrongpublic java.lang.String[] getSlotNames()
public int getNSlots()
public java.lang.String toString()
public java.lang.Object accept(Visitor v)
accept
in interface Visitable
v
- a Visitor that is interested in working with this object
public java.lang.String getModule()
getModule
in interface Modular
public boolean isBackwardChainingTrigger()
public java.lang.String getBackchainingTemplateName()
public java.lang.String getNameWithoutBackchainingPrefix()
public Deftemplate getBackchainingTemplate(Rete engine) throws JessException
engine
- the engine containing the template
JessException
- if anything goes wrongpublic boolean isOrdered()
public void setSlotSpecific(boolean b)
b
- true if this template should use slot-specific behaviorpublic boolean isSlotSpecific()
public final java.lang.String getConstructType()
getConstructType
in interface Named
public java.lang.String getShadowClassName()
public boolean isShadowTemplate()
public static boolean isSpecialName(java.lang.String name)
name
- the name of a template
public static Deftemplate getSpecialTemplate(java.lang.String name)
name
- "test" or "initial-fact"
|
© 2006 Sandia Corporation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |