anecho.JamochaMUD.plugins.TriggerDir
Class Rule

java.lang.Object
  extended by anecho.JamochaMUD.plugins.TriggerDir.Rule

public class Rule
extends java.lang.Object

This class is used to contain rules used by Triggers. A rule is a set of conditions. Each condition can be relatively simple but when combined with other conditions will define the result of a rule. There are three descriptions for a rule: Word - The text portion of the rule that JamochaMUD matches against Option - specifying if a rule is type AND/NOT/MODIFIER etc. Condition - A string containing both the Option and Word A complete rule follows this format when saved to a text file $RULES:1$0:AND:[idle$COLOUR:#ffffff$MATCHONLY:true$LAUNCH:None$MEDIA:None$TRIGGER:None$NAME:Highlight idle messages$DONE: $RULES:1 Indicates there is only 1 condition to this rule $0: Indicates the position of the first (0-based numbering) rule AND: the option for rule 0 [idle the string to match for rule 0 $COLOUR: the colour to use for this rule $MATCHONLY: Highlight with $COLOUR: only the portion of the text that matches this rule $LAUNCH: path of a program to launch based on a correct match $MEDIA: path to a media file to play based on a correct match $TRIGGER: Text to be sent back to the MU* based on a correct match $NAME: The human-readable name of this plug-in $DONE: This marks the end of the given rule


Constructor Summary
Rule()
           
Rule(java.lang.String name)
           
 
Method Summary
 void addCondition(java.lang.String cond)
          Adds a new rule to the end the existing list of rules
 void addCondition(java.lang.String option, java.lang.String word)
          Add a new rule to the end of the existing list of rules
 int conditionCount()
          This returns the number of conditions in this rule
 java.lang.String getColourString()
           
 java.lang.String getConditionAt(int index)
          Get the rule at the given index
 java.lang.String[] getConditions()
          Returns all the current rules as a String array
 java.lang.String getMediaString()
           
 java.lang.String getName()
          Returns the human-readable name of this rule
 java.lang.String getOptionAt(int index)
          Returns the option at the given index
 java.lang.String getTriggerString()
           
 java.lang.String getWordAt(int index)
          Returns the word at the given index
 void insertConditionAt(int index, java.lang.String cond)
          Set the rule at the given index.
 boolean isColour()
           
 boolean isGag()
           
 boolean isHighlight()
           
 boolean isMatchOnly()
           
 boolean isMedia()
           
 boolean isTrigger()
           
 void setColour(boolean state)
           
 void setColourString(java.lang.String code)
           
 void setConditions(java.lang.String conStr)
          Set the conditions based on one string.
 void setGag(boolean state)
           
 void setHighlight(boolean state)
           
 void setMatchOnly(boolean state)
           
 void setMedia(boolean state)
           
 void setMediaString(java.lang.String code)
           
 void setName(java.lang.String name)
          Set the name of this rule
 void setTrigger(boolean state)
           
 void setTriggerString(java.lang.String code)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rule

public Rule()

Rule

public Rule(java.lang.String name)
Parameters:
name -
Method Detail

setName

public void setName(java.lang.String name)
Set the name of this rule

Parameters:
name - human-readable name of this rule

getName

public java.lang.String getName()
Returns the human-readable name of this rule

Returns:
The human-readable name of this rule

conditionCount

public int conditionCount()
This returns the number of conditions in this rule

Returns:
an integer representing the number of conditions in this rule

insertConditionAt

public void insertConditionAt(int index,
                              java.lang.String cond)
Set the rule at the given index. This will over-write any existing rule

Parameters:
index - The index of the rule to set

getConditionAt

public java.lang.String getConditionAt(int index)
Get the rule at the given index

Parameters:
index - The index of the rule to return
Returns:
A String representing the rule at the selected index

getConditions

public java.lang.String[] getConditions()
Returns all the current rules as a String array

Returns:
A String array of all the current rules

setConditions

public void setConditions(java.lang.String conStr)
Set the conditions based on one string. This is generally how rules are stored, so this method will parse the string apart and build the conditions.

Parameters:
conStr - A String representing all the conditions

addCondition

public void addCondition(java.lang.String cond)
Adds a new rule to the end the existing list of rules

Parameters:
cond - The string representing the new condition

addCondition

public void addCondition(java.lang.String option,
                         java.lang.String word)
Add a new rule to the end of the existing list of rules

Parameters:
option -
word -

getWordAt

public java.lang.String getWordAt(int index)
Returns the word at the given index

Parameters:
index -
Returns:

getOptionAt

public java.lang.String getOptionAt(int index)
Returns the option at the given index

Parameters:
index -
Returns:

setHighlight

public void setHighlight(boolean state)
Parameters:
state -

isHighlight

public boolean isHighlight()
Returns:

setColour

public void setColour(boolean state)
Parameters:
state -

isColour

public boolean isColour()
Returns:

setColourString

public void setColourString(java.lang.String code)
Parameters:
code -

getColourString

public java.lang.String getColourString()
Returns:

setMatchOnly

public void setMatchOnly(boolean state)
Parameters:
state -

isMatchOnly

public boolean isMatchOnly()
Returns:

setGag

public void setGag(boolean state)
Parameters:
state -

isGag

public boolean isGag()
Returns:

setMedia

public void setMedia(boolean state)
Parameters:
state -

isMedia

public boolean isMedia()
Returns:

setMediaString

public void setMediaString(java.lang.String code)
Parameters:
code -

getMediaString

public java.lang.String getMediaString()
Returns:

setTrigger

public void setTrigger(boolean state)
Parameters:
state -

isTrigger

public boolean isTrigger()
Returns:

setTriggerString

public void setTriggerString(java.lang.String code)
Parameters:
code -

getTriggerString

public java.lang.String getTriggerString()
Returns: