Class FrameTemplate

java.lang.Object
  |
  +--FrameTemplate
All Implemented Interfaces:
FrameInterface, java.io.Serializable

public class FrameTemplate
extends java.lang.Object
implements FrameInterface, java.io.Serializable

The class `FrameTemplate' represents a frame template, which encodes how to convert a given Java (in particular, Jex) object to a frame.

See Also:
Serialized Form

Constructor Summary
FrameTemplate(FrameClass frameClass, java.lang.Class jClass, java.lang.String jId)
          Constructs this frame template.
 
Method Summary
static FrameTemplate find(java.lang.Class jClass)
          Finds a frame template that is appropriate to a given Java (Jex) object class.
 FrameClass getFrameClass()
          Returns the frame class of this frame template.
 java.lang.Object getSlotFiller(Slot slot)
          Returns the filler of a given slot.
 java.lang.Object getSlotFiller(java.lang.String slotName)
          Returns the filler of a given slot.
 java.util.ListIterator getSlots()
          Returns an iterator over the filled slots in this frame template, in the order that they were filled.
 void print(java.io.PrintStream ps)
          Prints the frame template in human-readable text form.
static void readClass(java.io.ObjectInput oi)
          Deserialises the static data members (class variables) of FrameTemplate.
 void setSlotFiller(Slot slot, java.lang.Object filler)
          Fills a given slot with a given value.
 void setSlotFiller(java.lang.String slotName, java.lang.Object filler)
          Fills a given slot with a given value.
 java.lang.String toString()
          Returns a string representing this frame template.
static void writeClass(java.io.ObjectOutput oo)
          Serialises the static data members (class variables) of FrameTemplate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameTemplate

public FrameTemplate(FrameClass frameClass,
                     java.lang.Class jClass,
                     java.lang.String jId)
Constructs this frame template.
Parameters:
frameClass - The frame class of the frame template to be constructed, which specifies the set of slots the frame template should have.
jClass - The Java class associated with this frame template.
jId - The name of the Java object identifier associated with this frame template.
Method Detail

find

public static FrameTemplate find(java.lang.Class jClass)
Finds a frame template that is appropriate to a given Java (Jex) object class.
Parameters:
jClass - The Java (Jex) class that you want to find a frame template to convert.
Returns:
A FrameTemplate for converting objects of type jClass to frames, or null if no suitable frame template exists.

getFrameClass

public FrameClass getFrameClass()
Returns the frame class of this frame template.
Specified by:
getFrameClass in interface FrameInterface
Returns:
The frame class of this frame template.

getSlotFiller

public java.lang.Object getSlotFiller(Slot slot)
Returns the filler of a given slot.
Specified by:
getSlotFiller in interface FrameInterface
Parameters:
slot - The slot whose filler you want to read.
Returns:
The filler of `slot', as held in this frame.

getSlotFiller

public java.lang.Object getSlotFiller(java.lang.String slotName)
                               throws InvalidSlot
Returns the filler of a given slot.
Specified by:
getSlotFiller in interface FrameInterface
Parameters:
slot - The name of the slot whose filler you want to read.
Returns:
The filler of the slot, as held in this frame.
Throws:
InvalidSlot - If the frame templatedoes not have a slot of that name (as specified in its frame class).

setSlotFiller

public void setSlotFiller(Slot slot,
                          java.lang.Object filler)
Fills a given slot with a given value. Records this slot as having been written directly.
Specified by:
setSlotFiller in interface FrameInterface
Parameters:
slot - The slot you want to write into.
filler - The filler (value) you want to write into `slot', which must be of the right type for `slot'.

setSlotFiller

public void setSlotFiller(java.lang.String slotName,
                          java.lang.Object filler)
                   throws InvalidSlot
Fills a given slot with a given value.
Specified by:
setSlotFiller in interface FrameInterface
Parameters:
slot - The name of the slot you want to write into.
filler - The filler (value) you want to write into the slot, which must be of the right type for the slot.
Throws:
InvalidSlot - If the frame template does not have that slot (as specified in its frame class).

getSlots

public java.util.ListIterator getSlots()
Returns an iterator over the filled slots in this frame template, in the order that they were filled. (If a slot was filled twice, its position in the iterator is determined by the first time it was filled.)
Specified by:
getSlots in interface FrameInterface
Returns:
An iterator over the filled slots in this frame template.

toString

public java.lang.String toString()
Returns a string representing this frame template. The format is frame-class (Java-class identifier).
Specified by:
toString in interface FrameInterface
Overrides:
toString in class java.lang.Object
Returns:
The string representation of this frame template.

print

public void print(java.io.PrintStream ps)
Prints the frame template in human-readable text form. Any references are just printed as they are.
Specified by:
print in interface FrameInterface
Parameters:
ps - A stream to print the frame template to.

writeClass

public static void writeClass(java.io.ObjectOutput oo)
                       throws java.io.IOException
Serialises the static data members (class variables) of FrameTemplate.
Parameters:
oo - An output stream to save the class data to.
Throws:
java.io.IOException - If an I/O exception occurs.

readClass

public static void readClass(java.io.ObjectInput oi)
                      throws java.io.IOException
Deserialises the static data members (class variables) of FrameTemplate.
Parameters:
oi - An input stream to save the class data to.
Throws:
java.io.IOException - If an I/O exception occurs.