001package Torello.JavaDoc.SyntaxHiLite; 002 003import Torello.Java.StrPrint; 004import java.io.File; 005 006/** A 32-Bit Java-{@code Integer} implementation of a File-System Cache. */ 007public class HLC32 extends AbstractHashCodeHLC<Integer> 008{ 009 /** 010 * Initializes a 64-Bit (java.lang.Long) Cache in the specified directory. 011 * <!-- Content below this line was block copied from class 'AbstractHashCodeHLC' --> 012 * 013 * This will load the hashCodes table to memory from the file-system directory identified 014 * by {@code String}-Parameter {@code 'cacheSaveDirectory'}. An exception shall be thrown 015 * if this file is not found, or the specified directory doesn't exist. 016 * 017 * @param cacheSaveDirectory This constructor presumes that this cache has been used and 018 * visited before. This directory name should point to your local-cache of the 019 * {@code HiLite.ME} Server Code hilite past-operations. 020 * 021 * @throws CacheError This error will throw if the cache has not been instantiated, or 022 * is corrupted. If the specified directory does not exist, then this {@code Error} shall 023 * also throw. The chain-cause {@code Throwable} should be visible, and is included as the 024 * {@code Throwable.getCause()}. 025 */ 026 public HLC32(String cacheSaveDirectory) 027 { super(cacheSaveDirectory, Integer.class); } 028 029 public Integer computeCacheKey( 030 final String codeTypeParam, 031 final boolean includeLineNumbers, 032 final byte styleNum, 033 final String sourceCodeAsString 034 ) 035 { 036 return 037 codeTypeParam.hashCode() + 038 (includeLineNumbers ? 1 : 0) + 039 styleNum + 040 sourceCodeAsString.hashCode(); 041 } 042 043 044 // Implementation of abstract-parent method. 045 // All it does is convert a Hash-Code into a Directory name. 046 // NOTE: This method is package private 047 048 String getSubDirName(Integer hashCode) 049 { 050 final int absVal = (hashCode.intValue() < 0) 051 ? -hashCode.intValue() 052 : hashCode.intValue(); 053 054 return 055 this.cacheSaveDirectory + 056 StrPrint.zeroPad10e4(absVal % AbstractHashCodeHLC.NUM_DIRS) + File.separator; 057 } 058}