org.apache.jetspeed.cache.disk
Class DiskCacheUtils

java.lang.Object
  extended byorg.apache.jetspeed.cache.disk.DiskCacheUtils

public class DiskCacheUtils
extends java.lang.Object

Misc utils for managing the disk cache.

This tries to separate URLs into three categories:

Version:
$Id: DiskCacheUtils.java,v 1.20 2004/02/23 02:45:29 jford Exp $
Author:
Kevin A. Burton
See Also:
DiskCache

Field Summary
static java.lang.String[] VALID_PROTOCOLS
          Used to determine if a given URL should be cached.
 
Constructor Summary
DiskCacheUtils()
           
 
Method Summary
static java.io.File getFile(DiskCache instance, java.lang.String url)
          Given a URL, determine what the filename would be within the cache.
static java.lang.String getFileURL(DiskCache instance, java.lang.String url)
          Given a url and an disk cache instance, determine what the correct URL for this cache entry for the remote URL would be.
static java.lang.String getLocalURL(java.lang.String virtual)
          Given a virtual URL, resolve it to a local URL: Ex: /test.xml -> http://localhost:80/test.xml
static java.lang.String getVirtual(java.lang.String url)
          Give an full url: http://www.cnn.com/test just return the virutal portion: /test
static boolean isCacheable(java.lang.String url)
          Return true if the given URL should be cached or not.
static boolean isCached(DiskCache instance, java.lang.String url)
          Return true if this url is in the cache.
static boolean isCached(java.lang.String url)
           
static boolean isLocal(java.lang.String url)
          Return true if this URL is on the local server.
static boolean isRemote(java.lang.String url)
          Return true if this URL is NOT on the local server.
static boolean isVirtual(java.lang.String url)
          Return true if this URL is virtual.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALID_PROTOCOLS

public static final java.lang.String[] VALID_PROTOCOLS
Used to determine if a given URL should be cached. This prevents people from trying to cache documents that aren't supported. http and ftp should fit almost any situation.

Constructor Detail

DiskCacheUtils

public DiskCacheUtils()
Method Detail

getVirtual

public static java.lang.String getVirtual(java.lang.String url)
Give an full url: http://www.cnn.com/test just return the virutal portion: /test


getLocalURL

public static java.lang.String getLocalURL(java.lang.String virtual)
Given a virtual URL, resolve it to a local URL: Ex: /test.xml -> http://localhost:80/test.xml


isVirtual

public static boolean isVirtual(java.lang.String url)
Return true if this URL is virtual. EX: /tmp/test.xml


isLocal

public static boolean isLocal(java.lang.String url)
Return true if this URL is on the local server.


isRemote

public static boolean isRemote(java.lang.String url)
Return true if this URL is NOT on the local server.


isCached

public static boolean isCached(DiskCache instance,
                               java.lang.String url)
Return true if this url is in the cache.

See Also:
DiskCache.isCached( String )

isCached

public static boolean isCached(java.lang.String url)
See Also:
isCached( DiskCache, String )

isCacheable

public static boolean isCacheable(java.lang.String url)
Return true if the given URL should be cached or not.


getFile

public static java.io.File getFile(DiskCache instance,
                                   java.lang.String url)
Given a URL, determine what the filename would be within the cache. Note that this doesn't return a URL just a path to where it would be stored locally.


getFileURL

public static java.lang.String getFileURL(DiskCache instance,
                                          java.lang.String url)
Given a url and an disk cache instance, determine what the correct URL for this cache entry for the remote URL would be.



Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.