Skip navigation links
org.brains2b.resx

Class ExtResourceBundle

    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.ResourceBundle

        java.util.ResourceBundle.Control
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected static java.sql.Connection m_con 
      protected java.util.HashMap m_contents 
      protected java.lang.String m_domain 
      protected java.util.Locale m_locale 
      • Fields inherited from class java.util.ResourceBundle

        parent
    • Constructor Summary

      Constructors 
      Constructor and Description
      ExtResourceBundle(java.lang.String baseName, java.util.Locale locale)
      Constructor for DatabaseBundle.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void clear()
      clear cache
      boolean containsKey(java.lang.String key) 
      java.util.Map getAllContents() 
      java.lang.String getBaseName()
      get the base name of this resource bundle
      protected static java.util.ResourceBundle getBundleImpl(ExtResourceBundle res)
      Method getBundleImpl.
      protected java.sql.Connection getConnection()
      get the connection to the database from which to collect the resources
      protected java.util.HashMap getContents()
      get the content of this resource bundle as a hashtable
      static java.util.ResourceBundle getExtBundle(java.lang.String baseName)
      Method getExtBundle.
      static java.util.ResourceBundle getExtBundle(java.lang.String baseName, java.util.Locale locale)
      Method getExtBundle.
      static java.util.ResourceBundle getExtBundle(java.lang.String baseName, java.util.Locale locale, java.sql.Connection con)
      Method getExtBundle.
      java.util.Enumeration getKeys() 
      java.util.Locale getLocale()
      get the locale with which this resource bundle was created
      protected java.util.ResourceBundle getParent()
      get the parent of this resource bundle.
      java.lang.String getSQL()
      Method getSQL.
      protected java.lang.Object handleGetObject(java.lang.String key) 
      java.util.Set<java.lang.String> keySet() 
      protected void makeConnection()
      Make a connection to the database
      • Methods inherited from class java.util.ResourceBundle

        clearCache, clearCache, getBaseBundleName, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, setParent
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_contents

        protected java.util.HashMap m_contents
      • m_domain

        protected java.lang.String m_domain
      • m_locale

        protected java.util.Locale m_locale
      • m_con

        protected static java.sql.Connection m_con
    • Constructor Detail

      • ExtResourceBundle

        public ExtResourceBundle(java.lang.String baseName,
                                 java.util.Locale locale)
        Constructor for DatabaseBundle.
    • Method Detail

      • getExtBundle

        public static java.util.ResourceBundle getExtBundle(java.lang.String baseName)
        Method getExtBundle. Replacement for getBundle(String) to get access to Database functions
        Parameters:
        baseName - String, the Name of the Bundle/Domain
        Returns:
        ResourceBundle
      • getExtBundle

        public static java.util.ResourceBundle getExtBundle(java.lang.String baseName,
                                                            java.util.Locale locale)
        Method getExtBundle. Replacement for getBundle(String,Locale) to get access to Database functions
        Parameters:
        baseName -
        locale -
        Returns:
        ResourceBundle
      • getExtBundle

        public static java.util.ResourceBundle getExtBundle(java.lang.String baseName,
                                                            java.util.Locale locale,
                                                            java.sql.Connection con)
        Method getExtBundle. Replacement for getBundle(String,Locale) to get access to Database functions
        Parameters:
        baseName -
        locale -
        Returns:
        ResourceBundle
      • getBundleImpl

        protected static java.util.ResourceBundle getBundleImpl(ExtResourceBundle res)
        Method getBundleImpl. Actual method for getting the Bundle.
          sequence is:
        • try finding a default List or Properties bundle
        • try to find a database bundle
        Parameters:
        res - ExtResourceBundle
        Returns:
        ResourceBundle
      • getParent

        protected java.util.ResourceBundle getParent()
        get the parent of this resource bundle.

        A parent of a resource bundle can be defined as a less Locale specific resource bundle: en is the parent of en_GB and has the empy locale as its owner parent.

        Returns:
        ResourceBundle, the parent of this resource bundle
      • handleGetObject

        protected java.lang.Object handleGetObject(java.lang.String key)
        Specified by:
        handleGetObject in class java.util.ResourceBundle
        See Also:
        ResourceBundle.handleGetObject(String)
      • getKeys

        public java.util.Enumeration getKeys()
        Specified by:
        getKeys in class java.util.ResourceBundle
        See Also:
        ResourceBundle.getKeys()
      • makeConnection

        protected void makeConnection()
                               throws java.sql.SQLException
        Make a connection to the database

        The connection is default made using either:

          System.properties
        • sql.driver the full classpath name of the driver
        • sql.url the url to connect to the database
        • sql.user the username with which to connect to the database
        • sql.password the password to connect to the database

        or a properties.file in the root of the application named connection.properties in which the four above properties are defined.

        Overwrite if you want to use another way of getting a connection

        Throws:
        SQLException, - in the event a connection could not be established
        java.sql.SQLException
      • getSQL

        public java.lang.String getSQL()
        Method getSQL.

        Composes the default query for getting values from a LOCALIZED_RESOURCE table. The query should be defined to get all values from a given base/domain, language and country at once

          The table definition is expected to be as Follows:
        • DOMAIN VARCHAR
        • KEY VARCHAR
        • VALUE VARCHAR
        • LANGUAGE VARCHAR
        • COUNTRY VARCHAR

        The lengths are not specified, so you can use your own create scripts are however provided for this table in the projects package

        Overwrite if you want to use another table

        Returns:
        String, the SQL-query
      • getContents

        protected java.util.HashMap getContents()
        get the content of this resource bundle as a hashtable
        Returns:
        HashMap, the content of this resource bundle
      • getAllContents

        public java.util.Map getAllContents()
      • getConnection

        protected java.sql.Connection getConnection()
                                             throws java.sql.SQLException
        get the connection to the database from which to collect the resources
        Returns:
        Connection
        Throws:
        java.sql.SQLException, - thrown if the connection to the database fails
        java.sql.SQLException
        See Also:
        makeConnection()
      • getBaseName

        public java.lang.String getBaseName()
        get the base name of this resource bundle
        Returns:
        String, the name of the bundle
      • getLocale

        public java.util.Locale getLocale()
        get the locale with which this resource bundle was created

        This implementation is contrary to ResourceBundle.getLocale() which returns the Locale of the resource bundle which was actually used and could return the Locale for the parent

        Overrides:
        getLocale in class java.util.ResourceBundle
        See Also:
        ResourceBundle.getLocale()
      • clear

        public static void clear()
        clear cache
      • containsKey

        public boolean containsKey(java.lang.String key)
        Overrides:
        containsKey in class java.util.ResourceBundle
      • keySet

        public java.util.Set<java.lang.String> keySet()
        Overrides:
        keySet in class java.util.ResourceBundle