de.caff.i18n

## Class XmlResourceBundle

- java.lang.Object
- - java.util.ResourceBundle
  - - de.caff.i18n.XmlResourceBundle

-     public class XmlResourceBundle
      extends java.util.ResourceBundle

  A resource bundle based on an XML file defining the resources.

  This adds the simplicity of using properties files for resources (no compilation necessary) with better language support (properties files are always in ISO-8859-1 encoding, while an XML file can specify its encoding) and some more features like comments.

  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `XmlResourceBundle.AbstractBasicResourceNode` Abstract base implementation of a resource node.
    `static class` | `XmlResourceBundle.ResourceActionGroup` Special resource group for actions.
    `static interface` | `XmlResourceBundle.ResourceNode` Basic definition of a resource node in the XML file.
    `static interface` | `XmlResourceBundle.ValueType`

    - ### Nested classes/interfaces inherited from class java.util.ResourceBundle

      `java.util.ResourceBundle.Control`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ATTR_COMMENT`
    `static java.lang.String` | `ATTR_INHERET`
    `static java.lang.String` | `ATTR_KEY`
    `static java.lang.String` | `ATTR_NAME`
    `static java.lang.String` | `ATTR_SUBTYPE`
    `static java.lang.String` | `ATTR_TYPE`
    `static java.lang.String` | `ATTR_VALUE`
    `static java.lang.String` | `ATTR_VERSION`
    `static java.lang.String` | `EXTENSION` Extension used for XML resource bundles.
    `static int` | `MY_VERSION`
    `static XmlResourceBundle.ValueType` | `OBJECT_VALUE_TYPE`
    `static java.lang.String` | `TAG_ACTION`
    `static java.lang.String` | `TAG_GROUP`
    `static java.lang.String` | `TAG_I18N`
    `static java.lang.String` | `TAG_RESOURCE`

    - ### Fields inherited from class java.util.ResourceBundle

      `parent`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XmlResourceBundle()` Default constructor.
    `XmlResourceBundle(java.io.InputStream is)` Read an XML resource from the given input stream.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getComment()`
    `java.util.Enumeration<java.lang.String>` | `getKeys()` Returns an enumeration of the keys.
    `static java.util.ResourceBundle` | `getResourceBundle(java.lang.String baseName)` Get a resource bundle with a given basename, using the default locale.
    `static java.util.ResourceBundle` | `getResourceBundle(java.lang.String baseName, java.util.Locale locale)` Get a resource bundle with a given basename, using the given locale.
    `static java.util.ResourceBundle` | `getResourceBundle(java.lang.String baseName, java.util.Locale locale, java.lang.ClassLoader classLoader)` Get a resource bundle with a given basename, using the given locale and class loader.
    `protected java.lang.Object` | `handleGetObject(java.lang.String key)` Gets an object for the given key from this resource bundle.
    `static void` | `main(java.lang.String[] args)`
    `void` | `putInheretedResource(java.lang.String key)`
    `void` | `putObjectResource(java.lang.String key, java.io.Serializable value)`
    `void` | `putObjectResource(java.lang.String key, java.io.Serializable value, java.lang.String comment)`
    `void` | `putResource(java.lang.String key, java.lang.Object value, XmlResourceBundle.ValueType type)`
    `void` | `putResource(java.lang.String key, java.lang.Object value, XmlResourceBundle.ValueType type, java.lang.String comment)`
    `void` | `putStringArrayResource(java.lang.String key, java.lang.String[] value)`
    `void` | `putStringArrayResource(java.lang.String key, java.lang.String[] value, java.lang.String comment)`
    `void` | `putStringResource(java.lang.String key, java.lang.String value)`
    `void` | `putStringResource(java.lang.String key, java.lang.String value, java.lang.String comment)`
    `void` | `saveXml(java.io.OutputStream os)`

    - ### Methods inherited from class java.util.ResourceBundle

      `clearCache, clearCache, containsKey, getBaseBundleName, 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

    - #### EXTENSION

          public static final java.lang.String EXTENSION

      Extension used for XML resource bundles.
      See Also:
        Constant Field Values

    - #### TAG_I18N

          public static final java.lang.String TAG_I18N

      See Also:
        Constant Field Values

    - #### TAG_GROUP

          public static final java.lang.String TAG_GROUP

      See Also:
        Constant Field Values

    - #### TAG_RESOURCE

          public static final java.lang.String TAG_RESOURCE

      See Also:
        Constant Field Values

    - #### TAG_ACTION

          public static final java.lang.String TAG_ACTION

      See Also:
        Constant Field Values

    - #### ATTR_KEY

          public static final java.lang.String ATTR_KEY

      See Also:
        Constant Field Values

    - #### ATTR_VALUE

          public static final java.lang.String ATTR_VALUE

      See Also:
        Constant Field Values

    - #### ATTR_TYPE

          public static final java.lang.String ATTR_TYPE

      See Also:
        Constant Field Values

    - #### ATTR_SUBTYPE

          public static final java.lang.String ATTR_SUBTYPE

      See Also:
        Constant Field Values

    - #### ATTR_COMMENT

          public static final java.lang.String ATTR_COMMENT

      See Also:
        Constant Field Values

    - #### ATTR_VERSION

          public static final java.lang.String ATTR_VERSION

      See Also:
        Constant Field Values

    - #### ATTR_INHERET

          public static final java.lang.String ATTR_INHERET

      See Also:
        Constant Field Values

    - #### ATTR_NAME

          public static final java.lang.String ATTR_NAME

      See Also:
        Constant Field Values

    - #### MY_VERSION

          public static final int MY_VERSION

      See Also:
        Constant Field Values

    - #### OBJECT_VALUE_TYPE

          public static final XmlResourceBundle.ValueType OBJECT_VALUE_TYPE

  - ### Constructor Detail

    - #### XmlResourceBundle

          public XmlResourceBundle(java.io.InputStream is)
                            throws java.io.IOException,
                                   org.xml.sax.SAXException,
                                   javax.xml.parsers.ParserConfigurationException

      Read an XML resource from the given input stream.
      Parameters:
        `is` - input stream
      Throws:
        `java.io.IOException` - on i/o errors
        `org.xml.sax.SAXException` - on XML parse errors
        `javax.xml.parsers.ParserConfigurationException` - on SAX parser configuration errors

    - #### XmlResourceBundle

          public XmlResourceBundle()

      Default constructor.

  - ### Method Detail

    - #### getKeys

          @NotNull
          public java.util.Enumeration<java.lang.String> getKeys()

      Returns an enumeration of the keys.
      Specified by:
        `getKeys` in class `java.util.ResourceBundle`

    - #### handleGetObject

          protected java.lang.Object handleGetObject(@NotNull
                                                     java.lang.String key)

      Gets an object for the given key from this resource bundle. Returns null if this resource bundle does not contain an object for the given key.
      Specified by:
        `handleGetObject` in class `java.util.ResourceBundle`
      Parameters:
        `key` - the key for the desired object
      Returns:
        the object for the given key, or null
      Throws:
        `java.lang.NullPointerException` - if `key` is `null`

    - #### getComment

          public java.lang.String getComment()

    - #### putStringResource

          public void putStringResource(java.lang.String key,
                                        java.lang.String value)

    - #### putStringResource

          public void putStringResource(java.lang.String key,
                                        java.lang.String value,
                                        java.lang.String comment)

    - #### putStringArrayResource

          public void putStringArrayResource(java.lang.String key,
                                             java.lang.String[] value)

    - #### putStringArrayResource

          public void putStringArrayResource(java.lang.String key,
                                             java.lang.String[] value,
                                             java.lang.String comment)

    - #### putObjectResource

          public void putObjectResource(java.lang.String key,
                                        java.io.Serializable value)

    - #### putObjectResource

          public void putObjectResource(java.lang.String key,
                                        java.io.Serializable value,
                                        java.lang.String comment)

    - #### putResource

          public void putResource(java.lang.String key,
                                  java.lang.Object value,
                                  XmlResourceBundle.ValueType type)

    - #### putInheretedResource

          public void putInheretedResource(java.lang.String key)

    - #### putResource

          public void putResource(java.lang.String key,
                                  java.lang.Object value,
                                  XmlResourceBundle.ValueType type,
                                  java.lang.String comment)

    - #### saveXml

          public void saveXml(java.io.OutputStream os)
                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getResourceBundle

          public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName)

      Get a resource bundle with a given basename, using the default locale. Compared to `ResourceBundle.getBundle()` this will also look for XML resource bundles.

      The semantics of this is also differing, because it has no access to the class loader of the calling class. It has to use `ClassLoader.getSystemClassLoader()` instead. Access to this method is restricted, so an exception will be thrown in restricted environments, eg unsigned applets. Use `getResourceBundle(String, java.util.Locale, ClassLoader)` instead with an appropriate class loader.

      Parameters:
        `baseName` - base name
      Returns:
        best matching resource bundle

    - #### getResourceBundle

          public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName,
                                                                   java.util.Locale locale)

      Get a resource bundle with a given basename, using the given locale. Compared to `ResourceBundle.getBundle()` this will also look for XML resource bundles.

      The semantics of this is also differing, because it has no access to the class loader of the calling class. It has to use `ClassLoader.getSystemClassLoader()` instead. Access to this method is restricted, so an exception will be thrown in restricted environments, eg unsigned applets. Use `getResourceBundle(String, java.util.Locale, ClassLoader)` instead with an appropriate class loader.

      Parameters:
        `baseName` - base name
        `locale` - locale to use for resource bundle resolve
      Returns:
        best matching resource bundle

    - #### getResourceBundle

          public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName,
                                                                   java.util.Locale locale,
                                                                   java.lang.ClassLoader classLoader)

      Get a resource bundle with a given basename, using the given locale and class loader. Compared to `ResourceBundle.getBundle()` this will also look for XML resource bundles.
      Parameters:
        `baseName` - base name
        `locale` - locale to use for resource bundle resolve
        `classLoader` - class loader to use for loading resource bundles
      Returns:
        best matching resource bundle

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.io.IOException,
                                  org.xml.sax.SAXException,
                                  javax.xml.parsers.ParserConfigurationException

      Throws:
        `java.io.IOException`
        `org.xml.sax.SAXException`
        `javax.xml.parsers.ParserConfigurationException`