public class Converter
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.atomic.AtomicBoolean |
active
True, if thread is active, otherwise false.
|
private java.util.concurrent.locks.Lock |
entryLock
"Mutex" for the producer–consumer.
|
private java.util.concurrent.Semaphore |
inputAvailable
Semaphore for the existence of an input requirement (producer-consumer).
|
private java.io.File |
inputFile
Variable for input file.
|
private Database.DB_Messenger |
query
Variable for SQL query.
|
private IConversionResults |
ui
The user interface that this thread created.
|
Constructor and Description |
---|
Converter(IConversionResults ui)
Initializes instance attributes.
|
Modifier and Type | Method and Description |
---|---|
private void |
convert(byte[] buffer,
java.lang.StringBuilder json)
Converts the input byte buffer given by parameter into json which is saved
using the StringBuilder.
|
void |
end()
End of the thread run.
|
private byte[] |
getBytes(java.io.File file,
Database.DB_Messenger query)
Retrieve data from the file or database.
|
boolean |
getInput(java.util.concurrent.atomic.AtomicReference<java.io.File> inputFile,
java.util.concurrent.atomic.AtomicReference<Database.DB_Messenger> query)
Get a request to process the input.
|
void |
run() |
void |
setInput(java.io.File inputFile,
Database.DB_Messenger query)
Sets the input processing request.
|
activeCount, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, checkAccess, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private IConversionResults ui
private java.util.concurrent.atomic.AtomicBoolean active
private java.util.concurrent.locks.Lock entryLock
private java.util.concurrent.Semaphore inputAvailable
private java.io.File inputFile
private Database.DB_Messenger query
public Converter(IConversionResults ui)
ui
- instance of the Window or CLI.public void end()
public void setInput(java.io.File inputFile, Database.DB_Messenger query)
inputFile
- input file.query
- SQL query.public boolean getInput(java.util.concurrent.atomic.AtomicReference<java.io.File> inputFile, java.util.concurrent.atomic.AtomicReference<Database.DB_Messenger> query)
inputFile
- variable for input file "passing by reference".query
- variable for SQL query "passing by reference".public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
private byte[] getBytes(java.io.File file, Database.DB_Messenger query) throws java.lang.Exception
file
- input file.query
- input query.java.lang.Exception
- if an error occurs while retrieving data.private void convert(byte[] buffer, java.lang.StringBuilder json) throws java.lang.Exception
buffer
- byte array buffer for input data of serialized object.json
- StringBuilder to which will be saved the json result.java.lang.Exception
- if an error occurred during deserialization.