leafchat.core.api
Class MessageInfo.Variables

java.lang.Object
  extended by leafchat.core.api.MessageInfo.Variables
Enclosing class:
MessageInfo

public class MessageInfo.Variables
extends java.lang.Object

Class representing the list of available scripting variables


Constructor Summary
MessageInfo.Variables()
           
 
Method Summary
 void add(java.lang.String variable)
          Add a variable to the list.
 void add(java.lang.String variable, java.lang.Class<?> type, java.lang.String code)
          Adds a custom variable to the list.
 java.lang.String getDefinition(java.lang.String variable)
          Obtains the code needed to define a variable, for example: "String myVariable=msg.getMyVariable();"
 java.lang.String[] getNames()
           
 java.lang.Class<?> getType(java.lang.String variable)
          Obtains the type of a named variable.
 void remove(java.lang.String variable)
          Removes a variable from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageInfo.Variables

public MessageInfo.Variables()
Method Detail

add

public void add(java.lang.String variable)
Add a variable to the list. If the variable is called 'frog' then its type will be determined by the getFrog() method in the message, which will also be used to define the variable.

Parameters:
variable - Variable name
Throws:
BugException - If the method isn't properly defined

add

public void add(java.lang.String variable,
                java.lang.Class<?> type,
                java.lang.String code)
Adds a custom variable to the list.

Parameters:
variable - Variable name
type - Type (should be int.class or String.class)
code - Code to define variable, which can assume the existance of a msg variable of the message type, e.g. "int frog=msg.getFrog();"

getNames

public java.lang.String[] getNames()
Returns:
Sorted list of all variable names

getDefinition

public java.lang.String getDefinition(java.lang.String variable)
Obtains the code needed to define a variable, for example: "String myVariable=msg.getMyVariable();"

Parameters:
variable - Variable
Returns:
Code to define variable

getType

public java.lang.Class<?> getType(java.lang.String variable)
Obtains the type of a named variable. Default is to look for the get method (as per getVariableType) and check its return value.

Parameters:
variable - Variablename
Returns:
Type of variable (should be either int.class or String.class)
Throws:
BugException - If variable method does not exist or there's something wrong with it

remove

public void remove(java.lang.String variable)
Removes a variable from the list.

Parameters:
variable - Variable to remove


Copyright © 2011 Samuel Marshall. All rights reserved.