|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--javatools.util.ScriptCatcher
It's a class to catch text from a script file and to divide it into commands.
| Constructor Summary | |
ScriptCatcher()
Creates new ScriptCatcher |
|
| Method Summary | |
void |
addCommand(java.lang.String value)
Adds a new command. |
void |
clear()
Removes all the commands. |
void |
constructCommands(java.lang.String textScript)
Construct commands fromf a given string (textScript) instead of a file. |
java.util.ArrayList |
getCommandList()
Returns the commands as a list. |
java.lang.String[] |
getCommands()
Returns the commands as an array. |
java.lang.String |
getCommandText(int numCommand)
Returns the command text of command numCommand. |
java.lang.String |
getCommentdelimiter()
Returns the string who represents the start of a comment. |
char |
getDivideCommandChar()
Returns the character who represents the end of a command. |
int |
getNumCommands()
Returns the number of commands. |
boolean |
getRemoveFormat()
Returns the property about removing formatting items (spaces and new-lines) |
java.lang.Character |
getStringDelimiterChar()
Returns the character who represents the start/end of a string in the script. |
java.util.Iterator |
iterator()
Returns an iterator to iterate commands. |
void |
loadScript(java.lang.String fileName)
Loads a script whose path is in "fileName" string, divides it into commands and make them available. |
java.lang.String |
removeComments(java.lang.String inStr)
Removes comments from a script (string inStr). |
java.lang.String |
removeSpaces(java.lang.String cmdText)
Removes unuseful spaces, tabs and CRs from a command. |
void |
saveScript(java.lang.String fileName)
Saves a script using saved command texts into "fileName". |
void |
setCommandText(int numCommand,
java.lang.String value)
Sets the text for command numCommand with the string value. |
void |
setCommentDelimiter(java.lang.String inStr)
Sets the string who represents the start of a comment. |
void |
setDivideCommandChar(char inChar)
Sets the character who represents the end of a command. |
void |
setNumCommands(int numCommands)
Sets the number of commands. |
void |
setRemoveFormat(boolean value)
Controls whether formatting items (spaces and new-lines) are going to be removed. |
void |
setStringDelimiterChar(java.lang.Character inChar)
Sets the character who represents the start/end of a string in the script. |
static java.lang.String |
textFile2String(java.lang.String fileName)
Loads text file "fileName" and puts its content into a string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ScriptCatcher()
| Method Detail |
public void setRemoveFormat(boolean value)
value - true: formatting items will be removed;
false: formatting items will NOT be removed.public boolean getRemoveFormat()
true: formatting items will be removed;
false: formatting items will NOT be removed.
public void loadScript(java.lang.String fileName)
throws java.io.FileNotFoundException
fileName - Path to the file to be processed.
java.io.FileNotFoundException - If "fileName" is not found
public void saveScript(java.lang.String fileName)
throws java.io.IOException
fileName - Path to file to be saved.
java.io.IOException - If some I/O error occurspublic void constructCommands(java.lang.String textScript)
textScript - The string containing the script to be processed.public java.lang.String removeSpaces(java.lang.String cmdText)
cmdText - String containing the command to be processed.
public java.lang.String removeComments(java.lang.String inStr)
inStr - The string containing the string to be processed.
public void clear()
public int getNumCommands()
public void setNumCommands(int numCommands)
throws java.lang.IndexOutOfBoundsException
numCommands - The number of commands to be generated.
java.lang.IndexOutOfBoundsException - if numCommands is less than 1.
public java.lang.String getCommandText(int numCommand)
throws java.lang.IndexOutOfBoundsException
numCommand.
numCommand - the number of the interested command, between 0 and getNumCommands()-1
java.lang.IndexOutOfBoundsException - If numCommand is not validpublic java.lang.String[] getCommands()
public java.util.ArrayList getCommandList()
public java.util.Iterator iterator()
public void addCommand(java.lang.String value)
value - The command to add.
public void setCommandText(int numCommand,
java.lang.String value)
throws java.lang.IndexOutOfBoundsException
numCommand with the string value.
numCommand - The number of the interested command, between 0 and getNumCommands()-1.value - The command text, WITHOUT command delimiter!
java.lang.IndexOutOfBoundsException - If numCommand is not valid.public void setDivideCommandChar(char inChar)
inChar - The character which will be interpreted as a command delimiter.public char getDivideCommandChar()
public void setStringDelimiterChar(java.lang.Character inChar)
inChar - The character which will be interpreted as a string delimiter.public java.lang.Character getStringDelimiterChar()
public void setCommentDelimiter(java.lang.String inStr)
inStr - The string which will be interpreted as a comment delimiter.public java.lang.String getCommentdelimiter()
public static java.lang.String textFile2String(java.lang.String fileName)
throws java.io.FileNotFoundException
fileName - Path to file to be loaded.
java.io.FileNotFoundException - If the file "fileName" is not found.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||