Class HLC64

    • 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
        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;