Class ConfigurableDataResource_impl

  • All Implemented Interfaces:
    DataResource, Resource

    public class ConfigurableDataResource_impl
    extends Resource_ImplBase
    implements DataResource
    A simple DataResource implementation that can read data from a file via a URL. There is an attribute for specifying the location of a local cache for a remote file, but this is not currently being used.
    • Field Detail

      • mUri

        private java.net.URI mUri
        URI of data.
      • mFileUrl

        private java.net.URL mFileUrl
        URL of file. This is formed from the URI, if possible.
    • Constructor Detail

      • ConfigurableDataResource_impl

        public ConfigurableDataResource_impl()
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Description copied from interface: DataResource
        Gets an InputStream to the data. It is the caller's responsibility to close this input stream when finished with it.
        Specified by:
        getInputStream in interface DataResource
        Returns:
        an InputStream to the data
        Throws:
        java.io.IOException - if an I/O error occurred when trying to open the stream
        See Also:
        DataResource.getInputStream()
      • getUri

        public java.net.URI getUri()
        Description copied from interface: DataResource
        Gets the URI of the data. In general, this method will return a URI that is equivalent to the URL returned by DataResource.getUrl(). However, in the case where DataResource.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.
        Specified by:
        getUri in interface DataResource
        Returns:
        The URI of the data
      • getUrl

        public java.net.URL getUrl()
        Description copied from interface: DataResource
        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 DataResource.getInputStream() method be used whenever possible - see the class comment for more information.
        Specified by:
        getUrl in interface DataResource
        Returns:
        the URL where the data is stored, or null if this is not available.
        See Also:
        DataResource.getUrl()
      • getLocalCache

        protected java.io.File getLocalCache()
        Gets the file name of the local cache for a remote resource file, if any. This is not currently supported; it always returns null.
        Returns:
        the local cache File
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: DataResource
        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.
        Specified by:
        equals in interface DataResource
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - 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.
        See Also:
        DataResource.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Description copied from interface: DataResource
        Gest the hash code for this DataResource. As always, if the DataResource.equals(Object) method is overridden, this method should also be overridden. Two objects that are equal must have the same hash code.
        Specified by:
        hashCode in interface DataResource
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code for this object
        See Also:
        DataResource.hashCode()