com.isomorphic.util

## Class LocaleMessageProviderRegistry

- java.lang.Object
- - com.isomorphic.util.LocaleMessageProviderRegistry

-     public class LocaleMessageProviderRegistry
      extends java.lang.Object

  Allows to register custom `LocaleMessageProvider`. Framework will look up for registered custom provider and use it to get i18n message when parsing XML sources.

  Providers can be registered (added) just for data sources and/or for any other XML source. Providers may be configured for all sources or for sources with specific prefix or which names match the regex specified during provider registration. Note that the provider implementation is not controlled, so it completely valid to use same instance for different look up configurations.

  Providers can be unregistered (removed) using the ID that is returned when provider was registered. Each add method returns an unique ID which later may be used to remove that specific provider. Note that removing provider by unique ID will remove only that specific provider which when added returned this ID.

  When framework is looking up for provider it will pick up first provider matching configuration according to the look up order (see below) and providers registration order.

  Look up order for data source:

  search data source provider configured with prefix/regex (added via `addDSLocaleMessageProivder(provider, prefix)` or `addDSLocaleMessageProivder(provider, regex)`)
  check if there's provider configured for all data sources (added via `addDSLocaleMessageProvider(provider)`)
  search all source provider configured with prefix/regex (added via `addLocaleMessageProivder(provider, prefix)` or `addLocaleMessageProivder(provider, regex)`)
  check if there's provider configured for all sources (added via `addLocaleMessageProvider(provider)`)
  Look up order for any other source:
  search all source provider configured with prefix/regex (added via `addLocaleMessageProivder(provider, prefix)` or `addLocaleMessageProivder(provider, regex)`)
  check if there's provider configured for all sources (added via `addLocaleMessageProvider(provider)`)

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `addDSLocaleMessageProvider(LocaleMessageProvider lmp)` Registers `LocaleMessageProvider` for all data sources.
    `static int` | `addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex)` Registers `LocaleMessageProvider` for data sources which names match the `regex`.
    `static int` | `addDSLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix)` Registers `LocaleMessageProvider` for data sources which names start with `prefix`.
    `static int` | `addLocaleMessageProvider(LocaleMessageProvider lmp)` Registers `LocaleMessageProvider` for all sources.
    `static int` | `addLocaleMessageProvider(LocaleMessageProvider lmp, java.util.regex.Pattern regex)` Registers `LocaleMessageProvider` for sources which names match the `regex`.
    `static int` | `addLocaleMessageProvider(LocaleMessageProvider lmp, java.lang.String prefix)` Registers `LocaleMessageProvider` for sources which names start with `prefix`.
    `static LocaleMessageProvider` | `getDSLocaleMessageProvider(java.lang.String id)` Looks up `LocaleMessageProvider` by data source id.
    `static LocaleMessageProvider` | `getLocaleMessageProvider(java.lang.String id)` Looks up `LocaleMessageProvider` by source id.
    `static boolean` | `removeLocaleMessageProvider(int id)` Unregisters `LocaleMessageProvider` by its unique ID.

- - ### Method Detail

    - #### addLocaleMessageProvider

          public static int addLocaleMessageProvider(LocaleMessageProvider lmp)

      Registers `LocaleMessageProvider` for all sources.
      Parameters:
        `lmp` - provider to register
      Returns:
        unique ID

    - #### addLocaleMessageProvider

          public static int addLocaleMessageProvider(LocaleMessageProvider lmp,
                                                     java.lang.String prefix)

      Registers `LocaleMessageProvider` for sources which names start with `prefix`.
      Parameters:
        `lmp` - provider to register
        `prefix` - prefix to use
      Returns:
        unique ID

    - #### addLocaleMessageProvider

          public static int addLocaleMessageProvider(LocaleMessageProvider lmp,
                                                     java.util.regex.Pattern regex)

      Registers `LocaleMessageProvider` for sources which names match the `regex`.
      Parameters:
        `lmp` - provider to register
        `regex` - regex to match
      Returns:
        unique ID

    - #### addDSLocaleMessageProvider

          public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp)

      Registers `LocaleMessageProvider` for all data sources.
      Parameters:
        `lmp` - provider to register
      Returns:
        unique ID

    - #### addDSLocaleMessageProvider

          public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp,
                                                       java.lang.String prefix)

      Registers `LocaleMessageProvider` for data sources which names start with `prefix`.
      Parameters:
        `lmp` - provider to register
        `prefix` - prefix to use
      Returns:
        unique ID

    - #### addDSLocaleMessageProvider

          public static int addDSLocaleMessageProvider(LocaleMessageProvider lmp,
                                                       java.util.regex.Pattern regex)

      Registers `LocaleMessageProvider` for data sources which names match the `regex`.
      Parameters:
        `lmp` - provider to register
        `regex` - regex to match
      Returns:
        unique ID

    - #### removeLocaleMessageProvider

          public static boolean removeLocaleMessageProvider(int id)

      Unregisters `LocaleMessageProvider` by its unique ID.
      Parameters:
        `id` - unique id
      Returns:
        `true` if provider was successfully removed, `false` otherwise

    - #### getLocaleMessageProvider

          public static LocaleMessageProvider getLocaleMessageProvider(java.lang.String id)

      Looks up `LocaleMessageProvider` by source id.
      Parameters:
        `id` - source id
      Returns:
        `LocaleMessageProvider` or `null` if not found

    - #### getDSLocaleMessageProvider

          public static LocaleMessageProvider getDSLocaleMessageProvider(java.lang.String id)

      Looks up `LocaleMessageProvider` by data source id.
      Parameters:
        `id` - source id
      Returns:
        `LocaleMessageProvider` or `null` if not found