|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ca.commons.cbutil.CBCache
This class creates a cache directory called 'temp' where temporary files are stored. Currently it works for audio, jpegPhoto and odDocumentDOC attributes. The audio are stored in a sub dir called 'audio'. It also contains methods for decreasing the cache size, cleaning (or emptying the cache and sorting the temporary files according to their last modified date.
| Nested Class Summary | |
static class |
CBCache.FileComparator
This Comparator compares two Files by their lastModified() date. |
| Constructor Summary | |
CBCache()
|
|
| Method Summary | |
static void |
cleanCache()
Cleans the cache of all temporary entries by deleting them. |
static void |
cleanCache(java.lang.String currentDN)
Cleans the cache of entries that start with the dn of the entry being modified. |
static void |
createAudioCache(java.lang.String currentDN,
javax.naming.directory.Attributes entry,
java.lang.String type,
int size)
Creates an audio cache directory named 'temp/audio' and adds temporary files to it currently naming them (for example) with the hash of their 'DN + a unique number + .wav'. |
static void |
createCache(java.lang.String currentDN,
javax.naming.directory.Attributes entry,
java.lang.String type,
int size)
Creates a cache directory named 'temp' and adds temporary files to it currently naming them (for example) with the hash of their 'DN + a unique number + .jpg'. |
static void |
decreaseAudioCacheSize()
Decreases the size of the audio cache (usually if the cache contains 100 or more temporary files), by deleting the oldest files until there is only 50 temporary files left in the cache. |
static void |
decreaseCacheSize()
Decreases the size of the cache (usually if the cache contains 100 or more temporary files), by deleting the oldest files until there is only 50 temporary files left in the cache. |
static void |
doAudioCache(java.lang.String currentDN,
byte[] bytes)
Creates the audio temporary files. |
static void |
doNormalCache(java.lang.String currentDN,
byte[] bytes,
java.lang.String extension)
Does the actual writing of the cache files. |
static java.io.File |
getAudioCacheDirectory()
Returns the directory that is being used for the audio caching. |
static java.lang.String |
getAudioDirPath()
Returns the absolute path of the audio temp directory. |
static java.io.File |
getCacheDirectory()
Returns the directory that is being used for the caching. |
static java.lang.String |
getDirPath()
Returns the absolute path of the temp directory. |
static java.io.File[] |
sortFiles(java.io.File[] files)
Sorts an array of files in order of lastModified (oldest to newest). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CBCache()
| Method Detail |
public static void createCache(java.lang.String currentDN,
javax.naming.directory.Attributes entry,
java.lang.String type,
int size)
currentDN - the dn of the entry being modified (will be used as part of the name of the temp file i.e: cn=Al,o=DEMOCORP,c=AU).entry - the actual entry that is being displayed.type - the attribute type for example: audio or jpegPhoto.size - the size of the number of specific attribute values this entry contains (i.e. 3 jpegPhoto attributes).
public static void createAudioCache(java.lang.String currentDN,
javax.naming.directory.Attributes entry,
java.lang.String type,
int size)
currentDN - the dn of the entry being modified (will be used as part of the name of the temp file i.e: cn=Al,o=DEMOCORP,c=AU).entry - the actual entry that is being displayed.type - the attribute type for example: audio or jpegPhoto.size - the size of the number of specific attribute values this entry contains (i.e. 3 audio attributes).
public static void doNormalCache(java.lang.String currentDN,
byte[] bytes,
java.lang.String extension)
currentDN - the dn of the entry being modified (will be used as part of the name of the temp file i.e: cn=Al,o=DEMOCORP,c=AU).bytes - the byte[] of the audio attribute.extension - the extensio of the cache file (currently .doc, .jpg).
public static void doAudioCache(java.lang.String currentDN,
byte[] bytes)
cn=Al,o=DEMOCORP,c=AU9.wav
This method can determine the following audio file types:
.wav .mp3 .rmi .ram .aiff .mid .au .stm .voc .xm .s3m .it
if an audio file type is unknown the temporary file is still created but with no extension.
currentDN - the dn of the entry being modified (will be used as part of the name of the temp file i.e: cn=Al,o=DEMOCORP,c=AU).bytes - the byte[] of the audio attribute.public static java.io.File[] sortFiles(java.io.File[] files)
files - the array of files to be sorted.
public static java.io.File getCacheDirectory()
public static java.io.File getAudioCacheDirectory()
public static void decreaseCacheSize()
public static void decreaseAudioCacheSize()
public static java.lang.String getDirPath()
public static java.lang.String getAudioDirPath()
public static void cleanCache(java.lang.String currentDN)
currentDN - the dn of the entry being modified.public static void cleanCache()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||