public class QueueFile
extends java.lang.Object
The cache is composed by
File to know the length of the file on disc.
RandomAccessFile for reading and writing
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
fileName
The name of the file
|
java.lang.Integer |
key
The key identifying this file.
|
| Constructor and Description |
|---|
QueueFile(java.lang.String fName,
java.lang.Integer key,
java.io.RandomAccessFile rf,
java.io.File f,
java.lang.String tstampStrTag)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release all the resources (for instance it releases the random
file).
|
java.io.File |
getFile()
An helper methods that returns the
File. |
long |
getFileLength()
Return the size of the file
|
long |
getNumOfStringsInFile() |
java.lang.String |
maxDate() |
java.lang.String |
minDate() |
java.lang.String |
readFromFile(QueueEntry entry)
Read a string from the file
|
void |
setReadingMode(boolean reading)
Set the reading mode of the file.
|
void |
setWritingMode(boolean writing)
Set the writing mode of the file.
|
QueueEntry |
writeOnFile(java.lang.String str,
java.lang.Integer key)
Write the passed string in the file.
|
public final java.lang.String fileName
public final java.lang.Integer key
The key is stored only to perform run-time tests of correctness.
public QueueFile(java.lang.String fName,
java.lang.Integer key,
java.io.RandomAccessFile rf,
java.io.File f,
java.lang.String tstampStrTag)
throws java.io.IOException
fName - The name of the filekey - The key of this entryrf - The RandomAccessFile used for I/Of - The File used to get the lengthtstampStrTag - The string to find the timestamp in each pushed stringjava.io.IOException - In case of error writing in the fileQueueFile(String fName, Integer key)}public java.io.File getFile()
throws java.io.FileNotFoundException
File.
As soon as raFile is not null, file is not null too.
A new File is built if file is null
otherwise the method returns a reference to file.
java.io.FileNotFoundException - If the file does not existpublic void close()
public long getFileLength()
public QueueEntry writeOnFile(java.lang.String str, java.lang.Integer key) throws java.io.IOException, StringQueueException
str - The string to write in the filejava.io.IOException - In case of error while performing I/OStringQueueException - In case of error reading the date of the log from strpublic java.lang.String readFromFile(QueueEntry entry) throws java.io.IOException
entry - The cache entry to saying how to read the entryjava.io.IOExceptionpublic void setReadingMode(boolean reading)
reading - true if the file is used for readingpublic void setWritingMode(boolean writing)
writing - true if the file is used for writingpublic java.lang.String minDate()
public long getNumOfStringsInFile()
public java.lang.String maxDate()