org.mindswap.pellet.utils
Class Cache

java.lang.Object
  extended by org.mindswap.pellet.utils.Cache

public class Cache
extends java.lang.Object

Maps remote URI's to local cached files so {#link org.mindswap.pellet.jena.ModelReader# ModelReader} can use cached files when needed. Mappings can be added one by one or read from an index file. If the use of cache is forced then local file will be used by the reader even if the remote file is available. Otherwise, local files will only be used when the remote file cannot be read.

Author:
Evren Sirin

Constructor Summary
Cache()
           
 
Method Summary
 void addCachedFile(java.lang.String fileURI, java.lang.String localFile)
          Add a local file to be used as a cached copy for the given URI.
 java.io.File getCachedFile(java.lang.String fileURI)
          Returns the cached File object for the given URI.
 boolean isForced()
          Returns if the using of cache is forced.
 void setForced(boolean b)
          Forces the readers to use the cached copies of the files even if the remote file may be available.
 void setLocalCacheDirectory(java.lang.String dir)
          Sets the cache dir for the inference engine to find the cached files when a file cannot be downparseed from its original URL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Method Detail

setForced

public void setForced(boolean b)
Forces the readers to use the cached copies of the files even if the remote file may be available. When the forcing of cache is enabled the reader will first check if the cached copy exists and then only try to use the remote file when there is no cached copy.

Parameters:
b -

isForced

public boolean isForced()
Returns if the using of cache is forced.

Returns:

setLocalCacheDirectory

public void setLocalCacheDirectory(java.lang.String dir)
Sets the cache dir for the inference engine to find the cached files when a file cannot be downparseed from its original URL. The cache dir should include a file named service.idx. This index file is a text file where each line is in the format [service description url]=[local filename] The ':' characters in the url's should be escaped as "\:"

Parameters:
dir - sets the local cache directory. if null it forces not to use the cache. if the given dir or index file inthat dir does not exist then nothing is done

getCachedFile

public java.io.File getCachedFile(java.lang.String fileURI)
Returns the cached File object for the given URI. Returns null if there isn't an entry in the cache for the given file or cached file is not found.

Parameters:
fileURI -
Returns:

addCachedFile

public void addCachedFile(java.lang.String fileURI,
                          java.lang.String localFile)
Add a local file to be used as a cached copy for the given URI.

Parameters:
fileURI - URI for the remote file
localFile - Path for the local cached copy


Copyright © 2007-2009 Natalya Keberle. All Rights Reserved.