java.lang.Object
com.aquima.interactions.foundation.io.resource.UrlResource
All Implemented Interfaces:
IResource, IResourceInfo, Serializable

public class UrlResource extends Object implements IResource, IResourceInfo
This resource class represents a resource from the URL resource manager.
Since:
6.3
Author:
M. Vermeulen
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    UrlResource(URL resourceUrl)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    This method returns an input stream for the resource.
    asOutputStream(boolean append)
    This method returns an output stream that may be used to write the contents of the resource.
    This method returns a reader for the resource.
    asWriter(boolean append)
    This method returns a writer that may be used to write the contents of the resource.
    boolean
    This method may be used to create the resource.
    boolean
    This method may be used to create the resource as folder.
    boolean
    This method can be used to determine if the resource is available.
    This method returns an object containing information about the resource.
    This method returns the name of the resource.
    This method can be used to retrieve a resource relative to the current resource from the same resource manager.
    This method returns a Uniform Resource Identifier object for the resource.
    boolean
    This method returns a boolean indicating if the resource represents a file.
    boolean
    This method returns a boolean indicating if the resource represents a folder.
    boolean
    This method can be used to determine if the resource is read-only.
    This method returns the last modification date value for the resource.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UrlResource

      public UrlResource(URL resourceUrl)
  • Method Details

    • asInputStream

      public InputStream asInputStream()
      Description copied from interface: IResource
      This method returns an input stream for the resource. The method will fail with an exception when the resource does not exist. The returned input stream should be closed by the invoking method.
      Specified by:
      asInputStream in interface IResource
      Returns:
      Input stream that can be used to read the contents of the resource.
    • asOutputStream

      public OutputStream asOutputStream(boolean append)
      Description copied from interface: IResource
      This method returns an output stream that may be used to write the contents of the resource. The append parameter may be used to specify if data written to the output stream should be appended to the resource (true) or if the resource should be overwritten by the data added to the output stream (false).
      Specified by:
      asOutputStream in interface IResource
      Parameters:
      append - Boolean indicating if the data added to the output stream should be appended to the resource.
      Returns:
      Output stream that may be used to write the contents of the resource.
    • asReader

      public Reader asReader()
      Description copied from interface: IResource
      This method returns a reader for the resource. The method will fail with an exception when the resource does not exist. The returned reader should be closed by the invoking method.
      Specified by:
      asReader in interface IResource
      Returns:
      Reader that can be used to read the contents of the resource.
    • asWriter

      public Writer asWriter(boolean append)
      Description copied from interface: IResource
      This method returns a writer that may be used to write the contents of the resource. The append parameter may be used to specify if data written to the writer should be appended to the resource (true) or if the resource should be overwritten by the data added to the writer (false).
      Specified by:
      asWriter in interface IResource
      Parameters:
      append - Boolean indicating if the data added to the writer should be appended to the resource.
      Returns:
      Writer that may be used to write the contents of the resource.
    • createFile

      public boolean createFile()
      Description copied from interface: IResource
      This method may be used to create the resource. This method is only applicable for resources that have been requested through the getRelative method, and that do not yet exist. The method returns a boolean indicating if the resource was actually created. When this method is invoked on a resource from a read only resource manager, an exception is thrown.
      Specified by:
      createFile in interface IResource
      Returns:
      boolean indicating if the resource was actually created.
    • createFolder

      public boolean createFolder()
      Description copied from interface: IResource
      This method may be used to create the resource as folder. This method is only applicable for resources that have been requested through the getRelative method, and that do not yet exist. The method returns a boolean indicating if the resource folder was actually created. When this method is invoked on a resource from a read only resource manager, an exception is thrown.
      Specified by:
      createFolder in interface IResource
      Returns:
      boolean indicating if the resource folder was actually created.
    • getInfo

      public IResourceInfo getInfo()
      Description copied from interface: IResource
      This method returns an object containing information about the resource. The information object may be used to determine if the resource actually exists, if it is read only, etc...
      Specified by:
      getInfo in interface IResource
      Returns:
      Object containing information about the resource.
    • getRelative

      public IResource getRelative(String path)
      Description copied from interface: IResource
      This method can be used to retrieve a resource relative to the current resource from the same resource manager. The returned resource may not yet exist. This method is only supported for resources of the type 'folder'.
      Specified by:
      getRelative in interface IResource
      Parameters:
      path - relative path to current protocol and location
      Returns:
      A resource object
    • exists

      public boolean exists()
      Description copied from interface: IResourceInfo
      This method can be used to determine if the resource is available.
      Specified by:
      exists in interface IResourceInfo
      Returns:
      boolean indicating if the resource is available.
    • getName

      public String getName()
      Description copied from interface: IResourceInfo
      This method returns the name of the resource.
      Specified by:
      getName in interface IResourceInfo
      Returns:
      the name of the resource.
    • getURI

      public URI getURI()
      Description copied from interface: IResourceInfo
      This method returns a Uniform Resource Identifier object for the resource.
      Specified by:
      getURI in interface IResourceInfo
      Returns:
      Uniform Resource Identifier object for the resource.
    • isFile

      public boolean isFile()
      Description copied from interface: IResourceInfo
      This method returns a boolean indicating if the resource represents a file.
      Specified by:
      isFile in interface IResourceInfo
      Returns:
      a boolean indicating if the resource represents a file.
    • isFolder

      public boolean isFolder()
      Description copied from interface: IResourceInfo
      This method returns a boolean indicating if the resource represents a folder.
      Specified by:
      isFolder in interface IResourceInfo
      Returns:
      a boolean indicating if the resource represents a folder.
    • isReadOnly

      public boolean isReadOnly()
      Description copied from interface: IResourceInfo
      This method can be used to determine if the resource is read-only. When this method returns true, the asOutputStream and asWriter methods of the resource won't be available.
      Specified by:
      isReadOnly in interface IResourceInfo
      Returns:
      boolean indicating if the resource is read-only.
    • lastModified

      public DateValue lastModified()
      Description copied from interface: IResourceInfo
      This method returns the last modification date value for the resource.
      Specified by:
      lastModified in interface IResourceInfo
      Returns:
      The last modification date, will return DateValue.UNKNOWN when no modification date could be determined.