edu.mit.sketch.system
Class Template

java.lang.Object
  |
  +--edu.mit.sketch.system.Template
All Implemented Interfaces:
Cloneable

public class Template
extends Object
implements Cloneable

A template defines the items and the properties/conditions that describe a new item. Some of the items and conditions are considered salient which means that they are more important than the others. The salient properties are usually filled in first before the system wastes time filling in less important slots.

Created: Thu Jan 3 11:23:22 2002
Copyright: Copyright (C) 2001 by MIT. All rights reserved.


Constructor Summary
Template(BBItemType type)
           
 
Method Summary
 void addComponent(String varName, BBItemType type, boolean isSalient)
          Add an object type to the template.
 void addConstraint(String varName, BBItemType constraintType, String[] argNames, Object value, boolean isSalient)
          Add a constraint on the objects that make up this template.
 void bind(String var, BBItem item)
          Bind the named pattern variable to the given item.
protected  Object clone()
          Copy this template.
 Template copy()
           
 BBItem getBBItem(String varName)
          Get the BBItem that is bound to varName.
 List getEmptySlotsFor(BBItemType type)
          Get the empty slots that can hold an item of the given type.
 Collection getSlots()
           
 BBItemType getType()
           
 void unbind(String var)
          Unbind the given pattern variable.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Template

public Template(BBItemType type)
Method Detail

getBBItem

public BBItem getBBItem(String varName)
Get the BBItem that is bound to varName. Or null, if there is no binding. It is an error to request the value for a variable not defined in this tempalte.

addComponent

public void addComponent(String varName,
                         BBItemType type,
                         boolean isSalient)
Add an object type to the template.
Parameters:
varName - The pattern variable to refer to the object within the template.
type - The type of object. This name should index into a lookup table which specifies the full java class name.
isSalient - Whether or not this item is a highly relevant feature in this template.

addConstraint

public void addConstraint(String varName,
                          BBItemType constraintType,
                          String[] argNames,
                          Object value,
                          boolean isSalient)
Add a constraint on the objects that make up this template. It takes the form of a predicate (as indacted by the property type), a list of arguments to the predicate, and the value that it evaluates to.
Parameters:
varName - name of this constraint
constraintType - a BBItemType that identifies the type of constraint
argNames - the names of the variables that this constraint refers to
value - the value of this constraint (boolean, realvalued
isSalient - whether or not this is a highly relevent constraint on the components.

bind

public void bind(String var,
                 BBItem item)
Bind the named pattern variable to the given item. If the binding leads to a consistent binding leave it and return true. Otherwise do not change the template and return false.

unbind

public void unbind(String var)
Unbind the given pattern variable.

copy

public Template copy()

clone

protected Object clone()
Copy this template.
Overrides:
clone in class Object

getEmptySlotsFor

public List getEmptySlotsFor(BBItemType type)
Get the empty slots that can hold an item of the given type.
Parameters:
type - a BBItemType
Returns:
a List of slot names

getSlots

public Collection getSlots()

getType

public BBItemType getType()