|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.g11ntoolkit.strfile.StrFile
Creates and maintains a string file with its associated buffer and hashtable.
The string file is the file that contains the association between token ids and the strings they represent. It is an intermediate file used by the L10N Leveraging tools. The file is written in XLIFF format and follows the conventions of XLIFF 1.1.
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 java.lang.String |
contextFileName
The Context File for the strings that were extracted. |
protected java.lang.String |
datatype
The data type of the source file. |
protected java.util.Hashtable |
elementTable
A collection of the associations between the tokens and the context element ids. |
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 java.lang.String |
productName
The Product Name. |
protected java.lang.String |
productVersion
The Product Version. |
protected java.lang.String |
sourceFileName
The Source File from which the strings were extracted. |
protected java.util.Hashtable |
stringTable
A collection of strings and their associated tokens. |
protected java.util.Locale |
targetLocale
The target locale. |
protected java.lang.StringBuffer |
theBuffer
A collection of all the file level data from the specified input file. |
protected java.util.Locale |
thisLocale
The locale. |
protected TokFile |
tokFile
The TokFile that contains the skeleton of the source file. |
protected static java.util.ResourceBundle |
vrb
Constants and variables used by the tools and classes. |
protected static java.util.ResourceBundle |
xliffrb
Constants, messages, and variables used by the tools and classes for XLIFF processing. |
protected static java.util.ResourceBundle |
xrb
Constants, messages, and variables used by the tools and classes for XML processing. |
| Constructor Summary | |
StrFile()
Creates an empty buffer and an empty hashtable and sets the log to the default output stream. |
|
| Method Summary | |
void |
append(java.lang.String aString)
Adds the specified string to the end of the buffer. |
void |
append(Token aToken,
XLEntry aString)
Adds the specified token and string translation entry to the hashtable. |
protected static java.lang.String |
convertToFileURL(java.lang.String filename)
Returns the filename converted to a file URL. |
void |
copyOf(StrFile anotherStrFile)
Creates a copy of the contents of another StrFile object in this object. |
void |
debugDump()
Dumps the contents of the object to the console for debugging. |
void |
debugDump(java.lang.String what)
Dumps the contents of the object to the console for debugging. |
boolean |
findString(XLEntry aString)
Returns true if the specified string translation entry is in the file. |
boolean |
findToken(Token aToken)
Returns true if the specified token is in the file. |
java.lang.StringBuffer |
getBuffer()
Returns the buffer. |
java.lang.String |
getContextFileName()
Returns the Context File Name. |
java.lang.String |
getDatatype()
Returns the data type of the source file. |
java.util.Hashtable |
getElementTable()
Returns the element table. |
java.util.Locale |
getLocale()
Returns the locale. |
java.lang.String |
getProductName()
Returns the Product Name. |
java.lang.String |
getProductVersion()
Returns the Product Version. |
java.lang.String |
getSourceFileName()
Returns the Source File Name. |
XLEntry |
getString(java.lang.String anElementId)
Returns the string translation entry that has the specified element id in its context. |
XLEntry |
getString(Token aToken)
Returns the string translation entry for the specified token. |
java.util.Hashtable |
getStringTable()
Returns the string table. |
java.util.Locale |
getTargetLocale()
Returns the target locale. |
TokFile |
getTokFile()
Returns the TokFile. |
java.lang.String |
getXLIFFLocaleString()
Returns the locale string suitable for use in an XLIFF file. |
java.util.Enumeration |
keys()
Returns an enumeration of the keys (Tokens) for all the strings in the file. |
void |
loadXLIFF(java.lang.String xf,
TokFile tf)
Loads the StrFile and TokFile objects with the records read from the specified XLIFF file. |
void |
setContextFileName(java.lang.String cf)
Sets the Context File Name. |
void |
setDatatype(java.lang.String dt)
Sets the data type of the source file. |
void |
setLocale(java.util.Locale aLocale)
Set the locale for this object to the specified Locale object. |
void |
setProductName(java.lang.String pn)
Sets the Product Name. |
void |
setProductVersion(java.lang.String pv)
Sets the Product Version. |
void |
setSourceFileName(java.lang.String sf)
Sets the Source File Name. |
void |
setTargetLocale(java.util.Locale tloc)
Set the target locale for this object to the specified Locale object. |
void |
setTokFile(TokFile tf)
Sets the TokFile. |
void |
writeXLIFF(java.io.OutputStreamWriter osWriter,
boolean writeBOM,
boolean sourceonly)
Writes the string file out to the specified output stream writer in XLIFF form. |
| 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 xrb
protected static java.util.ResourceBundle xliffrb
protected java.util.Hashtable stringTable
The key to the table is the token and the value is a translation entry for the string. The string can have comments which will be preserved in the string entry.
Token,
XLEntryprotected java.lang.StringBuffer theBuffer
This is only the stuff that comes before the first token id in the file. It is usually just comments.
protected java.util.Hashtable elementTable
The key to the table is the token and the value is a string for the element id in the TokContext object.
Token,
TokContextprotected java.util.Locale thisLocale
writeXML().
protected TokFile tokFile
TokFile that contains the skeleton of the source file.
This is needed for the XLIFF file format.
protected java.lang.String sourceFileName
This is needed for the XLIFF file format.
protected java.lang.String contextFileName
This is needed for the XLIFF file format.
protected java.util.Locale targetLocale
This is needed for the XLIFF file format.
protected java.lang.String productName
This is needed for the XLIFF file format.
protected java.lang.String productVersion
This is needed for the XLIFF file format.
protected java.lang.String datatype
This is needed for the XLIFF file format. The value must be one of the values specified in the xliff.datatype section of the xliffres.java file.
xliffres| Constructor Detail |
public StrFile()
This may be handy if the buffer is going to be used to create a new string file.
| Method Detail |
public void copyOf(StrFile anotherStrFile)
StrFile object in this object.
anotherStrFile - a StrFile specifying the StrFile object to copypublic java.lang.StringBuffer getBuffer()
public java.util.Hashtable getStringTable()
public java.util.Hashtable getElementTable()
public void setLocale(java.util.Locale aLocale)
aLocale - a Locale specifying the locale for this objectgetLocale()public java.util.Locale getLocale()
setLocale(java.util.Locale)public java.lang.String getXLIFFLocaleString()
public void loadXLIFF(java.lang.String xf,
TokFile tf)
throws StrFileError
xf - a String specifying the name of the XLIFF filetf - a TokFile specifying the TokFile fill in
StrFileError - if there is an error when processing the filepublic void setDatatype(java.lang.String dt)
dt - a String specifying the data type of the source filegetDatatype(),
datatypepublic java.lang.String getDatatype()
setDatatype(java.lang.String),
datatypepublic void setProductVersion(java.lang.String pv)
pv - a String specifying the version of the productgetProductVersion()public java.lang.String getProductVersion()
setProductVersion(java.lang.String)public void setProductName(java.lang.String pn)
pn - a String specifying the name of the productgetProductName()public java.lang.String getProductName()
setProductName(java.lang.String)public void setTargetLocale(java.util.Locale tloc)
tloc - a Locale specifying the target locale for this objectgetTargetLocale()public java.util.Locale getTargetLocale()
setLocale(java.util.Locale)public void setSourceFileName(java.lang.String sf)
sf - a String specifying the name of the source file from which the strings were extractedgetSourceFileName()public java.lang.String getSourceFileName()
setSourceFileName(java.lang.String)public void setContextFileName(java.lang.String cf)
cf - a String specifying the name of the source file from which the strings were extractedgetContextFileName()public java.lang.String getContextFileName()
setContextFileName(java.lang.String)public void setTokFile(TokFile tf)
TokFile.
tf - a TokFile specifying the TokFile object that contains the source file skeletongetTokFile()public TokFile getTokFile()
TokFile.
TokFile object that contains the source file skeletonsetTokFile(com.g11ntoolkit.tokfile.TokFile)
public void writeXLIFF(java.io.OutputStreamWriter osWriter,
boolean writeBOM,
boolean sourceonly)
throws EmptyStrFile,
java.io.IOException
osWriter - an OutputStreamWriter objectwriteBOM - a boolean indicating whether to write a Byte Order Mark (true) or not (false)sourceonly - a boolean indicating whether to write a source only file (true) or a source and target file (false)
EmptyStrFile - if there is nothing to write out
java.io.IOException - if any error is detected for the output writerpublic java.util.Enumeration keys()
public XLEntry getString(Token aToken)
aToken - a Token object specifying the key of the desired entry
public boolean findToken(Token aToken)
aToken - a Token object containing the desired token
public boolean findString(XLEntry aString)
aString - a XLEntry object containing the desired string
public XLEntry getString(java.lang.String anElementId)
anElementId - a String
public void append(Token aToken,
XLEntry aString)
aToken - a Token objectaString - a XLEntry objectpublic void append(java.lang.String aString)
This becomes a file level comment. If write is called, this string, as well as all the other file level comments, will be written out before the actual token/string entries. It is assumed that the string is a properly formatted comment record. No checking is done.
aString - a String specifying the string to append to the objectpublic void debugDump()
This version of the method assumes that you want all of the contents.
public void debugDump(java.lang.String what)
You can control what gets dumped by specifying a parameter. The parameter can be ALL, BUFFER, or STRINGS. The parameter must be specified in all uppercase characters.
what - a String specifying what to dumpprotected static java.lang.String convertToFileURL(java.lang.String filename)
filename - a String containing the file name to be converted
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||