unsw.cse.framescript
Class Instance

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Frame
          extended by unsw.cse.framescript.Instance
Direct Known Subclasses:
MobInstance, Script

public class Instance
extends Frame

This class implements instance frames in FrameScript.

Author:
mmcgill

Constructor Summary
Instance()
          Creates an unnamed instance frame.
Instance(Atom name)
          Creates a named instance frame.
 
Method Summary
 void addParent(Generic parent)
          Adds a parent to the frame.
 java.lang.String asText()
          Writes the frame as FrameScript.
 Term getSlot(Atom slot)
          Gets the value of a slot for the instance.
 void initFrame()
          Initialises the frame.
 Term putSlot(Atom slot, Term value)
          Puts a value into a slot in an instance frame.
 Term removeSlot(Atom slot)
          Removes a slot from the instance frame.
 Term removeSlot(Atom slot, Term value)
          Removes a specific value from a slot in an instance frame.
 Term replaceSlot(Atom slot, Term value)
          Replaces the value of a slot.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Frame
equals, eval
 
Methods inherited from class unsw.cse.framescript.Term
assign, asString, fullMatch, indents, mapVars, match
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Instance

public Instance()
Creates an unnamed instance frame.


Instance

public Instance(Atom name)
Creates a named instance frame.

Parameters:
name - the name of the frame
Method Detail

addParent

public void addParent(Generic parent)
               throws FSException
Adds a parent to the frame.

Parameters:
parent - the parent being added, this should either be a frame or the name of a frame
Throws:
FSException - if adding t as a parent would create an inheritance cycle

initFrame

public void initFrame()
               throws FSException
Description copied from class: Frame
Initialises the frame.

Overrides:
initFrame in class Frame
Throws:
FSException

getSlot

public Term getSlot(Atom slot)
             throws FSException
Gets the value of a slot for the instance.

Parameters:
slot - the name of the slot
Returns:
the value of the slot, null if the slot has no value
Throws:
FSException - if there is an error evaluating the slot's value

putSlot

public Term putSlot(Atom slot,
                    Term value)
             throws FSException
Puts a value into a slot in an instance frame.

Parameters:
slot - the name of the slot
value - the value to be put into the slot
Returns:
the result of the if_added daemon
Throws:
FSException - any errors putting into the slot

replaceSlot

public Term replaceSlot(Atom slot,
                        Term value)
                 throws FSException
Replaces the value of a slot.

Parameters:
slot - the name of the slot
value - the new value for the slot
Returns:
the result of running the if_replaced daemon
Throws:
FSException - any errors replacing the slot value

removeSlot

public Term removeSlot(Atom slot)
                throws FSException
Removes a slot from the instance frame.

Parameters:
slot - the name of the slot
Returns:
the result of running the if_removed daemon
Throws:
FSException - any errors removing the slot

removeSlot

public Term removeSlot(Atom slot,
                       Term value)
                throws FSException
Removes a specific value from a slot in an instance frame.

Parameters:
slot - the name of the slot
value - the value to be removed from the slot
Returns:
the value removed from the slot
Throws:
FSException

toString

public java.lang.String toString()
Description copied from class: Term
Turns the Term into a string.

Overrides:
toString in class Frame

asText

public java.lang.String asText()
Description copied from class: Frame
Writes the frame as FrameScript.

Specified by:
asText in class Frame
Returns:
a string that can hopefully be parsed to recreate the frame