|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.g11ntoolkit.tokenizer.FileTokenizer
General class for a file tokenizer.
This is intended to be a class whose sub-classes take care of all the work. This class is here to provide a first level of interpretation as to with which kind of a file we are dealing.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See License Agreement.
| Field Summary | |
protected static java.util.Hashtable |
context
The context hashtable. |
protected static java.lang.String |
encoding
The encoding specifies which encoding is used for the input file. |
protected static java.lang.StringBuffer |
inFileBuffer
The string buffer which will contain the input file data for the subclasses to use. |
protected static java.util.ResourceBundle |
jspVars
JSP variables Resource Bundle. |
private static java.util.logging.Logger |
log
The log used for all messages from this class. |
protected static java.util.ResourceBundle |
mrb
Message Resource Bundle. |
protected static java.lang.String |
product
The name of the Product that contains the input file. |
protected static java.lang.String |
productVersion
The version for the product that contains the input file. |
protected static java.util.Hashtable |
revContext
The Tokens associated with their contexts. |
protected java.util.Locale |
targetLocale
The target locale specifies which locale is used for the resource bundle. |
protected static TokContext |
tokContext
The context information. |
protected static Token |
token
The token is used to get the unique token numbers. |
protected static java.util.ResourceBundle |
vrb
Variables Resource Bundle. |
| Constructor Summary | |
|
FileTokenizer()
Establishes an instance of the class for public use in order to determine which subclass to use. |
protected |
FileTokenizer(java.lang.String anEncoding)
Used by the subclasses to establish an instance of the class and save the encoding information for use in processing the file. |
protected |
FileTokenizer(java.lang.String anEncoding,
java.util.Locale aLocale,
Token aToken)
Used by the subclasses to establish an instance of the class and save all the input information for use in processing the file. |
| Method Summary | |
protected static java.lang.String |
cleanConcats(java.lang.String val)
Removes any string concats from the specified string. |
static java.lang.String |
getEncoding()
Returns the encoding name for the input file. |
java.lang.StringBuffer |
getFileBuffer()
Returns the file buffer that contains the input file contents. |
TokContext |
getKey(Token token)
Returns the key for a specified token in the tokenized file. |
static java.lang.String |
getProductName()
Returns the product name. |
static java.lang.String |
getProductVersion()
Returns the product version. |
Token |
getToken(TokContext key)
Returns the token for a specified key in the tokenized file. |
java.util.Enumeration |
keys()
Returns a list of keys in the tokenized file. |
static void |
readFile(java.lang.String inFileName)
Reads in the specified file and stores it in the string buffer. |
static void |
readFilePlain(java.lang.String inFileName,
java.lang.String encoding)
Reads in the specified file and stores it in the string buffer. |
void |
setContext(TokContext ctxt,
Token tok)
Saves the association between a context in the tokenized file and its token. |
static void |
setEncoding(java.lang.String e)
Sets the encoding name for the input file. |
static void |
setProductName(java.lang.String p)
Sets the product name. |
static void |
setProductVersion(java.lang.String v)
Sets the product version. |
protected void |
setupTok(java.lang.String anEncoding,
java.util.Locale aLocale)
Used by the subclasses to set up the common part of the checking of any DSP file. |
protected static void |
setupTok(java.lang.String inFileName,
java.lang.String contextFileName)
Used by the subclasses to set up the common part of the tokenizing of any file and reads the file into the string buffer. |
java.util.Enumeration |
tokens()
Returns a list of tokens in the tokenized file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static java.util.logging.Logger log
protected static java.util.ResourceBundle mrb
protected static java.util.ResourceBundle vrb
protected static java.util.ResourceBundle jspVars
protected static Token token
protected static java.lang.String encoding
The encoding will also be used on the output files.
protected java.util.Locale targetLocale
protected static java.lang.StringBuffer inFileBuffer
protected static TokContext tokContext
protected static java.util.Hashtable context
This is a table of the contexts in the file associated with their tokens.
protected static java.util.Hashtable revContext
This is a table of the tokens in the file associated with their contexts (i.e., a reverse context).
protected static java.lang.String product
protected static java.lang.String productVersion
| Constructor Detail |
public FileTokenizer()
protected FileTokenizer(java.lang.String anEncoding,
java.util.Locale aLocale,
Token aToken)
throws FileTokenizerError
anEncoding - a String specifying the encoding to use on the input fileaLocale - a Locale objectaToken - a Token object
FileTokenizerError - when anything goes wrong
protected FileTokenizer(java.lang.String anEncoding)
throws FileTokenizerError
anEncoding - a String specifying the encoding to use on the input file
FileTokenizerError - when anything goes wrong| Method Detail |
protected void setupTok(java.lang.String anEncoding,
java.util.Locale aLocale)
throws FileTokenizerError
anEncoding - a String specifying the encoding to use on the input fileaLocale - a Locale object
FileTokenizerError - when anything goes wrong
protected static void setupTok(java.lang.String inFileName,
java.lang.String contextFileName)
throws FileTokenizerError
inFileName - a String specifying the input file namecontextFileName - a String specifying the file name to use for the token id and context
FileTokenizerError - when anything goes wrong
public static void readFile(java.lang.String inFileName)
throws FileTokenizerError
Coverts any non-ascii characters to their unicode value.
inFileName - a String specifying the name of the file to read
FileTokenizerError - for any errors
public static void readFilePlain(java.lang.String inFileName,
java.lang.String encoding)
throws FileTokenizerError
inFileName - a String specifying the name of the file to readencoding - a String specifying the encoding for the input file
FileTokenizerError - for any errors
protected static java.lang.String cleanConcats(java.lang.String val)
throws FileTokenizerError
This replaces each string concat with a single blank and returns the resulting string. The length of the specified string must be longer than 3 characters before this method will do anything.
A string concat is assumed to be a double quote, followed by some amount of white space, followed by a plus sign (+), followed by some amount of white space, followed by a double quote. The amount of white space can be none in both places. This is why the minimum length of the string is checked before trying to remove the concats.
val - a String specifying the string to clean
FileTokenizerError - when anything goes wrongpublic java.util.Enumeration keys()
public java.util.Enumeration tokens()
public Token getToken(TokContext key)
key - a TokContext object specifying the context
public TokContext getKey(Token token)
token - a Token object specifying the token
public void setContext(TokContext ctxt,
Token tok)
ctxt - a TokContext object specifying the context for the specified tokentok - a Token object specifying the token for the specified contextpublic java.lang.StringBuffer getFileBuffer()
public static void setEncoding(java.lang.String e)
e - a String specifying the encoding namegetEncoding()public static java.lang.String getEncoding()
setEncoding(java.lang.String)public static void setProductName(java.lang.String p)
p - a String specifying the name of the productgetProductName()public static java.lang.String getProductName()
setProductName(java.lang.String)public static void setProductVersion(java.lang.String v)
v - a String specifying the version of the productgetProductVersion()public static java.lang.String getProductVersion()
setProductVersion(java.lang.String)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||