|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.ResourceBundle
com.tecnick.tmxjavabridge.TMXResourceBundle
public class TMXResourceBundle
Reads resource text data directly from a TMX (XML) file.
First, the TMXResourceBundle class instantiates itself with two parameters: a TMX file name and a target language name. Then, using a DOM parser, it reads all of a translation unit's properties for the key information and specified language data and populates a hashtable with them.
TMX info: http://www.lisa.org/tmx/
You instantiate the TMXResourceBundle class in a program to read data from a
TMX file. Once the class is instantiated, it reads all the data in a TMX file
and loads into a DOM tree. Then it populates a hashtable so the
handleGetObject() method can be called to find text information based on a
key just as a standard ResourceBundle class does.
Instantiating the TMXResouceBundle class is the same as instantiating the
PropertyResourceBundle class. First you obtain a system language code (e.g.:
from a locale's information). In TMX the value of the attribute must be one
of the ISO language identifiers (a two- or three-letter code) or one of the
standard locale identifiers (a two- or three-letter language code, a dash,
and a two-letter region code).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.ResourceBundle |
---|
java.util.ResourceBundle.Control |
Field Summary | |
---|---|
protected java.util.Hashtable |
hashcontents
The hastable that will contain data loaded from XML |
protected int |
numberOfItems
Number of translation units (tu) items |
protected java.util.Vector |
vectOfItems
Vector to store tu items keys |
Fields inherited from class java.util.ResourceBundle |
---|
parent |
Constructor Summary | |
---|---|
TMXResourceBundle(java.lang.String xmlfile,
java.lang.String language)
TMX to Hashtable conversion. |
|
TMXResourceBundle(java.lang.String xmlfile,
java.lang.String language,
java.lang.String cachefile)
TMX to Hashtable conversion. |
Method Summary | |
---|---|
java.util.Enumeration |
getKeys()
Define getKeys method |
int |
getNumberOfItems()
Returns the number of translation units |
java.lang.String |
getString(java.lang.String key,
java.lang.String def)
Get key value, return default if void. |
java.lang.Object |
handleGetObject(java.lang.String key)
handleGetObject implementation |
org.w3c.dom.Document |
parseXmlFile(java.lang.String filename,
boolean validating)
Parses an XML file and returns a DOM document. |
Methods inherited from class java.util.ResourceBundle |
---|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Hashtable hashcontents
protected int numberOfItems
protected java.util.Vector vectOfItems
Constructor Detail |
---|
public TMXResourceBundle(java.lang.String xmlfile, java.lang.String language)
xmlfile
- the TMX (XML) file to read, supports also URI resources or JAR
resourceslanguage
- ISO language identifier (a two- or three-letter code)public TMXResourceBundle(java.lang.String xmlfile, java.lang.String language, java.lang.String cachefile)
xmlfile
- the TMX (XML) file to read, supports also URI resources or JAR
resourceslanguage
- ISO language identifier (a two- or three-letter code)cachefile
- name of the file used to store cache data for the specified
languageMethod Detail |
---|
public org.w3c.dom.Document parseXmlFile(java.lang.String filename, boolean validating)
filename
- the name of XML filevalidating
- If true, the contents is validated against the DTD specified
in the file.
public java.lang.String getString(java.lang.String key, java.lang.String def)
key
- name of keydef
- default value
public final java.lang.Object handleGetObject(java.lang.String key) throws java.util.MissingResourceException
handleGetObject
in class java.util.ResourceBundle
key
- the resource key
java.util.MissingResourceException
public int getNumberOfItems()
public java.util.Enumeration getKeys()
getKeys
in class java.util.ResourceBundle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |