public class CacheImpl extends java.lang.Object implements Cache
Constructor and Description |
---|
CacheImpl(java.io.File cacheRoot)
Constructs a URI translator for usage with a local cache location.
|
CacheImpl(java.io.File cacheRoot,
java.util.HashMap<java.net.URI,java.net.URI> uriMap)
Constructs a URI translator for usage with a local cache location.
|
Modifier and Type | Method and Description |
---|---|
void |
copyToCache(java.net.URI originalURI,
java.io.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(java.net.URI originalURI,
java.lang.String xml)
Copy the original resource into the local cache.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<java.net.URI> |
getAllUris(java.net.URI uri)
This method provides a useful means of getting a list of the URIs for
all documents in a branch of the cache.
|
java.io.File |
getCacheFile(java.net.URI uri)
Gets the cache file for an original URI.
|
java.io.File |
getCacheRoot() |
java.net.URI |
getCacheURI(java.net.URI uri)
TODO Modify to use the java.net.URIEncoder and java.net.URIDecoder classes.
|
java.net.URI |
getOriginalURI(java.io.File file) |
java.net.URI |
getOriginalURI(java.net.URI uri) |
int |
hashCode() |
boolean |
isCacheURI(java.net.URI uri)
Tests if a URI is a URI of a resource in the local cache.
|
void |
purge(java.net.URI uri)
Delete a resource from the cache.
|
public CacheImpl(java.io.File cacheRoot) throws XBRLException
cacheRoot
- The root directory for the cache.XBRLException
- if the cacheRoot is null or does not exist or cannot be
written to or read from.public CacheImpl(java.io.File cacheRoot, java.util.HashMap<java.net.URI,java.net.URI> uriMap) throws XBRLException
cacheRoot
- uriMap
- The hash map from original URIs to local URIs.XBRLException
- if the cacheRoot is null or does not existpublic boolean isCacheURI(java.net.URI uri) throws XBRLException
Cache
isCacheURI
in interface Cache
uri
- The URI to be tested to see if it identifies a
resource in the local cache.XBRLException
- if the URI status as a cache URI cannot be determined.Cache.isCacheURI(java.net.URI)
public java.net.URI getCacheURI(java.net.URI uri) throws XBRLException
Cache
getCacheURI
in interface Cache
uri
- The URI to be translated into a cache URI (if necessary).XBRLException
- if the resource cannot be cached.Cache.getCacheURI(java.net.URI)
public java.net.URI getOriginalURI(java.net.URI uri) throws XBRLException
getOriginalURI
in interface Cache
uri
- The URI to be translated into an original URI (if necessary).XBRLException
- if a caching operation fails
or if a cache file cannot be translated into a URI.Cache.getOriginalURI(java.net.URI)
public java.net.URI getOriginalURI(java.io.File file) throws XBRLException
getOriginalURI
in interface Cache
file
- The file to be translated into an original URI (if necessary).XBRLException
- if a caching operation fails
or if a cache file cannot be translated into a URI.Cache.getOriginalURI(File)
public java.io.File getCacheFile(java.net.URI uri) throws XBRLException
Cache
getCacheFile
in interface Cache
uri
- The URI to obtain the cache file for,XBRLException
- if the URI cannot be translated into
a location in the local cache.Cache.getCacheFile(java.net.URI)
public void copyToCache(java.net.URI originalURI, java.io.File cacheFile)
Cache
copyToCache
in interface Cache
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.Cache.copyToCache(java.net.URI, java.io.File)
public void copyToCache(java.net.URI originalURI, java.lang.String xml) throws XBRLException
Cache
copyToCache
in interface Cache
originalURI
- the URI of the resource to be copied into the cache.xml
- The XML to store in the cache at the given URI.XBRLException
- if the resource cannot be copied into the local cache.Cache.copyToCache(java.net.URI, java.lang.String)
public void purge(java.net.URI uri) throws XBRLException
Cache
purge
in interface Cache
uri
- The original or the cache URI.XBRLException
- if the cache file cannot be determined.Cache.purge(java.net.URI)
public java.io.File getCacheRoot()
public java.util.List<java.net.URI> getAllUris(java.net.URI uri) throws XBRLException
Cache
getAllUris
in interface Cache
uri
- A URI that corresponds to a directory or file in the cache.XBRLException
Cache.getAllUris(URI)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)