1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 | package Torello.JavaDoc.SyntaxHiLite;
import Torello.Java.StrPrint;
import java.io.File;
/** A 32-Bit Java-{@code Integer} implementation of a File-System Cache. */
public class HLC32 extends AbstractHashCodeHLC<Integer>
{
/**
* Initializes a 64-Bit (java.lang.Long) Cache in the specified directory.
* <!-- Content below this line was block copied from class 'AbstractHashCodeHLC' -->
*
* This will load the hashCodes table to memory from the file-system directory identified
* by {@code String}-Parameter {@code 'cacheSaveDirectory'}. An exception shall be thrown
* if this file is not found, or the specified directory doesn't exist.
*
* @param cacheSaveDirectory This constructor presumes that this cache has been used and
* visited before. This directory name should point to your local-cache of the
* {@code HiLite.ME} Server Code hilite past-operations.
*
* @throws CacheError This error will throw if the cache has not been instantiated, or
* is corrupted. If the specified directory does not exist, then this {@code Error} shall
* also throw. The chain-cause {@code Throwable} should be visible, and is included as the
* {@code Throwable.getCause()}.
*/
public HLC32(String cacheSaveDirectory)
{ super(cacheSaveDirectory, Integer.class); }
public Integer computeCacheKey(
final String codeTypeParam,
final boolean includeLineNumbers,
final byte styleNum,
final String sourceCodeAsString
)
{
return
codeTypeParam.hashCode() +
(includeLineNumbers ? 1 : 0) +
styleNum +
sourceCodeAsString.hashCode();
}
// Implementation of abstract-parent method.
// All it does is convert a Hash-Code into a Directory name.
// NOTE: This method is package private
String getSubDirName(Integer hashCode)
{
final int absVal = (hashCode.intValue() < 0)
? -hashCode.intValue()
: hashCode.intValue();
return
this.cacheSaveDirectory +
StrPrint.zeroPad10e4(absVal % AbstractHashCodeHLC.NUM_DIRS) + File.separator;
}
}
|