All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Samples.GetQuotes

java.lang.Object
   |
   +----Samples.GetQuotes

public class GetQuotes
extends Object
This class provides a utility to make java source i18n compliant. Note the translated file is not ready to compile until the developer has provided for resource bundle loading and access. For examples, see the Java Internationalization documentation.


Variable Index

 o excludeCount
 o excludes
 o keyDifferentiator
 o keys
 o MaxQuote
 o outputDirectory
 o quoteCount
 o quotes
 o resBundleName

Constructor Index

 o GetQuotes(String, boolean)
Create an instance of GetQuotes.

Method Index

 o getSub(String)
Gets the substition key string for the original string.
 o isExclude(String)
Checks if the string is to be excluded from translation.
 o loadExcludes(String)
Loads the file of excluded strings.
 o main(String[])
Runs GetQuotes accepting command args and performing GetQuotes invocation.
 o makeKey(String)
Turns a quote string into an acceptable key.
 o parseStream(boolean, StreamTokenizer, FileOutputStream)
Parses the source code substituting keys for quoted strings.
 o restored(String)
Translates special control characters into escape character sequences.

Variables

 o quoteCount
 static int quoteCount
 o keyDifferentiator
 static int keyDifferentiator
 o MaxQuote
 static int MaxQuote
 o excludeCount
 static int excludeCount
 o quotes
 static String quotes[]
 o keys
 static String keys[]
 o excludes
 static String excludes[]
 o outputDirectory
 static String outputDirectory
 o resBundleName
 static String resBundleName

Constructors

 o GetQuotes
 GetQuotes(String name,
           boolean output)
Create an instance of GetQuotes. Load files and initiate the parsing/translation operation.

Parameters:
name - the file or directory name
output - a flag indicating the translated file is to be sent to stdout

Methods

 o main
 public static void main(String args[])
Runs GetQuotes accepting command args and performing GetQuotes invocation. Examples: To generate a table to stdout, with no translated file,
 Samples.GetQuotes ..\Samples\BuildAccessorWindow.java -h"American English" -t 
 
To generate a translation to stdout,
 Samples.GetQuotes ..\Samples\BuildAccessorWindow.java -bMyResources -o 
 
To generate translated files from the Samples directory to Samples/I18n, with a locale file captured in a file from stdout, using a string excludes file and a specific resource bundle name,
 Samples.GetQuotes ..\Samples -h"American English" -xsamplesExclude.txt -t -d..\Samples\I18n -bMyResources > locale_en_US.properties
 

Parameters:
args - list of command line arguments
 o parseStream
 void parseStream(boolean outputFlag,
                  StreamTokenizer stis,
                  FileOutputStream fos)
Parses the source code substituting keys for quoted strings.

Parameters:
outputFlag - if true send parsed and translated text to stdout
stis - a StreamTokenizer to handle the source code parsing
fos - an output stream to write parsed source and translations.
 o getSub
 String getSub(String originalQuote)
Gets the substition key string for the original string. If the string does not exist in the database of strings, store it and create a key for it. If the original quote is found in a list of quotes to exclude the original quote is returned. Translated keys are returned with the resource bundle accessor method syntax.

Parameters:
originalQuote - the content of a quoted string found in the source code
Returns:
if translated, the key to the string, else the original string
 o makeKey
 String makeKey(String quote)
Turns a quote string into an acceptable key. The key and the quote are ultimately stored in the locale file. Keys are generated by taking the first words of the quote, special characters are excluded, capitalizing the words, concatenating the words together, truncating the words at a certain length, then adding a number to make the key unique if necessary. If a quote does not have the requisite words to form a key, a special key is generated for the quote.

Parameters:
quote - the quote taken from the source code
Returns:
the new key for the quote
 o loadExcludes
 static void loadExcludes(String filename)
Loads the file of excluded strings.

Parameters:
filename - the name of the file containing the excluded strings.
 o isExclude
 boolean isExclude(String quote)
Checks if the string is to be excluded from translation.

Parameters:
quote - a quoted string from the source code
Returns:
true if found on the excludes list else false
 o restored
 private String restored(String quote)
Translates special control characters into escape character sequences.

Parameters:
quote - a string possibly containing special control characters
Returns:
the quote with any control characters converted to escape sequences

All Packages  Class Hierarchy  This Package  Previous  Next  Index