com.jaxfront.core.dom
Class CodeTables

java.lang.Object
  extended by com.jaxfront.core.dom.CodeTables

public class CodeTables
extends java.lang.Object

Holds all possible codesets defined in a XML file (codes.xsd) for a specific XMLSchema.Each codeset defines codes and according descriptions in different languages. A code in a codeset may be marked as 'invalid'. An invalid code will be marked as an error in its according view.

See Also:
XMLSchemaImpl.getCodeTables()

Constructor Summary
CodeTables(XMLSchema schema)
          Creates a CodeTable for a specific XMLSchema out of a String representing an URL.
 
Method Summary
static java.lang.String createCacheKey(XMLSchema schema, java.lang.String url, java.net.URL xuiURL)
           
static java.util.Hashtable createCodeTable(Type source, org.w3c.dom.Document dom)
          Builds a hashtable for all codesets in the passed document object model.
static java.lang.String createKeyInt(boolean checkType, Type source, java.lang.String codeSetName, java.lang.String language)
           
static java.lang.String[] extractFromKey(java.lang.String key)
           
 java.util.Map getAllItems(Type source, java.lang.String codesetName, java.lang.String language)
           
 java.util.Hashtable getCachedURLs()
           
 java.lang.String[] getCodeItemKeys(Type source, java.lang.String codesetName)
          Returns all codes keys belonging to a codeset in the current language.
 java.lang.String[][] getCodeItems(boolean checkType, Type source, java.lang.String codesetName, java.lang.String language)
           
 java.lang.String[][] getCodeItems(Type source, java.lang.String codesetName)
          Returns all codes belonging to a codeset in the current language.
 CodeSetEntry getCodeSetEntry(boolean checkType, Type source, java.lang.String codesetName, java.lang.String language)
           
static java.net.URL getCodeSetHelpURL(java.net.URL codeSetURL, java.lang.String language, java.lang.String codeSetName, java.lang.String code)
           
 java.lang.String getCodeSetLabel(java.lang.String codeSetName, java.lang.String language)
           
 java.util.Hashtable getCodeSets()
           
static java.net.URL getCodeSetURL(XMLSchema schema, java.lang.String url)
           
 java.lang.String getEntryHelp(Type source, java.lang.String codesetName, java.lang.String id, java.lang.String language)
           
 java.lang.String getEntryParam(Type source, java.lang.String codesetName, java.lang.String id, java.lang.String language)
           
 java.lang.String getId(Type source, java.lang.String codesetName, int pos, java.lang.String language)
          Returns the id (code) for a certain description within a codeset.
 java.lang.String getId(Type source, java.lang.String codesetName, java.lang.String text, java.lang.String language)
          Returns the id (code) for a certain description within a codeset.
 java.lang.String getIdByKey(Type source, java.lang.String codesetName, java.lang.String language, int pos)
          Returns the id (code) for a certain description within a codeset.
 java.lang.String getIdByKey(Type source, java.lang.String codesetName, java.lang.String language, java.lang.String text)
          Returns the id (code) for a certain description within a codeset.
 java.lang.String[] getItems(boolean checkType, Type source, java.lang.String codesetName, java.lang.String language)
          Returns all codes belonging to a codeset in the current language.
 java.lang.String getText(Type source, java.lang.String codesetName, java.lang.String id, java.lang.String language)
          Returns the description for an id in a certain codeset.
 java.lang.String[] getTextArray(Type source, java.lang.String name, java.lang.String[] id, java.lang.String language)
          Returns an array of descriptions for different id's.
 void initialize(org.w3c.dom.Document codeSetDocument)
          Initializes the codeset with a String representing the codeset file location.
 java.lang.String[] initialize(Type source, java.lang.String codeSetName, java.io.Reader reader)
           
 java.lang.String[] initialize(Type source, java.lang.String classURL, java.lang.String codeSetName)
          Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).
 boolean initialize(XMLSchema schema, java.lang.String url)
           
 boolean initialize(XMLSchema schema, java.lang.String url, java.net.URL xuiURL, org.apache.xerces.xni.parser.XMLEntityResolver resolver)
          Initializes the codeset with a String representing the codeset file location.
 java.lang.String[][] initialize2(Type source, java.lang.String codeSetName, java.io.Reader reader)
          Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).
 java.lang.String[][] initialize2(Type source, java.lang.String classURL, java.lang.String codeSetName)
          Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).
 boolean isCached(java.lang.String aCodeSetUrl)
           
static boolean isValueInvalid(java.lang.String value, java.lang.String language)
          Returns true if the passed value is an invalid code description.
 void release()
          Release class
 void releaseCache()
           
 void releaseCodeSets()
          Releases all loaded codesets for this codetable.
 void setLanguage(java.lang.String language)
          Sets the current language for the code table.
 java.lang.String toXML()
           
static java.util.LinkedHashMap transformHashtablesForXMLSerialization(java.util.Hashtable codeSets)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeTables

public CodeTables(XMLSchema schema)
Creates a CodeTable for a specific XMLSchema out of a String representing an URL.

Parameters:
schema - the schema which holds this codeset
Method Detail

createCacheKey

public static java.lang.String createCacheKey(XMLSchema schema,
                                              java.lang.String url,
                                              java.net.URL xuiURL)

createCodeTable

public static java.util.Hashtable createCodeTable(Type source,
                                                  org.w3c.dom.Document dom)
Builds a hashtable for all codesets in the passed document object model.


createKeyInt

public static java.lang.String createKeyInt(boolean checkType,
                                            Type source,
                                            java.lang.String codeSetName,
                                            java.lang.String language)

extractFromKey

public static java.lang.String[] extractFromKey(java.lang.String key)

getAllItems

public java.util.Map getAllItems(Type source,
                                 java.lang.String codesetName,
                                 java.lang.String language)

getCachedURLs

public java.util.Hashtable getCachedURLs()

getCodeItemKeys

public java.lang.String[] getCodeItemKeys(Type source,
                                          java.lang.String codesetName)
Returns all codes keys belonging to a codeset in the current language.

Parameters:
codesetName - name of a codeset
Returns:
String[] with all the codes for a codeset or null

getCodeItems

public java.lang.String[][] getCodeItems(boolean checkType,
                                         Type source,
                                         java.lang.String codesetName,
                                         java.lang.String language)

getCodeItems

public java.lang.String[][] getCodeItems(Type source,
                                         java.lang.String codesetName)
Returns all codes belonging to a codeset in the current language.

Parameters:
codesetName - name of a codeset
Returns:
String[] with all the codes for a codeset or null

getCodeSetEntry

public CodeSetEntry getCodeSetEntry(boolean checkType,
                                    Type source,
                                    java.lang.String codesetName,
                                    java.lang.String language)

getCodeSetHelpURL

public static java.net.URL getCodeSetHelpURL(java.net.URL codeSetURL,
                                             java.lang.String language,
                                             java.lang.String codeSetName,
                                             java.lang.String code)

getCodeSetLabel

public java.lang.String getCodeSetLabel(java.lang.String codeSetName,
                                        java.lang.String language)

getCodeSets

public java.util.Hashtable getCodeSets()

getCodeSetURL

public static java.net.URL getCodeSetURL(XMLSchema schema,
                                         java.lang.String url)

getEntryHelp

public java.lang.String getEntryHelp(Type source,
                                     java.lang.String codesetName,
                                     java.lang.String id,
                                     java.lang.String language)

getEntryParam

public java.lang.String getEntryParam(Type source,
                                      java.lang.String codesetName,
                                      java.lang.String id,
                                      java.lang.String language)

getId

public java.lang.String getId(Type source,
                              java.lang.String codesetName,
                              int pos,
                              java.lang.String language)
Returns the id (code) for a certain description within a codeset. Returns null if no description has been found.

Parameters:
codesetName - name of the codeset
text - description to looking for
language - language to lookup
Returns:
an id defined for a description

getId

public java.lang.String getId(Type source,
                              java.lang.String codesetName,
                              java.lang.String text,
                              java.lang.String language)
Returns the id (code) for a certain description within a codeset. Returns null if no description has been found.

Parameters:
codesetName - name of the codeset
text - description to looking for
language - language to lookup
Returns:
an id defined for a description

getIdByKey

public java.lang.String getIdByKey(Type source,
                                   java.lang.String codesetName,
                                   java.lang.String language,
                                   int pos)
Returns the id (code) for a certain description within a codeset. Returns null if no description has been found.

Parameters:
key - codeset cache key
pos - position to looking for
Returns:
an id defined for a position

getIdByKey

public java.lang.String getIdByKey(Type source,
                                   java.lang.String codesetName,
                                   java.lang.String language,
                                   java.lang.String text)
Returns the id (code) for a certain description within a codeset. Returns null if no description has been found.

Parameters:
key - codeset cache key
codesetName - name of the codeset
text - description to looking for
language - language to lookup
Returns:
an id defined for a description

getItems

public java.lang.String[] getItems(boolean checkType,
                                   Type source,
                                   java.lang.String codesetName,
                                   java.lang.String language)
Returns all codes belonging to a codeset in the current language.

Parameters:
codesetName - name of a codeset
language - current language
Returns:
String[] with all the codes for a codeset or null

getText

public java.lang.String getText(Type source,
                                java.lang.String codesetName,
                                java.lang.String id,
                                java.lang.String language)
Returns the description for an id in a certain codeset.

Parameters:
codesetName - name of the codeset
id - id to looking for
language - current language
Returns:
description text

getTextArray

public java.lang.String[] getTextArray(Type source,
                                       java.lang.String name,
                                       java.lang.String[] id,
                                       java.lang.String language)
Returns an array of descriptions for different id's.

Parameters:
codesetName - name of the codeset
id - id's to looking for
language - current language
Returns:
an array of descriptions

initialize

public void initialize(org.w3c.dom.Document codeSetDocument)
Initializes the codeset with a String representing the codeset file location.


initialize

public java.lang.String[] initialize(Type source,
                                     java.lang.String codeSetName,
                                     java.io.Reader reader)

initialize

public java.lang.String[] initialize(Type source,
                                     java.lang.String classURL,
                                     java.lang.String codeSetName)
Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).


initialize

public boolean initialize(XMLSchema schema,
                          java.lang.String url)

initialize

public boolean initialize(XMLSchema schema,
                          java.lang.String url,
                          java.net.URL xuiURL,
                          org.apache.xerces.xni.parser.XMLEntityResolver resolver)
Initializes the codeset with a String representing the codeset file location.

Returns:
boolean true if a codeset has been found and loaded for the given url

initialize2

public java.lang.String[][] initialize2(Type source,
                                        java.lang.String codeSetName,
                                        java.io.Reader reader)
Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).


initialize2

public java.lang.String[][] initialize2(Type source,
                                        java.lang.String classURL,
                                        java.lang.String codeSetName)
Initializes the codeset from an input stream (e.g. a class file that implements the codeset interface).


isCached

public boolean isCached(java.lang.String aCodeSetUrl)

isValueInvalid

public static boolean isValueInvalid(java.lang.String value,
                                     java.lang.String language)
Returns true if the passed value is an invalid code description.

Parameters:
value -

release

public void release()
Release class


releaseCache

public void releaseCache()

releaseCodeSets

public void releaseCodeSets()
Releases all loaded codesets for this codetable.


setLanguage

public void setLanguage(java.lang.String language)
Sets the current language for the code table.


toXML

public java.lang.String toXML()

transformHashtablesForXMLSerialization

public static java.util.LinkedHashMap transformHashtablesForXMLSerialization(java.util.Hashtable codeSets)