miSim

misim.util
Class TxtParser

java.lang.Object
  |
  +--misim.util.TxtParser

public class TxtParser
extends java.lang.Object

TxtParser generates the Txt.java internationalisation class from a message file. The message file defines all messages that will be used by the software, and their identifiers. Each message is on a separate line, and is of the form:

MESSAGE_IDENTIFIER = A message with %1 replacements

where MESSAGE_IDENTIFIER will become a static integer message identifier, and the message is stored as a string, where text may be inserted in place of the %n identifiers (where n is a number from 1 to 9). The auto generated Txt.java class extends TxtBaseClass.java which provides the core message retrieval functions.


Constructor Summary
TxtParser()
          Constructor, which simply initialises the global message and identifier Vectors.
 
Method Summary
static void main(java.lang.String[] args)
          Main method invoked to read the message file and generate a java class file that provides message retrieval and internationalisation.
 void parseGroup(SettingsGroup group)
          Read all of the settings in the given group into the global Vectors of messages and identifiers.
 void readText(java.lang.String fromFile, java.lang.String toFile)
          Read a settings file, and call parseGroup to parse all settings groups in that file into messages and identifiers, then generate the Txt.java file that stores and retrieves these messages.
 void writeFile(java.lang.String toFile)
          Generate the Java source file for Txt.java, containing the get() method, and all of the message identifiers and values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TxtParser

public TxtParser()
Constructor, which simply initialises the global message and identifier Vectors.
Method Detail

readText

public void readText(java.lang.String fromFile,
                     java.lang.String toFile)
              throws java.lang.Exception
Read a settings file, and call parseGroup to parse all settings groups in that file into messages and identifiers, then generate the Txt.java file that stores and retrieves these messages.
Parameters:
fromFile - The name of the message file to read
toFile - The name of the java source file to write
Throws:
java.lang.Exception - If any errors occured whilst reading or writing the files.

writeFile

public void writeFile(java.lang.String toFile)
               throws java.lang.Exception
Generate the Java source file for Txt.java, containing the get() method, and all of the message identifiers and values. These are retrieved from the global message and identifier Vectors.
Parameters:
toFile - The name of the file to write

parseGroup

public void parseGroup(SettingsGroup group)
Read all of the settings in the given group into the global Vectors of messages and identifiers.
Parameters:
group - The SettingsGroup to read

main

public static void main(java.lang.String[] args)
Main method invoked to read the message file and generate a java class file that provides message retrieval and internationalisation. The two command line arguments are the Message file name, and the Java source file name to be generated (in that order). The generated file defines a class 'Txt.java' and assumes a package name of 'misim.util' - therefore the second parameter is only intended to allow the destination directory for the generated source. However, the full path must be given (eg. 'mysourcedir\\misim\\util\\Txt.java')

miSim