at.spardat.xma.boot.cache
Class FCResource

java.lang.Object
  extended byat.spardat.xma.boot.cache.FCResource
All Implemented Interfaces:
IFileCacheResource

public class FCResource
extends java.lang.Object
implements IFileCacheResource

class: FCResource ( File Cached Resource )

Describes an entry in the file-cache.


Field Summary
protected  byte[] buffer_
          byte array for buffered mode
protected  boolean debug
          extended readable file output
protected  java.io.File file_
          resource file
protected  java.net.URL location_
          the remote resource location
protected  PropertyFile properties_
          info-file about the cached file
 
Constructor Summary
protected FCResource(java.net.URL location, java.io.File file, boolean bmode, boolean debug)
           Create a FCResource for the resources specified as a remote URL.
 
Method Summary
 long getExpiration()
          Gets the expiration date of this resource.
 java.io.InputStream getInputStream()
          Gets an input stream from this resource
 long getLastModified()
          Last-Modified is the http-header value used to check, if a resource is still up to date.
 long getLastUpdated()
          Returns the time in the local system clock that the file was most recently checked for an update.
 java.net.URL getLocalRes()
          get an url to the local resource
 java.net.URL getLocation()
          Returns the remote location this entry caches.
 java.lang.String getProperty(java.lang.String key)
          Returns the value of the specified key, or null if the key does not exist.
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the value of the specified key, or the default value if the key does not exist.
 boolean isExpired()
          is this resource still up to date
protected  void loadBuffer()
          load data from resource file into memory buffer
 void setExpiration(long lExpires)
          Sets the expiration date of this resource.
 void setLastModified(long lastModified)
          Sets the value of the last modified header in the resource description file.
 void setLastUpdated(long updatedTime)
          Sets the time in the local system clock that the file was most recently checked for an update.
 void setProperty(java.lang.String string, long l)
          Sets the named property to the given value.
 java.lang.Object setProperty(java.lang.String key, java.lang.String value)
          Sets the value for the specified key.
protected  void store()
          Saves the current information for the cache entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

location_

protected java.net.URL location_
the remote resource location


properties_

protected PropertyFile properties_
info-file about the cached file


file_

protected java.io.File file_
resource file


buffer_

protected byte[] buffer_
byte array for buffered mode


debug

protected boolean debug
extended readable file output

Constructor Detail

FCResource

protected FCResource(java.net.URL location,
                     java.io.File file,
                     boolean bmode,
                     boolean debug)
              throws java.io.IOException

Create a FCResource for the resources specified as a remote URL.

it is protected, because a resource must not be created by others than the FileCache

If the file does not exist, it will not be created.

Parameters:
location - the remote resource location
file - the resource file
bmode - buffer mode
Throws:
java.io.IOException - containing the filename
java.lang.IllegalArgumentException - the file must exist already
Method Detail

loadBuffer

protected void loadBuffer()
                   throws java.io.IOException
load data from resource file into memory buffer

Returns:
void
Throws:
java.io.IOException - containing the filename

getLocation

public java.net.URL getLocation()
Returns the remote location this entry caches.

Specified by:
getLocation in interface IFileCacheResource

store

protected void store()
              throws java.io.IOException
Saves the current information for the cache entry.

Throws:
java.io.IOException - containing the filename

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: IFileCacheResource
Gets an input stream from this resource

Specified by:
getInputStream in interface IFileCacheResource
Returns:
InputStream
Throws:
java.io.IOException - containing the filename
See Also:
IFileCacheResource

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the value of the specified key, or null if the key does not exist.

Specified by:
getProperty in interface IFileCacheResource
Parameters:
key - key to look for

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Returns the value of the specified key, or the default value if the key does not exist.

Specified by:
getProperty in interface IFileCacheResource

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.String value)
Sets the value for the specified key.

Specified by:
setProperty in interface IFileCacheResource
Returns:
the previous value

getLastUpdated

public long getLastUpdated()
Returns the time in the local system clock that the file was most recently checked for an update.

Specified by:
getLastUpdated in interface IFileCacheResource
Returns:
long last update timestamp

setLastUpdated

public void setLastUpdated(long updatedTime)
Sets the time in the local system clock that the file was most recently checked for an update.


getLastModified

public long getLastModified()
Description copied from interface: IFileCacheResource
Last-Modified is the http-header value used to check, if a resource is still up to date.

Specified by:
getLastModified in interface IFileCacheResource
Returns:
long last modified date

setLastModified

public void setLastModified(long lastModified)
Sets the value of the last modified header in the resource description file.

Parameters:
lastModified - in milliseconds since 1.1.1970

setExpiration

public void setExpiration(long lExpires)
Description copied from interface: IFileCacheResource
Sets the expiration date of this resource.

Specified by:
setExpiration in interface IFileCacheResource
Parameters:
lExpires - expiration date/time
Returns:
void

getExpiration

public long getExpiration()
Description copied from interface: IFileCacheResource
Gets the expiration date of this resource.

Specified by:
getExpiration in interface IFileCacheResource
Returns:
the expiration date in milliseconds since 1.1.1970

setProperty

public void setProperty(java.lang.String string,
                        long l)
Description copied from interface: IFileCacheResource
Sets the named property to the given value.

Specified by:
setProperty in interface IFileCacheResource
Parameters:
string - name of the property
l - of the property

getLocalRes

public java.net.URL getLocalRes()
Description copied from interface: IFileCacheResource
get an url to the local resource

Specified by:
getLocalRes in interface IFileCacheResource

isExpired

public boolean isExpired()
Description copied from interface: IFileCacheResource
is this resource still up to date

Specified by:
isExpired in interface IFileCacheResource
Returns:
true if it is already expired