it.tidalwave.geo.viewer.spi.ResourceCache Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* forceTen - open source geography
* Copyright (C) 2007-2012 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://forceten.tidalwave.it
* SCM: https://bitbucket.org/tidalwave/forceten-src
*
**********************************************************************************************************************/
package it.tidalwave.geo.viewer.spi;
import javax.annotation.Nonnull;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URI;
import it.tidalwave.util.NotFoundException;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public interface ResourceCache
{
/*******************************************************************************************************************
*
* Finds a cached image for the resource at the given URI.
*
* @param uri the resource URI
* @return the cached image
* @throws NotFoundException if the image is not in cache
* @throws IOException if an I/O error occurs
*
******************************************************************************************************************/
@Nonnull
public BufferedImage findImage (@Nonnull URI uri)
throws IOException, NotFoundException;
/*******************************************************************************************************************
*
* Stores an image into the cache.
*
* @param uri the resource URI
* @param buffer the raw buffer of the image
*
******************************************************************************************************************/
public void storeImage (@Nonnull URI uri, @Nonnull byte[] buffer);
/*******************************************************************************************************************
*
* Returns the URI of a cached resource corresponding to the given URI. This is useful for code that prefers to
* perform by itself the loading of the resource.
*
* @param uri the resource URI
* @return the URI of the cached resource
* @throws NotFoundException if the resource is not in cache
*
******************************************************************************************************************/
@Nonnull
public URI findCachedResourceUri (@Nonnull URI uri)
throws NotFoundException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy