Class HLC64

    • Constructor Summary

      Constructors 
      Constructor Description
      HLC64​(String cacheSaveDirectory)
      Initializes a 63-Bit (Long) Cache in the specified directory.
    • Method Summary

       
      Abstract Method for Calculating the Hash-Key used in Caching Files
      Modifier and Type Method Description
      Long computeCacheKey​(String codeTypeParam, boolean includeLineNumbers, byte styleNum, String sourceCodeAsString)
      Compute a Hash-Code for a given Source-File, and it's HiLiting Parameters
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HLC64

        🡇     🗕  🗗  🗖
        public HLC64​(java.lang.String cacheSaveDirectory)
        Initializes a 63-Bit (java.lang.Long) Cache in the specified directory. This will load the hashCodes table to memory from the file-system directory identified by String-Parameter 'cacheSaveDirectory'. An exception shall be thrown if this file is not found, or the specified directory doesn't exist.
        Parameters:
        cacheSaveDirectory - This constructor presumes that this cache has been used and visited before. This directory name should point to your local-cache of the 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 Error shall also throw. The chain-cause Throwable should be visible, and is included as the Throwable.getCause().
    • Method Detail

      • computeCacheKey

        🡅     🗕  🗗  🗖
        public java.lang.Long computeCacheKey​(java.lang.String codeTypeParam,
                                              boolean includeLineNumbers,
                                              byte styleNum,
                                              java.lang.String sourceCodeAsString)
        Description copied from class: AbstractHashCodeHLC
        Compute a Hash-Code for a given Source-File, and it's HiLiting Parameters
        Specified by:
        computeCacheKey in class AbstractHashCodeHLC<java.lang.Long>
        Parameters:
        codeTypeParam - The code type identifier (e.g., 'java', 'html', 'css') used to distinguish syntax rules.
        includeLineNumbers - A flag indicating whether line numbers are to be included in the highlighted HTML output.
        styleNum - A numeric style identifier used to determine which syntax color scheme should be applied.
        sourceCodeAsString - The unhighlighted source code text which is used for generating a "Hash Key" into the cache.
        Returns:
        A key which may be used for saving a file to disk.
        Code:
        Exact Method Body:
         final long FNV_PRIME = 0x100000001b3L;
         long hash = 0xcbf29ce484222325L;
            
         // Mix in codeTypeParam
         for (int i = 0; i < codeTypeParam.length(); i++) {
             hash ^= codeTypeParam.charAt(i);
             hash *= FNV_PRIME;
         }
            
         // Mix in includeLineNumbers
         hash ^= (includeLineNumbers ? 1 : 0);
         hash *= FNV_PRIME;
            
         // Mix in styleNum
         hash ^= styleNum;
         hash *= FNV_PRIME;
            
         // Mix in sourceCodeAsString
         for (int i = 0; i < sourceCodeAsString.length(); i++) {
             hash ^= sourceCodeAsString.charAt(i);
             hash *= FNV_PRIME;
         }
            
         return hash;