|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openstreetmap.josm.io.CacheCustomContent<T>
T - a Throwable that may be thrown during updateData(),
use RuntimeException if no exception must be handled.public abstract class CacheCustomContent<T extends java.lang.Throwable>
Use this class if you want to cache and store a single file that gets updated regularly. Unless you flush() it will be kept in memory. If you want to cache a lot of data and/or files, use CacheFiles
| Field Summary | |
|---|---|
private byte[] |
data
Where the data will be stored |
private java.lang.String |
ident
The ident that identifies the stored file. |
static int |
INTERVAL_ALWAYS
Common intervals |
static int |
INTERVAL_DAILY
|
static int |
INTERVAL_HOURLY
|
static int |
INTERVAL_MONTHLY
|
static int |
INTERVAL_NEVER
|
static int |
INTERVAL_WEEKLY
|
private java.io.File |
path
The (file-)path where the data will be stored |
private int |
updateInterval
How often to update the cached version |
| Constructor Summary | |
|---|---|
CacheCustomContent(java.lang.String ident,
int updateInterval)
Initializes the class. |
|
| Method Summary | |
|---|---|
void |
flushData()
Flushes the data from memory. |
byte[] |
getData()
Returns the data without performing any updates |
java.lang.String |
getDataString()
Returns the data without performing any updates |
protected boolean |
isCacheValid()
This function serves as a comfort hook to perform additional checks if the cache is valid |
private void |
loadFromDisk()
Tries to load the data using the given ident from disk. |
private void |
saveToDisk()
Stores the data to disk |
protected abstract byte[] |
updateData()
This function will be executed when an update is required. |
byte[] |
updateForce()
Executes an update regardless of updateInterval |
java.lang.String |
updateForceString()
Executes an update regardless of updateInterval |
byte[] |
updateIfRequired()
Updates data if required |
java.lang.String |
updateIfRequiredString()
Updates data if required |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int INTERVAL_ALWAYS
public static final int INTERVAL_HOURLY
public static final int INTERVAL_DAILY
public static final int INTERVAL_WEEKLY
public static final int INTERVAL_MONTHLY
public static final int INTERVAL_NEVER
private byte[] data
private final java.lang.String ident
private final java.io.File path
private final int updateInterval
| Constructor Detail |
|---|
public CacheCustomContent(java.lang.String ident,
int updateInterval)
ident - updateInterval - | Method Detail |
|---|
protected abstract byte[] updateData()
throws T extends java.lang.Throwable
T extends java.lang.Throwableprotected boolean isCacheValid()
public byte[] updateIfRequired()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
public java.lang.String updateIfRequiredString()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
public byte[] updateForce()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
public java.lang.String updateForceString()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
public byte[] getData()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
public java.lang.String getDataString()
throws T extends java.lang.Throwable
T extends java.lang.Throwable
private void loadFromDisk()
throws T extends java.lang.Throwable
T extends java.lang.Throwableprivate void saveToDisk()
public void flushData()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||