Package org.kie.api.io

## Interface Resource

- All Superinterfaces:
    `java.io.Serializable`

      public interface Resource
      extends java.io.Serializable

  Generic interface to provide a Reader or InputStream for the underlying IO resource.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ResourceConfiguration` | `getConfiguration()` |
    `java.io.InputStream` | `getInputStream()` | Open an InputStream to the resource, the user must close this when finished.
    `java.io.Reader` | `getReader()` | Opens a Reader to the resource, the user must close this when finished.
    `ResourceType` | `getResourceType()` | Returns the type of the resource if one could be inferred by the extension of the resource or if it was explicitly set.
    `java.lang.String` | `getSourcePath()` |
    `java.lang.String` | `getTargetPath()` |
    `Resource` | `setConfiguration​(ResourceConfiguration conf)` | Sets the resource configuration in case it is necessary.
    `Resource` | `setResourceType​(ResourceType type)` | Sets the resource type.
    `Resource` | `setSourcePath​(java.lang.String path)` | Sets this resource name.
    `Resource` | `setTargetPath​(java.lang.String path)` | In case this resource should be written to a different path when writing it down to the KieFileSystem, this property allows the application to set such path.

- - ### Method Detail

    - #### getInputStream

          java.io.InputStream getInputStream()
                                      throws java.io.IOException

      Open an InputStream to the resource, the user must close this when finished.
      Returns:
        InputStream to the resource
      Throws:
        `java.io.IOException`

    - #### getReader

          java.io.Reader getReader()
                            throws java.io.IOException

      Opens a Reader to the resource, the user must close this when finished.
      Returns:
        Reader to the resource
      Throws:
        `java.io.IOException`

    - #### getSourcePath

          java.lang.String getSourcePath()

      Returns:
        source path of the resource, if one is available.

    - #### getTargetPath

          java.lang.String getTargetPath()

      Returns:
        the target path that should be used when writing this resource down to KieFileSystem.

    - #### getResourceType

          ResourceType getResourceType()

      Returns the type of the resource if one could be inferred by the extension of the resource or if it was explicitly set.
      Returns:
        typo of the resource

    - #### getConfiguration

          ResourceConfiguration getConfiguration()

      Returns:
        the configuration for the resource if one is available.

    - #### setSourcePath

          Resource setSourcePath​(java.lang.String path)

      Sets this resource name. Some services require a resource to be named and it is not always possible to infer a name automatically. For instance, a file resource automatically infers its name from the file and path, but a byte array resource has to be given a name.
      Parameters:
        `path` - the path of the resource
      Returns:
        the resource itself in order to use it as a fluent API

    - #### setTargetPath

          Resource setTargetPath​(java.lang.String path)

      In case this resource should be written to a different path when writing it down to the KieFileSystem, this property allows the application to set such path.
      Parameters:
        `path` - the path of the resource
      Returns:
        the resource itself in order to use it as a fluent API

    - #### setResourceType

          Resource setResourceType​(ResourceType type)

      Sets the resource type. For some resources it is possible to infer the type by the file name extension for instance. When it is not possible to infer it automatically, the user is expected to set it.
      Parameters:
        `type` - the resource type
      Returns:
        the resource itself in order to use it as a fluent API

    - #### setConfiguration

          Resource setConfiguration​(ResourceConfiguration conf)

      Sets the resource configuration in case it is necessary.
      Parameters:
        `conf` - the resource configuration
      Returns:
        the resource itself in order to use it as a fluent API