com.haley.haleyrules
Interface TemplateAssertion

All Superinterfaces:
Assertion, KnowledgeBaseObject, WorkingMemoryObject

public interface TemplateAssertion
extends Assertion

The TemplateAssertion interface publishes the API to assert a fact for an Eclipse template, i.e., a representation declared with "deftemplate", whereas the RelationAssertion interface publishes the API to assert facts for an Eclipse relation, i.e., a representation declared with "defrelation".

After obtaining the template from a knowledge base, e.g, KnowledgeBase.findTemplate(String), an application may begin the process of asserting a fact into a working memory with a call to Template.beginAssertion(WorkingMemory). An application can assign values to the fields via the methods published by this interface. Once all the desired fields have been initialized, a fact is created with a call to Assertion.assertFact(). Any values that are not specified default a value defined by template itself. Also, since the assertion is a KnowledgeBaseObject, it needs to be released.

 TemplateAssertion assertion = null;
 try {
    assertion = template.beginAssertion(wm);
    ...
    assertion.assign(field,"John Doe");
    ...
    assertion.assertFact();
 } catch (Exception e) {
    ...
 } finally {
    if (assertion != null)
      assertion.release();
 }
 

Author:
The Haley Enterprise Copyright © 1998-2004, all rights reserved. Questions, comments or to report a problem contact support@haley.com

Method Summary
 void assign(TemplateField field, boolean value)
          Assign the specified boolean to the specified field.
 void assign(TemplateField field, double value)
          Assign the specified number to the specified field.
 void assign(TemplateField field, long value)
          Assign the specified number to the specified field.
 void assign(TemplateField field, java.lang.String value)
          Assign the specified string to the specified field.
 void assignAsDate(TemplateField field, java.util.Date value)
          Assign the specified date to the specified field without a time component.
 void assignAsDate(TemplateField field, int year, int month, int day)
          Assign year/month/day as a date in the specified field without a time component.
 void assignAsDate(TemplateField field, java.lang.String dateString, java.lang.String format)
          Assign a date specified by converting the dateString to a date based upon the format to the specified field.
 void assignAsObject(TemplateField field, java.lang.Object object)
          Assign the specified object to the specified field.
 void assignAsTime(TemplateField field, java.util.Date value)
          Assign the specified date as a specific point in time.
 void assignAsTime(TemplateField field, long seconds)
          Assign a time specified as the number of seconds (not milliseconds) since 00:00:00 Jan 1, 1970 to the specified field.
 void assignAsTime(TemplateField field, java.lang.String timeString, java.lang.String format)
          Assign a time specified by converting the timeString to a time based upon the format to the specified field.
 void assignAsUnsigned(TemplateField field, long value)
          Assign the specified long to the specified field.
 void assignDefault(TemplateField field)
          Assigns the default value for the specified field.
 
Methods inherited from interface com.haley.haleyrules.Assertion
assertFact, reset
 
Methods inherited from interface com.haley.haleyrules.WorkingMemoryObject
getWorkingMemory
 
Methods inherited from interface com.haley.haleyrules.KnowledgeBaseObject
getKnowledgeBase, release
 

Method Detail

assign

public void assign(TemplateField field,
                   boolean value)
            throws EclipseException
Assign the specified boolean to the specified field. The boolean "true" becomes the Eclipse element 1 and the boolean "false" becomes the Eclipse element 0.

Parameters:
field - the template field to which to assign
value - the boolean value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assign

public void assign(TemplateField field,
                   double value)
            throws EclipseException
Assign the specified number to the specified field.

Parameters:
field - the template field to which to assign
value - the double value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assign

public void assign(TemplateField field,
                   long value)
            throws EclipseException
Assign the specified number to the specified field.

Parameters:
field - the template field to which to assign
value - the long value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsUnsigned

public void assignAsUnsigned(TemplateField field,
                             long value)
                      throws EclipseException
Assign the specified long to the specified field.

Parameters:
field - the template field to which to assign
value - the long value to assign
Throws:
EclipseException - if the specified number is negative
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assign

public void assign(TemplateField field,
                   java.lang.String value)
            throws EclipseException
Assign the specified string to the specified field. Use assignAsObject(TemplateField,Object) if you want the string to be assigned as an object rather than an Eclipse symbol.

Parameters:
field - the template field to which to assign
value - the string value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsDate

public void assignAsDate(TemplateField field,
                         java.util.Date value)
                  throws EclipseException
Assign the specified date to the specified field without a time component. Use assignAsTime(TemplateField,Date) if you want the date to be asserted as an Eclipse point in time rather than an Eclipse date. Use assignAsObject(TemplateField,Object) if you want the date to be asserted as an object rather than an Eclipse date.

Parameters:
field - the template field to which to assign
value - the date value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsDate

public void assignAsDate(TemplateField field,
                         int year,
                         int month,
                         int day)
                  throws EclipseException
Assign year/month/day as a date in the specified field without a time component.

Parameters:
field - the template field to which to assign
year - the four digit year e.g., 2001
month - the month 1=January, ..., 12=December
day - the day of the month 1 through 31
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsDate

public void assignAsDate(TemplateField field,
                         java.lang.String dateString,
                         java.lang.String format)
                  throws EclipseException
Assign a date specified by converting the dateString to a date based upon the format to the specified field.

Parameters:
field - the template field to which to assign
dateString - the string representation of a date
format - the format of the dateString
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsTime

public void assignAsTime(TemplateField field,
                         java.util.Date value)
                  throws EclipseException
Assign the specified date as a specific point in time.

Parameters:
field - the template field to which to assign
value - the date value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsTime

public void assignAsTime(TemplateField field,
                         long seconds)
                  throws EclipseException
Assign a time specified as the number of seconds (not milliseconds) since 00:00:00 Jan 1, 1970 to the specified field.

Parameters:
field - the template field in which to store the time value.
seconds - the number of seconds (not milliseconds) since 00:00:00 Jan 1, 1970
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsTime

public void assignAsTime(TemplateField field,
                         java.lang.String timeString,
                         java.lang.String format)
                  throws EclipseException
Assign a time specified by converting the timeString to a time based upon the format to the specified field.

Parameters:
field - the template field in which to store the time value
timeString - the string representation of a time
format - the format of the timeString
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignAsObject

public void assignAsObject(TemplateField field,
                           java.lang.Object object)
                    throws EclipseException
Assign the specified object to the specified field.
Note: even if object is a String or a Date, it is asserted as an object, not as a symbol, date, or time element.

Parameters:
field - the template field to which to assign "l"
object - the object value to assign
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted

assignDefault

public void assignDefault(TemplateField field)
                   throws EclipseException
Assigns the default value for the specified field.

Parameters:
field -
Throws:
EclipseException - if the assertion has been released
EclipseException - if the field does not belong to the template being asserted
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been cleared
EclipseException - if the knowledge base has been deleted
EclipseException - if the working memory has been deleted


Copyright © 1998-2006 Haley Systems, Inc. All Rights Reserved.