org.apache.tamaya.format

## Class ConfigurationFormats

- java.lang.Object
- - org.apache.tamaya.format.ConfigurationFormats

-     public final class ConfigurationFormats
      extends Object

  Small accessor and management class dealing with `ConfigurationFormat` instances.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static List<ConfigurationFormat>` | `getFormats()` Get all currently available formats, ordered by priority.
    `static List<ConfigurationFormat>` | `getFormats(String... formatNames)` Get all currently available formats, ordered by priority.
    `static List<ConfigurationFormat>` | `getFormats(URL url)` Get all currently available formats, ordered by priority.
    `static Collection<ConfigurationData>` | `getPropertySources(Collection<URL> urls, ConfigurationFormat... formats)`
    `static ConfigurationData` | `readConfigurationData(String resource, InputStream inputStream, ConfigurationFormat... formats)` Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.
    `static ConfigurationData` | `readConfigurationData(URL url)` Tries to read configuration data from a given URL, hereby traversing all known formats in order of precedence.
    `static ConfigurationData` | `readConfigurationData(URL url, ConfigurationFormat... formats)` Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getFormats

          public static List<ConfigurationFormat> getFormats()

      Get all currently available formats, ordered by priority.
      Returns:
        the currently available formats, never null.

    - #### getFormats

          public static List<ConfigurationFormat> getFormats(String... formatNames)

      Get all currently available formats, ordered by priority.
      Returns:
        the currently available formats, never null.

    - #### getFormats

          public static List<ConfigurationFormat> getFormats(URL url)

      Get all currently available formats, ordered by priority.
      Returns:
        the currently available formats, never null.

    - #### readConfigurationData

          public static ConfigurationData readConfigurationData(URL url)
                                                         throws IOException

      Tries to read configuration data from a given URL, hereby traversing all known formats in order of precedence. Hereby the formats are first filtered to check if the URL is acceptable, before the input is being parsed.
      Parameters:
        `url` - the url from where to read, not null.
      Returns:
        the ConfigurationData read, or null.
      Throws:
        `IOException` - if the resource cannot be read.

    - #### readConfigurationData

          public static ConfigurationData readConfigurationData(URL url,
                                                                ConfigurationFormat... formats)
                                                         throws IOException

      Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.
      Parameters:
        `url` - the url from where to read, not null.
        `formats` - the formats to try.
      Returns:
        the ConfigurationData read, or null.
      Throws:
        `IOException` - if the resource cannot be read.

    - #### getPropertySources

          public static Collection<ConfigurationData> getPropertySources(Collection<URL> urls,
                                                                         ConfigurationFormat... formats)

      Parameters:
        `urls` - the urls from where to read, not null.
        `formats` - the formats to try.
      Returns:
        the `ConfigurationData` of the files successfully decoded by the given formats.

    - #### readConfigurationData

          public static ConfigurationData readConfigurationData(String resource,
                                                                InputStream inputStream,
                                                                ConfigurationFormat... formats)
                                                         throws IOException

      Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.
      Parameters:
        `resource` - a descriptive name for the resource, since an InputStream does not have any)
        `inputStream` - the inputStream from where to read, not null.
        `formats` - the formats to try.
      Returns:
        the ConfigurationData read, or null.
      Throws:
        `IOException` - if the resource cannot be read.

Copyright © 2014–2015 Apache Software Foundation. All rights reserved.