bin
Class Parser

java.lang.Object
  extended by bin.Parser

public class Parser
extends java.lang.Object

Parser Class

This class is used to parse any external files that are loaded into AI Builder.

NB: As most of the code adheres to a particular format, the documentation that accompanies the parseIndividualInstinct() method is written out only once, in the first instinct ("BlindFire") code block.

Version:
0.1 - Initial Release
Author:
Richard John Sproston [ richard.sproston@gmail.com || lucky_jackpot@hotmail.com ]

Constructor Summary
Parser()
          Default Constructor for class with no parameters.
Parser(java.lang.String instinct)
          Default Constructor for class with 1 parameter.
Parser(java.lang.String instinct, int numParams)
          Default Constructor for class with 2 parameters.
 
Method Summary
 void parseDocument(javax.swing.JTextArea textArea)
          This method begins to parse an entire AI file document, (as represented by the contents of the JTextArea "preview" pane.
 void parseIndividualInstinct(java.lang.String individualInstinct, int lineNumber)
           This method parses an individual line of code, attempting to locate a specific instinct within the line, as well as checking parameter count information as applicable to the instinct being parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser()
Default Constructor for class with no parameters.


Parser

public Parser(java.lang.String instinct)
Default Constructor for class with 1 parameter.

Parameters:
instinct - The current instinct being parsed.

Parser

public Parser(java.lang.String instinct,
              int numParams)
Default Constructor for class with 2 parameters.

Parameters:
instinct - The current instinct being parsed.
numParams - How many parameters the current instinct has.
Method Detail

parseDocument

public void parseDocument(javax.swing.JTextArea textArea)
                   throws java.io.FileNotFoundException,
                          java.io.IOException,
                          InstinctException
This method begins to parse an entire AI file document, (as represented by the contents of the JTextArea "preview" pane.

Parameters:
textArea - The graphical component that contains the text that comprises the AI file's contents.
Throws:
java.io.FileNotFoundException
java.io.IOException
InstinctException

parseIndividualInstinct

public void parseIndividualInstinct(java.lang.String individualInstinct,
                                    int lineNumber)
                             throws java.io.FileNotFoundException,
                                    java.io.IOException,
                                    InstinctException

This method parses an individual line of code, attempting to locate a specific instinct within the line, as well as checking parameter count information as applicable to the instinct being parsed.

NB: The "Follow" instinct is separated into three sub-section code blocks to evaluate its valid parameter range (this is because "Follow" has three working implementations with 2, 3 and 4 parameter versions (respectively) being shown to function correctly!

Parameters:
individualInstinct - The name of the specific instinct currently being parsed.
lineNumber - The number of the line in the file where the instinct resides (used primarily to obtain a handle on line-parsing errors, so the user knows exactly where to look for the error).
Throws:
java.io.FileNotFoundException - If the "ai.properties" resource file (that acts as the program "database") cannot be located.
java.io.IOException - If any other possible I/O exception occurs whilst attempting to find/read a (core resource) file.
InstinctException - If an error parsing the currnet instinct occurs, prepare a handle to retrieve all related information (ready for a meaningful output display to the user).