org.appng.api.support

## Class ApplicationResourceHolder

- java.lang.Object
- - org.appng.api.support.ApplicationResourceHolder

- All Implemented Interfaces:
    Closeable, AutoCloseable, Resources

      public class ApplicationResourceHolder
      extends Object
      implements Resources

  Default `Resources`-implementation
  Author:
    Matthias Herlitzius

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApplicationResourceHolder(Application application, MarshallService marshallService, File applicationFolder, File outputFolder)` Creates a new `ApplicationResourceHolder`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `dumpToCache(ResourceType... types)` Writes all `Resource`s to the local caching location.
    `ApplicationInfo` | `getApplicationInfo()` Returns the `ApplicationInfo`, read from the `Application`'s `application-info.xml`.
    `Resource` | `getResource(Integer id)` Returns the `Resource` with the given ID.
    `Resource` | `getResource(ResourceType type, String fileName)` Returns the `Resource` of the given type with the given name, if any.
    `Set<Resource>` | `getResources()` Returns the underlying `Resource`
    `Set<Resource>` | `getResources(ResourceType type)` Returns all `Resource`s of the given `ResourceType`.

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

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

- - ### Constructor Detail

    - #### ApplicationResourceHolder

          public ApplicationResourceHolder(Application application,
                                           MarshallService marshallService,
                                           File applicationFolder,
                                           File outputFolder)
                                    throws InvalidConfigurationException

      Creates a new `ApplicationResourceHolder`
      Parameters:
        `application` - the `Application` that owns the `Resources`
        `marshallService` - a `MarshallService` using `MarshallService.AppNGSchema.APPLICATION`
        `applicationFolder` - the location of the `Application`'s `Resource`s on disc, only needed if the `Application` is filebased
        `outputFolder` - the output folder for storing the cached resources of the `Application`
      Throws:
        `InvalidConfigurationException` - if no valid application-info.xml could be found
      See Also:
        `Application.getResourceSet()`, `Application.isFileBased()`, `dumpToCache(ResourceType...)`

  - ### Method Detail

    - #### getResources

          public Set<Resource> getResources(ResourceType type)

      Description copied from interface: `Resources`
      Returns all `Resource`s of the given `ResourceType`.
      Specified by:
        `getResources` in interface `Resources`
      Parameters:
        `type` - the ResourceType
      Returns:
        the `Resource`s of the given `ResourceType`

    - #### dumpToCache

          public void dumpToCache(ResourceType... types)

      Description copied from interface: `Resources`
      Writes all `Resource`s to the local caching location.
      Specified by:
        `dumpToCache` in interface `Resources`
      Parameters:
        `types` - the types to write the cachefiles for
      See Also:
        `Resource.getCachedFile()`

    - #### getResource

          public Resource getResource(ResourceType type,
                                      String fileName)

      Description copied from interface: `Resources`
      Returns the `Resource` of the given type with the given name, if any.
      Specified by:
        `getResource` in interface `Resources`
      Parameters:
        `type` - the `ResourceType` of the `Resource`
        `fileName` - the name of the `Resource`
      Returns:
        the `Resource`, or `null` if no such `Resource` exists.

    - #### getResources

          public Set<Resource> getResources()

      Description copied from interface: `Resources`
      Returns the underlying `Resource`
      Specified by:
        `getResources` in interface `Resources`
      Returns:
        the underlying `Resource`s

    - #### getResource

          public Resource getResource(Integer id)

      Description copied from interface: `Resources`
      Returns the `Resource` with the given ID.
      Specified by:
        `getResource` in interface `Resources`
      Parameters:
        `id` - the ID of the `Resource`
      Returns:
        the `Resource`, or `null` if no such resource exists.

    - #### getApplicationInfo

          public ApplicationInfo getApplicationInfo()

      Description copied from interface: `Resources`
      Returns the `ApplicationInfo`, read from the `Application`'s `application-info.xml`.
      Specified by:
        `getApplicationInfo` in interface `Resources`
      Returns:
        the `ApplicationInfo`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Resources`
      Throws:
        `IOException`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.