Package Torello.JavaDoc.SyntaxHiLite
Class HiLiteCache64
- java.lang.Object
-
- Torello.JavaDoc.SyntaxHiLite.HiLiteCache64
-
public class HiLiteCache64 extends java.lang.Object
A caching-system class that allows this tool to efficiently bypass calls to the server when an exact-copy of the hilited source-code already exists inside the cache.
Hi-Lited Source-Code:- View Here: Torello/JavaDoc/SyntaxHiLite/HiLiteCache64.java
- Open New Browser-Tab: Torello/JavaDoc/SyntaxHiLite/HiLiteCache64.java
File Size: 12,664 Bytes Line Count: 310 '\n' Characters Found
-
-
Constructor Summary
Constructors Constructor HiLiteCache64(String cacheSaveDirectory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method static HiLiteCache64
initializeOrClear(String cacheSaveDirectory, StorageWriter sw)
static void
main(String[] argv)
void
persistMasterHashToDisk()
void
rebuildMasterHashCache()
int
totalNumber()
long
totalSize()
-
-
-
Constructor Detail
-
HiLiteCache64
public HiLiteCache64(java.lang.String cacheSaveDirectory) throws CacheError
This will load the hashCodes table to memory from the file-system directory identified byString
-Parameter'cacheSaveDirectory'
. An exception shall be thrown if this file is not found.- Parameters:
cacheSaveDirectory
- This constructor presumes that this cache has been used and visited before. This directory name should point to your local-cache of theHiLite.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 thisError
shall also throw. The chain-causeThrowable
should be visible, and is included as theThrowable.getCause()
.
-
-
Method Detail
-
totalSize
public long totalSize()
Inform the user how much space (in bytes) is used by thisCache
.- Returns:
- The number of bytes being used on the file-system by this
Cache
. - Code:
- Exact Method Body:
return FileNode .createRoot(this.cacheSaveDirectory) .loadTree() .getDirTotalContentsSize();
-
totalNumber
public int totalNumber()
Count how many files and directories are contained in thisCache
.- Returns:
- The total number of files and sub-directories in the
Cache
directory. - Code:
- Exact Method Body:
return FileNode .createRoot(this.cacheSaveDirectory) .loadTree() .count();
-
persistMasterHashToDisk
public void persistMasterHashToDisk() throws CacheError
This will save the hash-codeTreeSet<Integer>
to disk. The Master Hash-Code List just keeps a record of the hashcodes of everyString
that was hilited by the Hiliter (and therefore saved inside the Cache). This method will save that JavaTreeSet
of Hash-Codes to disk.- Throws:
CacheError
- ThisError
will throw if there is a problem writing the master cache-hash to disk. The chain-causeThrowable
should be visible, and is included as theThrowable.getCause()
- Code:
- Exact Method Body:
CacheMethodsInternal64.persistMasterHashToDisk(this);
-
rebuildMasterHashCache
public void rebuildMasterHashCache()
Will write this method soon. It currently is not written.
TO DO:
* This is supposed to be for "Error Recovery". Fortunately, an error has never really happend to me, and even if it did... Just deleting the whole thing and rebuilding the Cache by running the HiLiter on all of the files seems smarter/safer anyway. This has perpetually been on the "To Do List" for 5 years now... I think it more prudent to remind people, just delete and start over is probably smarter, it your Cache directory got messed up (for whatever reason - but mine never has anyway!)- Code:
- Exact Method Body:
throw new ToDoException();
-
initializeOrClear
public static HiLiteCache64 initializeOrClear (java.lang.String cacheSaveDirectory, StorageWriter sw) throws CacheError
This will initialize a cache-file in the file-system directory identified by parameterString cacheSaveDirectory
. If the directory specified does not exist, aCacheError
is thrown. Any old cache files will be removed. To attempt to preserve old cache-files, call methodinitializeOrRepair(String, StorageWriter)
OrClear: If the directory structure provided to this initialize method is not empty, the its entire contents shall be erased by a call to (Below)
Java Line of Code:
FileTransfer.deleteFilesRecursive (FileNode.createRoot(cacheSaveDirectory).loadTree(), sw);
- Parameters:
cacheSaveDirectory
- This constructor presumes that this cache has been used and visited before. This directory name should point to your local-cache ofHiLite.ME
Server Code hilite past-operations.sw
- This receives log-writes from the call toFileTransfer.deleteFilesRecursive(Torello.Java.FileNode, Torello.Java.FileNodeFilter, Torello.Java.FileNodeFilter, java.lang.Appendable)
which clears the files currently in the cache. This parameter may be null, and if it is, output-text will be shunted.- Throws:
CacheError
- This exception will be throw if there are errors deleting any old-cache files currently in the directory; or if there is any error creating the new master hash-cache file. The chain-causeThrowable
should be visible, and is included as theThrowable.getCause()
.- Code:
- Exact Method Body:
return CacheMethodsInternal64.initializeOrClear(cacheSaveDirectory, sw);
-
main
public static void main(java.lang.String[] argv)
- Code:
- Exact Method Body:
if (argv.length != 1) { System.out.println( "argv.length != 1\n" + "argv[0] must contain the Cache-Directory Name.\n" ); System.exit(1); } java.io.File f = new java.io.File(argv[0]); if ((! f.exists()) || (! f.isDirectory())) { System.out.println( "argv[0] must contain the Cache-Directory Name.\n" + "Unfortunately: ((! f.exists()) || (! f.isDirectory()))\n" ); System.exit(1); } initializeOrClear(argv[0], new StorageWriter());
-
-