XBRLAPI

A Java API for XBRL


org.xbrlapi.cache
Interface Cache

All Superinterfaces:
Serializable
All Known Implementing Classes:
CacheImpl

public interface Cache
extends Serializable

Author:
Geoffrey Shuetrim (geoff@galexy.net)

Method Summary
 void copyToCache(URI originalURI, File cacheFile)
          Copy the original resource into the local cache if the resource exists and is able to be copied into the cache and does nothing otherwise.
 void copyToCache(URI originalURI, String xml)
          Copy the original resource into the local cache.
 List<URI> getAllUris(URI uri)
          This method provides a useful means of getting a list of the URIs for all documents in a branch of the cache.
 File getCacheFile(URI uri)
          Gets the cache file for an original URI.
 URI getCacheURI(URI uri)
          TODO Modify to use the java.net.URIEncoder and java.net.URIDecoder classes.
 URI getOriginalURI(File file)
           
 URI getOriginalURI(URI uri)
           
 boolean isCacheURI(URI uri)
          Tests if a URI is a URI of a resource in the local cache.
 void purge(URI uri)
          Delete a resource from the cache.
 

Method Detail

isCacheURI

boolean isCacheURI(URI uri)
                   throws XBRLException
Tests if a URI is a URI of a resource in the local cache.

Parameters:
uri - The URI to be tested to see if it identifies a resource in the local cache.
Returns:
true if and only if the URI is for a resource in the local cache.
Throws:
XBRLException - if the URI status as a cache URI cannot be determined.

getCacheURI

URI getCacheURI(URI uri)
                throws XBRLException
TODO Modify to use the java.net.URIEncoder and java.net.URIDecoder classes. Adds the resource at the original URI to the cache if it is not already cached.

Parameters:
uri - The URI to be translated into a cache URI (if necessary).
Returns:
the cache URI corresponding to the provided URI.
Throws:
XBRLException - if the resource cannot be cached.

getOriginalURI

URI getOriginalURI(URI uri)
                   throws XBRLException
Parameters:
uri - The URI to be translated into an original URI (if necessary).
Returns:
the original (non-cache) URI corresponding to the provided URI.
Throws:
XBRLException - if a caching operation fails or if a cache file cannot be translated into a URI.

getOriginalURI

URI getOriginalURI(File file)
                   throws XBRLException
Parameters:
file - The file to be translated into an original URI (if necessary).
Returns:
the original (non-cache) URI corresponding to the provided file. If the file is not a cache file then the returned URI is just a URI version of the file. Otherwise, the original URI is derived from the file.
Throws:
XBRLException - if a caching operation fails or if a cache file cannot be translated into a URI.

getCacheFile

File getCacheFile(URI uri)
                  throws XBRLException
Gets the cache file for an original URI.

Parameters:
uri - The URI to obtain the cache file for,
Returns:
The File for the provided URI.
Throws:
XBRLException - if the URI cannot be translated into a location in the local cache.

copyToCache

void copyToCache(URI originalURI,
                 File cacheFile)
Copy the original resource into the local cache if the resource exists and is able to be copied into the cache and does nothing otherwise. Thus, caching fails silently.

Parameters:
originalURI - the URI of the resource to be copied into the cache.
cacheFile - The file to be used to store the cache version of the resource.

copyToCache

void copyToCache(URI originalURI,
                 String xml)
                 throws XBRLException
Copy the original resource into the local cache.

Parameters:
originalURI - the URI of the resource to be copied into the cache.
xml - The XML to store in the cache at the given URI.
Throws:
XBRLException - if the resource cannot be copied into the local cache.

purge

void purge(URI uri)
           throws XBRLException
Delete a resource from the cache.

Parameters:
uri - The original or the cache URI.
Throws:
XBRLException - if the cache file cannot be determined.

getAllUris

List<URI> getAllUris(URI uri)
                     throws XBRLException
This method provides a useful means of getting a list of the URIs for all documents in a branch of the cache. This can be very helpful when trying to reload the cached documents into a data store.

Parameters:
uri - A URI that corresponds to a directory or file in the cache.
Returns:
the list of original URIs for the files in the specified directory (or the directory containing the specified file) and the original URIs for all of the files in descendant directories of that directory.
Throws:
XBRLException

Get Java XBRL API implementation at SourceForge.net.