vscript.interpreter
Class TagInterpreter

java.lang.Object
  |
  +--vscript.interpreter.TagInterpreter

public abstract class TagInterpreter
extends java.lang.Object

The TagInterpreter object interprets the tag.
It creates the object corresponding to the TAG.
It also constructs the message tree transparent to the user.
TagInterpreter contains a number of helper methods that help in interpreting the tag.
Most of the interpreters have to override only the interpretObject method to create an suitable interpreter.


Constructor Summary
TagInterpreter()
           
 
Method Summary
protected  void addComponent(javax.swing.JComponent comp, javax.swing.JPanel currentObject, vscript.GUI.ScreenPos pos, java.lang.String name)
          Metod called if the interpreted child object is a Component and the interpreted object is a Container.
This method is to be overridden by Interpreters that interpret Container objects with different behaviour.Default behaviour sets the Layout of the container to PercentLayout if it is not PercentLayout.
If the tag does not contain the pos attribute the component is not added.
 java.awt.Image getImage(java.lang.String baseStr, java.lang.String imgStr)
          The methods helps interpreters to load images.
If the baseStr is null then the imgStr is treated as representing a absolute URL.
If imgStr is not an absolute URL then the methods tries to load the image from the code base.
protected  java.util.List getSubTagList()
          Any interpreter that wants to control which subtags it can allow must override this method.Method that returns a list containing list of subtags that are to be processed.
static void handleMessageGUI(javax.swing.JComponent comp, vscript.message.Message message)
          Helper methods that handles messages to be understood by all GUI components.
 java.lang.Object interpret(vscript.Tag tag, vscript.message.MessageNode parent, int workingLevel)
          Interprets the Tag and returns the interpreted object.
Working level is the level at which the interpreter is working.
protected abstract  java.lang.Object interpretObject(vscript.Tag tag)
          For subclasses to override.
protected  boolean nameReqd()
          To check if the tag requires an identifier or not.By default true is returned.If a tag does not have a identifier return false.
static void processAttributes(java.awt.Component comp, vscript.Tag tag)
          Process bcolor,fcolor,border,enable,disable attributes.
static void processAttributes(java.awt.Component comp, vscript.Tag tag, boolean color, boolean enabled, boolean visible, boolean border)
          Process bcolor,fcolor,border,enable,disable attributes.
static void processBColor(java.awt.Component comp, java.lang.String arg)
          Helper method that helps to handle bcolor attribute.If arg is null then default color form VSRHelper is taken.
static void processBorder(java.awt.Component comp, java.lang.String arg)
          Helper method that helps to handle border attribute.If arg is null then default border form VSRHelper is taken.
static void processEnabled(java.awt.Component comp, java.lang.String arg)
          Helper method that helps to handle Enabled attribute.
static void processFColor(java.awt.Component comp, java.lang.String arg)
          Helper method that helps to handle fcolor attribute.If arg is null then default color form VSRHelper is taken.
protected  void processObject(java.lang.Object object)
          Method should be overridden by interpreters to do some processing on child objects like adding as listeners..ect.
static void processVisible(java.awt.Component comp, java.lang.String arg)
          Helper method that helps to handle Visible attribute.
static void setBorder(javax.swing.JComponent comp, java.lang.String borderStr)
          This method is a helper method that helps to set border around passes component based on the number passed as a string object.
protected  void setInterpretOrder(java.util.List list)
          Called to change the order of interpretation if required.
 boolean validLevel(int level)
          This method should be overridden by interpreters to indiciate if it is valid for the interpreter to work at a perticular level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagInterpreter

public TagInterpreter()
Method Detail

interpret

public java.lang.Object interpret(vscript.Tag tag,
                                  vscript.message.MessageNode parent,
                                  int workingLevel)
Interprets the Tag and returns the interpreted object.
Working level is the level at which the interpreter is working.

Parameters:
tag - The tag to be interpreted.
parent - The parent message node.
workingLevel - The working level of the interpreter.

getSubTagList

protected java.util.List getSubTagList()
Any interpreter that wants to control which subtags it can allow must override this method.Method that returns a list containing list of subtags that are to be processed. If a list is returned then all tags other than those in the list are considered as tag data. If null is returned all subtags are processed.Default implementation returns null.


nameReqd

protected boolean nameReqd()
To check if the tag requires an identifier or not.By default true is returned.If a tag does not have a identifier return false.


processObject

protected void processObject(java.lang.Object object)
Method should be overridden by interpreters to do some processing on child objects like adding as listeners..ect.

Parameters:
object - The child object created after interpreting the subtags if any.

addComponent

protected void addComponent(javax.swing.JComponent comp,
                            javax.swing.JPanel currentObject,
                            vscript.GUI.ScreenPos pos,
                            java.lang.String name)
Metod called if the interpreted child object is a Component and the interpreted object is a Container.
This method is to be overridden by Interpreters that interpret Container objects with different behaviour.Default behaviour sets the Layout of the container to PercentLayout if it is not PercentLayout.
If the tag does not contain the pos attribute the component is not added.

Parameters:
comp - Component to be added.
currentObject - The container to which the component will be added.
pos - The ScreenPos object created based on the pos attribute.
name - The name of the component as specified in the tag identifier.

interpretObject

protected abstract java.lang.Object interpretObject(vscript.Tag tag)
For subclasses to override. Should interpret the tag and return the interpreted obect.If there is an error and Tag cannot be interpreted return null.

Parameters:
tag - The tag to interpret.

setInterpretOrder

protected void setInterpretOrder(java.util.List list)
Called to change the order of interpretation if required. The tags in the list have to be arranged in the order in which they are to be interpreted.

Parameters:
list - The list of tag tag objects.

validLevel

public boolean validLevel(int level)
This method should be overridden by interpreters to indiciate if it is valid for the interpreter to work at a perticular level. If the level is valid the method should return true else false.

Parameters:
level - The level at which the interpreter is working.

getImage

public java.awt.Image getImage(java.lang.String baseStr,
                               java.lang.String imgStr)
The methods helps interpreters to load images.
If the baseStr is null then the imgStr is treated as representing a absolute URL.
If imgStr is not an absolute URL then the methods tries to load the image from the code base.

Parameters:
baseStr - String representing the base url.
imgStr - String representing the name of the image.

setBorder

public static void setBorder(javax.swing.JComponent comp,
                             java.lang.String borderStr)
This method is a helper method that helps to set border around passes component based on the number passed as a string object. Default value is '1' whichd does not result in any change to the border.


handleMessageGUI

public static void handleMessageGUI(javax.swing.JComponent comp,
                                    vscript.message.Message message)
Helper methods that handles messages to be understood by all GUI components.


processAttributes

public static void processAttributes(java.awt.Component comp,
                                     vscript.Tag tag)
Process bcolor,fcolor,border,enable,disable attributes.


processAttributes

public static void processAttributes(java.awt.Component comp,
                                     vscript.Tag tag,
                                     boolean color,
                                     boolean enabled,
                                     boolean visible,
                                     boolean border)
Process bcolor,fcolor,border,enable,disable attributes. If a perticular attribute is to be processed or not is determined based on the passed boolean value.


processBColor

public static void processBColor(java.awt.Component comp,
                                 java.lang.String arg)
Helper method that helps to handle bcolor attribute.If arg is null then default color form VSRHelper is taken.


processFColor

public static void processFColor(java.awt.Component comp,
                                 java.lang.String arg)
Helper method that helps to handle fcolor attribute.If arg is null then default color form VSRHelper is taken.


processBorder

public static void processBorder(java.awt.Component comp,
                                 java.lang.String arg)
Helper method that helps to handle border attribute.If arg is null then default border form VSRHelper is taken.


processVisible

public static void processVisible(java.awt.Component comp,
                                  java.lang.String arg)
Helper method that helps to handle Visible attribute.


processEnabled

public static void processEnabled(java.awt.Component comp,
                                  java.lang.String arg)
Helper method that helps to handle Enabled attribute.