|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.leeds.ccg.andyt.projects.genesis.utilities.ErrorHandler
public abstract class ErrorHandler
An abstract class
to be extended by classes that are required to
handle runtime errors such as java.lang.OutOfMemroyError
.
Constructor Summary | |
---|---|
ErrorHandler()
|
Method Summary | |
---|---|
void |
clearMemoryReserve()
Clears memoryReserve by setting it to null and calling the garbage collector. |
java.io.File |
getDirectory()
|
protected int[] |
getMemoryReserve()
|
protected java.util.HashMap |
getNumberOfCachesSwappedAsFilesHashMap()
|
void |
initMemoryReserve()
Initialises memoryReserve as an array of size 3000000. |
void |
initMemoryReserve(int size)
Initialises this.memoryReserve as an int[] of length size. |
protected java.lang.Object |
loadObject(java.io.File aFile)
Loads an Object from aFile File . |
protected java.lang.Object |
loadObject(java.io.ObjectInputStream aObjectInputStream)
Loads an Object from aObjectInputStream ObjectInputStream . |
protected void |
setDirectory(java.io.File directory)
Sets this.directory to directory . |
protected void |
setMemoryReserve(int[] memoryReserve)
Sets this.memoryReserve to memoryReserve . |
protected void |
setNumberOfCachesSwappedAsFilesHashMap(java.util.HashMap numberOfCachesSwappedAsFilesHashMap)
Sets this.numberOfCachesSwappedAsFilesHashMap to numberOfCachesSwappedAsFilesHashMap . |
protected java.io.File |
swapToFile(java.util.HashMap aHashMap)
If aHashMap.isEmpty() this does nothing and returns null. |
protected java.io.File |
swapToFile(java.util.HashSet _HashSet)
If aHashSetSerializable.isEmpty() this does nothing and returns null. |
protected java.io.File |
writeToFile()
A method to write this instance to a File located in the directory returned by getDirectory(). |
java.io.File |
writeToFile(boolean handleOutOfMemoryError)
A method to write this instance to Files located in this.directory. |
protected void |
writeToFile(java.lang.Object objectToWrite,
java.io.File aFileToWriteTo)
A method to write this instance to a File located in the directory returned by getDirectory(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ErrorHandler()
Method Detail |
---|
public final void initMemoryReserve(int size)
this.memoryReserve
as an int[]
of length size.
size
- The length that this.memoryReserve
is initialised as.public final void initMemoryReserve()
this.directory
public final void clearMemoryReserve()
protected java.io.File swapToFile(java.util.HashSet _HashSet)
aHashSetSerializable.isEmpty()
this does nothing and returns null.
Otherwise aHashSetSerializable
is swapped to a File
which is returned.
protected java.io.File swapToFile(java.util.HashMap aHashMap)
aHashMap.isEmpty()
this does nothing and returns null.
Otherwise aHashMap
is swapped to a File
which is returned.
public final java.io.File writeToFile(boolean handleOutOfMemoryError) throws java.io.IOException
handleOutOfMemoryError
- If true then OutOfMemoryErrors are caught, swap operations are initiated,
then the method is re-called.
If false then OutOfMemoryErrors are caught and thrown.
java.io.IOException
protected java.io.File writeToFile() throws java.io.IOException
java.io.IOException
protected void writeToFile(java.lang.Object objectToWrite, java.io.File aFileToWriteTo) throws java.io.IOException
objectToWrite
- The object to be written
java.io.IOException
protected final java.lang.Object loadObject(java.io.File aFile)
Object
from aFile File
.
aFile
- The File
from which the Object
Returns:Object
null
protected final java.lang.Object loadObject(java.io.ObjectInputStream aObjectInputStream)
Object
from aObjectInputStream ObjectInputStream
.
aObjectInputStream
- The ObjectInputStream
from which the Object
Returns:Object
null
public final java.io.File getDirectory()
this.directory
protected final void setDirectory(java.io.File directory)
this.directory
to directory
.
N.B. No checks are done on directory
to ensure it is viable for use.
protected final int[] getMemoryReserve()
this.memoryReserve
protected final void setMemoryReserve(int[] memoryReserve)
this.memoryReserve
to memoryReserve
.
protected final java.util.HashMap getNumberOfCachesSwappedAsFilesHashMap()
this.numberOfCachesSwappedAsFilesHashMap
protected final void setNumberOfCachesSwappedAsFilesHashMap(java.util.HashMap numberOfCachesSwappedAsFilesHashMap)
this.numberOfCachesSwappedAsFilesHashMap
to numberOfCachesSwappedAsFilesHashMap
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |