2ronwalf//The MIT License
2ronwalf//
2ronwalf// Copyright (c) 2004 Evren Sirin
2ronwalf//
2ronwalf// Permission is hereby granted, free of charge, to any person obtaining a copy
2ronwalf// of this software and associated documentation files (the "Software"), to
2ronwalf// deal in the Software without restriction, including without limitation the
2ronwalf// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
2ronwalf// sell copies of the Software, and to permit persons to whom the Software is
2ronwalf// furnished to do so, subject to the following conditions:
2ronwalf//
2ronwalf// The above copyright notice and this permission notice shall be included in
2ronwalf// all copies or substantial portions of the Software.
2ronwalf//
2ronwalf// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2ronwalf// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2ronwalf// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2ronwalf// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2ronwalf// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2ronwalf// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2ronwalf// IN THE SOFTWARE.
2ronwalf
2ronwalf/*
2ronwalf * Created on Dec 30, 2003
2ronwalf *
2ronwalf */
2ronwalfpackage org.mindswap.owl;
2ronwalf
2ronwalfimport java.io.File;
2ronwalfimport java.net.URI;
2ronwalf
2ronwalfimport org.xml.sax.InputSource;
2ronwalf
2ronwalf/**
2ronwalf *
2ronwalf *
2ronwalf *
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic interface OWLCache {
2ronwalf /**
2ronwalf * Forces the readers to use the cached copies of the files even if the remote
2ronwalf * file may be available. When the forcing of cache is enabled the reader will
2ronwalf * first check if the cached copy exists and then only try to use the remote file
2ronwalf * when there is no cached copy.
2ronwalf *
2ronwalf * @param b
2ronwalf */
2ronwalf public void setForced(boolean b);
2ronwalf
2ronwalf /**
2ronwalf * Returns if the using of cache is forced.
2ronwalf *
2ronwalf * @return
2ronwalf */
2ronwalf public boolean isForced();
2ronwalf
2ronwalf /**
2ronwalf * Sets the cache dir for the inference engine to find the cached files when a
2ronwalf * file cannot be downparseed from its original URL. The cache dir should include
2ronwalf * a file named service.idx. This index file is a text file where each line is in
2ronwalf * the format
2ronwalf * [service description url]=[local filename]
2ronwalf *
2ronwalf * The ':' characters in the url's should be escaped as "\:"
2ronwalf *
2ronwalf * @param dir sets the local cache directory. if null it forces not to use the cache.
2ronwalf * if the given dir or index file inthat dir does not exist then nothing is
2ronwalf * done
2ronwalf */
2ronwalf public void setLocalCacheDirectory(String dir);
2ronwalf
2ronwalf /**
2ronwalf * Returns the full path to the local cache directory as a string
2ronwalf * @return a String indicating the path to the local cache directory
2ronwalf */
2ronwalf public String getLocalCacheDirectory();
2ronwalf
2ronwalf
2ronwalf /**
2ronwalf * Returns the cached source for the given URI. Returns null if there isn't an entry in the
2ronwalf * cache for the given file or cached file is not found.
2ronwalf *
2ronwalf * @param fileURI
2ronwalf * @return
2ronwalf */
2ronwalf public InputSource getCachedFile(String fileURI);
2ronwalf
2ronwalf
2ronwalf /**
2ronwalf * Add a local file to be used as a cached copy for the given URI.
2ronwalf *
2ronwalf * @param fileURI URI for the remote file
2ronwalf * @param localFile File for the local cached copy
2ronwalf */
2ronwalf public void addCachedFile(String fileURI, File localFile);
2ronwalf
2ronwalf /**
2ronwalf * Attempt to update a cached file from remote site. The key can
2ronwalf * be retrieved from uri.
2ronwalf *
2ronwalf * <p><b>WARNING</b>: Default implementation will not do anything when this function is called but this
2ronwalf * behaviour can be overridden with a new OWLCache implementation that saves the remote file
2ronwalf * locally and calls the addCachedFile() function so subsequent read operations will use the
2ronwalf * local file.
2ronwalf *
2ronwalf * @param uri update the local cache by using the latest content from uri.
2ronwalf */
12daenzerorama public void updateCachedFile(URI uri);
2ronwalf
2ronwalf /**
2ronwalf * Saves the current status of the index file (service.idx) persistently.
2ronwalf * All changes performed during the running session by calls of
2ronwalf * <code>addCachedFile(String, File)</code> are stored.
2ronwalf *
2ronwalf * @see addCachedFile(String fileURI, File localFile)
2ronwalf */
2ronwalf public void updateIndexFile();
12daenzerorama
12daenzerorama public void removeCachedFile(URI uri, File localFile);
2ronwalf}