leafchat.core.api
Class MessageInfo

java.lang.Object
  extended by leafchat.core.api.MessageInfo
All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>

public class MessageInfo
extends java.lang.Object
implements java.lang.Comparable<java.lang.Object>

Provides information about a particular class of Msg. Subclasses of this should be provided by each message class. This information is used to present a view of the message hierarchy for the scripting user interface. To provide this for a message class, create a method - public static MessageInfo getInfo() - in the class.

Note: This implements Comparable for compatibility reasons; implementing Comparable would remove binary compatibility with earlier versions.


Nested Class Summary
 class MessageInfo.Variables
          Class representing the list of available scripting variables
 
Constructor Summary
MessageInfo(java.lang.Class<? extends Msg> c)
          Constructs with a particular message class and a default name (the class name without Msg).
MessageInfo(java.lang.Class<? extends Msg> c, java.lang.String name, java.lang.String description)
          Constructs with a particular message class.
 
Method Summary
 void addSubclass(MessageInfo subclass)
          Called by system to add a subclass to this info.
 boolean allowScripting()
           
 void close()
          Called by system to close this info; removes the info from its superclass, if any.
 int compareTo(java.lang.Object obj)
           
 boolean equals(java.lang.Object obj)
           
 FilterInfo[] getAppropriateFilters()
           
 java.lang.String getContextInit()
          Messages can supply code that initialises the context if needed, to be used when the message is received.
 java.lang.String getDescription()
           
 java.lang.Class<? extends Msg> getMessageClass()
           
 java.lang.String getName()
           
 MessageInfo[] getSubclasses()
           
 MessageInfo getSuperclass()
           
 MessageInfo.Variables getVariables()
           
 boolean isAbstract()
           
protected  void listAppropriateFilters(java.util.Collection<FilterInfo> list)
          Adds permitted filters to a list.
protected  void listScriptingVariables(MessageInfo.Variables v)
          Adds scripting variables to a list.
 void removeSubclass(MessageInfo subclass)
          Called by system to remove a subclass from this info.
 void setSuperclass(MessageInfo superclass)
          Called by system to set the superclass for this info
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageInfo

public MessageInfo(java.lang.Class<? extends Msg> c)
Constructs with a particular message class and a default name (the class name without Msg).

Parameters:
c - Class of message to which this info applies

MessageInfo

public MessageInfo(java.lang.Class<? extends Msg> c,
                   java.lang.String name,
                   java.lang.String description)
Constructs with a particular message class.

Parameters:
c - Class of message to which this info applies
name - Display name for message
description - Description of message
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj - Comparison object
Returns:
True if the object is a MessageInfo referring to same class

getContextInit

public java.lang.String getContextInit()
Messages can supply code that initialises the context if needed, to be used when the message is received. Message will be in 'msg' variable. Default version just calls superclass or returns nothing.

Returns:
Java code

getVariables

public MessageInfo.Variables getVariables()
Returns:
List of scripting variables automatically provided by the message

getMessageClass

public java.lang.Class<? extends Msg> getMessageClass()
Returns:
Class of message

getName

public final java.lang.String getName()
Returns:
Display name

getDescription

public final java.lang.String getDescription()
Returns:
Description for display, null if none

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>

isAbstract

public boolean isAbstract()
Returns:
True if messages of this type are never sent; default is true if the message class is abstract

allowScripting

public boolean allowScripting()
Returns:
True if this message appears in the scripting 'events' section, false if it (and all subclasses) doesn't; default taken from superclass (root default is false)

listScriptingVariables

protected void listScriptingVariables(MessageInfo.Variables v)
Adds scripting variables to a list. Default just adds variables from superclass MessageInfo.

Parameters:
v - List to add variables to

getAppropriateFilters

public final FilterInfo[] getAppropriateFilters()
Returns:
List of message filter classes that may be appropriate for this message type

addSubclass

public final void addSubclass(MessageInfo subclass)
Called by system to add a subclass to this info.

Parameters:
subclass - Subclass info

removeSubclass

public final void removeSubclass(MessageInfo subclass)
Called by system to remove a subclass from this info.

Parameters:
subclass - Subclass info

setSuperclass

public final void setSuperclass(MessageInfo superclass)
Called by system to set the superclass for this info

Parameters:
superclass - Superclass info

close

public final void close()
Called by system to close this info; removes the info from its superclass, if any.


listAppropriateFilters

protected void listAppropriateFilters(java.util.Collection<FilterInfo> list)
Adds permitted filters to a list. Default version just adds filters from superclass MessageInfo, or nothing if none.

Parameters:
list - List to add filters to

getSubclasses

public MessageInfo[] getSubclasses()
Returns:
List of subclasses of this message type

getSuperclass

public MessageInfo getSuperclass()
Returns:
Superclass of this message type


Copyright © 2011 Samuel Marshall. All rights reserved.