public final class MultithreadedClassifier extends LocalClassifierBase
ClassifierExecutor
. This class handles the classification of files, strings and buffers on multiple threads.Constructor and Description |
---|
MultithreadedClassifier(MultithreadedClassificationListener listener)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelAndDestroy()
Cancels the classifier and all classifications in progress.
|
void |
classifyBuffer(byte[] buffer,
java.lang.String fileName,
int priority)
Executes a buffer classification.
|
void |
classifyFile(java.io.File file,
int priority)
Executes a file classification.
|
void |
classifyString(java.lang.String string,
int priority)
Executes a string classification.
|
void |
destroy()
Destroys the classifier.
|
int |
getActiveThreadCount()
Retrieves the number of threads that are currently running.
|
java.util.List<ClassificationFuture> |
getClassificationFutureList() |
int |
getMaxThreadCount()
Retrieves the maximum number of threads that the classifier can use.
|
int |
getThreadExpiryTimeout()
Retrieves the expiry timeout of a thread.
|
void |
loadSettings(java.io.File settingsFile)
Loads the settings from a file.
|
void |
loadSettings(java.lang.String settings)
Loads the settings from a string.
|
void |
setMaxThreadCount(int maxThreads)
Sets the maximum number of threads that the classifier can use.
|
void |
setThreadExpiryTimeout(int millis)
Sets the expiry timeout of a thread.
|
void |
waitForFinished()
Blocks the current thread until the classifier finishes all classifications.
|
isLicenseLoaded, isSettingsLoaded, loadLicense, loadLicense
public MultithreadedClassifier(MultithreadedClassificationListener listener)
listener
- The MultithreadedClassificationListener
which receives the results.public void classifyFile(java.io.File file, int priority) throws InvalidArgumentException, java.io.FileNotFoundException, InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, java.io.IOException, UnsupportedMimeTypeException, NoKnownDataException, java.lang.Exception
MultithreadedClassificationListener
passed in the constructor.file
- The file to be classified.priority
- The priority of the file in the queue. Files with high priority will be classified before the files with low priority.InvalidArgumentException
- If file parameter is null.java.io.FileNotFoundException
- If the file does not exist.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.java.io.IOException
- If there was an error reading the file.UnsupportedMimeTypeException
- If this type of file cannot be classified.NoKnownDataException
- If this file cannot be classified.java.lang.Exception
- Generic exception.public void classifyString(java.lang.String string, int priority) throws InvalidArgumentException, InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoKnownDataException, java.lang.Exception
MultithreadedClassificationListener
passed in the constructor.string
- The string to be classified.priority
- The priority of the string in the queue. Strings with high priority will be classified before the strings with low priority.InvalidArgumentException
- If string parameter is null or empty.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoKnownDataException
- If this file cannot be classified.java.lang.Exception
- Generic exception.public void classifyBuffer(byte[] buffer, java.lang.String fileName, int priority) throws InvalidLicenseException, LicenseExpiredException, LicenseException, SettingsException, NoKnownDataException, java.lang.Exception
MultithreadedClassificationListener
passed in the constructor.buffer
- The buffer to be classified.fileName
- If you classify the buffer from a file, specify the file name.priority
- The priority of the buffer in the queue. Buffers with high priority will be classified before the buffers with low priority.InvalidLicenseException
- If the license is invalid.LicenseExpiredException
- If the license is expired.LicenseException
- If the license is not loaded.SettingsException
- If the settings are invalid or not loaded.NoKnownDataException
- If this file cannot be classified.java.lang.Exception
- Generic exception.public void loadSettings(java.io.File settingsFile) throws InvalidArgumentException, SettingsException, java.io.FileNotFoundException, java.io.IOException, java.lang.Exception
settingsFile
- The file containing the settings.InvalidArgumentException
- If settingsFile argument is null.SettingsException
- If there was an error loading the settings.java.io.FileNotFoundException
- If the settings file does not exist.java.io.IOException
- If there was an error reading the file.java.lang.Exception
- Generic exception.public void loadSettings(java.lang.String settings) throws InvalidArgumentException, SettingsException, java.lang.Exception
settings
- The string containing the settings.InvalidArgumentException
- If settings argument is null or empty.SettingsException
- If there was an error loading the settings.java.lang.Exception
- Generic exception.public void setMaxThreadCount(int maxThreads)
maxThreads
- The maximum number of threads.public int getMaxThreadCount()
public void setThreadExpiryTimeout(int millis)
millis
- The expiry timeout of a thread in milliseconds.public int getThreadExpiryTimeout()
public int getActiveThreadCount()
public void waitForFinished()
public void cancelAndDestroy()
MultithreadedClassifier
will be destroyed and cannot be used again. This automatically destroys the classifier, so destroy()
method is not needed to be called after this.public void destroy()
public java.util.List<ClassificationFuture> getClassificationFutureList()