Interface DataResource

  • All Superinterfaces:
    Resource
    All Known Implementing Classes:
    ConfigurableDataResource_impl, DataResource_impl

    public interface DataResource
    extends Resource
    DataResource is a simple resource that provides access to data. All DataResources will implement the getInputStream() method to provide access to their data.

    DataResources may optionally implement getUrl(), which would return the URL where the data is located. This may be necessary for some applications, but it is strongly recommended the getInputStream() be used whenever possible, because accessing the data directly via the URL does not allow the ResourceManager to assist in caching or sharing of data.

    • Method Detail

      • getInputStream

        InputStream getInputStream()
                            throws IOException
        Gets an InputStream to the data. It is the caller's responsibility to close this input stream when finished with it.
        Returns:
        an InputStream to the data
        Throws:
        IOException - if an I/O error occurred when trying to open the stream
      • getUri

        URI getUri()
        Gets the URI of the data. In general, this method will return a URI that is equivalent to the URL returned by getUrl(). However, in the case where getUrl() returns null (indicating no URL available), this method may still return a URI. This can be the case if the URI does not use a standard protocol such as http or file.
        Returns:
        The URI of the data
      • getUrl

        URL getUrl()
        Gets the URL where the data is stored. This method may return null if there is no appropriate URL (for example if the data is stored in a relational database). It is recommended that the getInputStream() method be used whenever possible - see the class comment for more information.
        Returns:
        the URL where the data is stored, or null if this is not available.
      • equals

        boolean equals​(Object aObj)
        Determines if this DataResource is equal to another DataResource. It is important that DataResource implementations override this method appropriately, because the ResourceManager can make use of this method to determine when cached data can be reused. Two DataResources that are equal according to this method will be considered to provide access to the same data; therefore, a common cache can be used.
        Overrides:
        equals in class Object
        Parameters:
        aObj - the object to compare to
        Returns:
        true if and only if aObj is a DataResource and provides access to the same data as this object.
      • hashCode

        int hashCode()
        Gest the hash code for this DataResource. As always, if the equals(Object) method is overridden, this method should also be overridden. Two objects that are equal must have the same hash code.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code for this object