de.esprit.appsuite.project

## Class ResourceDefAdapter

- java.lang.Object
- - de.esprit.appsuite.project.ResourceDefAdapter

-     public final class ResourceDefAdapter
      extends java.lang.Object

  This adapter provides helper methods for coping with system test resources. It wraps a `ResourceDef` implementation, which is typically an Enum implementing the `ResourceDef` interface. The according Enum MUST be located in the same package like the resource-file.
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.Class` | `definingClass`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourceDefAdapter(IconKey iconKey)`
    `ResourceDefAdapter(ResourceDef resourceDef, FileDataType dataType, java.lang.String resourceName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.io.File` | `copyToFile(java.io.File targetDir, java.lang.String fileName)` Copies the ASCII resource to the given targetDirectory under the given name.
    `java.io.File` | `copyToTargetDir(java.io.File targetDir)`
    `java.io.File` | `copyToTargetDir(java.io.File targetDir, ReplacementMap replacements)` Copies the ASCII resource to a file and performs the replacements defined in the given `ReplacementMap`
    `java.io.File` | `copyToTargetDir(java.io.File targetDir, java.lang.String fileName, ReplacementMap replacements)` Copies the ASCII resource to a file and performs the replacements defined in the given `ReplacementMap`
    `ProgressReader` | `createProgressReader()` Opens the resource for reading.
    `java.io.File` | `extractToTargetDir(ApplicationContext ctx, java.io.File targetDir)` Extracts the content of a zip-archive resource to the target directory.
    `ProgressInputStream` | `getAsProgressInputStream()`
    `java.io.InputStream` | `getAsStream()`
    `FileDataType` | `getDataType()`
    `java.lang.String` | `getResourceClassName()` Return the fully qualified class name of the resource
    `java.lang.String` | `getResourceFilePath()` Return the relative file pathname of the the resource including the resourceName.
    `ResourceInfo` | `getResourceInfo()`
    `java.lang.String` | `getResourceName()` Returns the name of this resource
    `java.lang.String` | `toString()`

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

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

- - ### Field Detail

    - #### definingClass

          protected final java.lang.Class definingClass

  - ### Constructor Detail

    - #### ResourceDefAdapter

          public ResourceDefAdapter(IconKey iconKey)

    - #### ResourceDefAdapter

          public ResourceDefAdapter(ResourceDef resourceDef,
                            FileDataType dataType,
                            java.lang.String resourceName)

  - ### Method Detail

    - #### getDataType

          public FileDataType getDataType()

    - #### getResourceName

          public java.lang.String getResourceName()

      Returns the name of this resource

    - #### getResourceClassName

          public java.lang.String getResourceClassName()

      Return the fully qualified class name of the resource

    - #### getAsStream

          public java.io.InputStream getAsStream()
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getAsProgressInputStream

          public ProgressInputStream getAsProgressInputStream()
                                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getResourceFilePath

          public java.lang.String getResourceFilePath()

      Return the relative file pathname of the the resource including the resourceName.

    - #### getResourceInfo

          public ResourceInfo getResourceInfo()

    - #### createProgressReader

          public ProgressReader createProgressReader()
                                              throws java.io.IOException

      Opens the resource for reading. Note that the reader must be closed after using it.
      Throws:
        `java.io.IOException`

    - #### copyToTargetDir

          public java.io.File copyToTargetDir(java.io.File targetDir)
                                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### extractToTargetDir

          public java.io.File extractToTargetDir(ApplicationContext ctx,
                                        java.io.File targetDir)
                                          throws java.lang.Exception

      Extracts the content of a zip-archive resource to the target directory. Returns the File reference to the extracted directory. Note: the name of the extracted directory must match the resource-name without the zip-suffix.
      Throws:
        `java.lang.Exception`

    - #### copyToTargetDir

          public java.io.File copyToTargetDir(java.io.File targetDir,
                                     ReplacementMap replacements)
                                       throws java.io.IOException

      Copies the ASCII resource to a file and performs the replacements defined in the given `ReplacementMap`
      Throws:
        `java.io.IOException`

    - #### copyToTargetDir

          public java.io.File copyToTargetDir(java.io.File targetDir,
                                     java.lang.String fileName,
                                     ReplacementMap replacements)
                                       throws java.io.IOException

      Copies the ASCII resource to a file and performs the replacements defined in the given `ReplacementMap`
      Throws:
        `java.io.IOException`

    - #### copyToFile

          public java.io.File copyToFile(java.io.File targetDir,
                                java.lang.String fileName)
                                  throws java.io.IOException

      Copies the ASCII resource to the given targetDirectory under the given name.
      Throws:
        `java.io.IOException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.