Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask Class Referenceabstract

Inherits SwingWorker< TranslateTextTask.TranslateResult, Void >.

Inherited by org.sleuthkit.autopsy.contentviewers.TranslatablePanel.OnTranslation, and org.sleuthkit.autopsy.texttranslation.ui.TranslatedTextViewer.ExtractAndTranslateTextTask.

Classes

class  TranslateResult
 

Public Member Functions

 TranslateTextTask (boolean translateText, String fileDescriptor)
 
TranslateResult doInBackground () throws InterruptedException
 
void done ()
 

Protected Member Functions

void onErrorDisplay (String text, ComponentOrientation orientation, int font)
 
void onProgressDisplay (String text, ComponentOrientation orientation, int font)
 
abstract void onTextDisplay (String text, ComponentOrientation orientation, int font)
 
abstract String retrieveText () throws IOException, InterruptedException, IllegalStateException
 
String translate (String input) throws NoServiceProviderException, TranslationException
 

Private Member Functions

TranslateResult translateRetrievedText (String fileText) throws InterruptedException
 

Private Attributes

final String contentDescriptor
 
final boolean translateText
 

Static Private Attributes

static final Logger logger = Logger.getLogger(TranslatedTextViewer.class.getName())
 

Detailed Description

This is an abstract class for translating text and displaying to the user.

Definition at line 39 of file TranslateTextTask.java.

Constructor & Destructor Documentation

org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.TranslateTextTask ( boolean  translateText,
String  fileDescriptor 
)

This is the main constructor for the TranslateTextTask.

Parameters
translateTextwhether or not to translate text
fileDescriptorthe content descriptor for the item being translated (used for logging errors)

Definition at line 89 of file TranslateTextTask.java.

References org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translateText.

Member Function Documentation

TranslateResult org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.doInBackground ( ) throws InterruptedException
void org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.done ( )
void org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onErrorDisplay ( String  text,
ComponentOrientation  orientation,
int  font 
)
protected

When an error result is received, this method is called. This method can be overridden depending on the scenario but defaults to just displaying using onTextDisplay.

Parameters
textthe text of the error
orientationthe orientation for the error
fontthe font style of the error

Definition at line 130 of file TranslateTextTask.java.

References org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onTextDisplay().

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.done().

void org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onProgressDisplay ( String  text,
ComponentOrientation  orientation,
int  font 
)
protected

When a progress result is received, this method is called. This method can be overridden depending on the scenario, but defaults to just displaying using onTextDisplay.

Parameters
textthe text of the status update
orientationthe orientation for the status
fontthe font style of the status

Definition at line 118 of file TranslateTextTask.java.

References org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onTextDisplay().

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translateRetrievedText().

abstract void org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onTextDisplay ( String  text,
ComponentOrientation  orientation,
int  font 
)
abstractprotected

This method should be overridden when a translated text result is received.

Parameters
textthe text to display
orientationthe orientation of the text
fontthe font style (returns plain)

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.done(), org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onErrorDisplay(), and org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onProgressDisplay().

abstract String org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.retrieveText ( ) throws IOException, InterruptedException, IllegalStateException
abstractprotected

This method retrieves the original text content to be translated.

Returns
the original text content
Exceptions
IOException
InterruptedException
IllegalStateException

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.doInBackground().

String org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translate ( String  input) throws NoServiceProviderException, TranslationException
protected

This method passes the translation off to the translation service provider.

Parameters
inputtext to be translated
Returns
translated text or error message

Definition at line 238 of file TranslateTextTask.java.

References org.sleuthkit.autopsy.texttranslation.TextTranslationService.getInstance(), and org.sleuthkit.autopsy.texttranslation.TextTranslationService.translate().

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translateRetrievedText().

TranslateResult org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translateRetrievedText ( String  fileText) throws InterruptedException
private

This is the final step in the translation swing worker prior to being done(); translates the text if needed.

Parameters
fileTextthe text to translate
Returns
the translated text
Exceptions
InterruptedExceptionif operation is canclled, an interrupted exception is thrown

Definition at line 175 of file TranslateTextTask.java.

References org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.TranslateResult.error(), org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.onProgressDisplay(), org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.TranslateResult.success(), and org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translate().

Referenced by org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.doInBackground().

Member Data Documentation

final String org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.contentDescriptor
private

Definition at line 44 of file TranslateTextTask.java.

final Logger org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.logger = Logger.getLogger(TranslatedTextViewer.class.getName())
staticprivate

Definition at line 41 of file TranslateTextTask.java.

final boolean org.sleuthkit.autopsy.texttranslation.ui.TranslateTextTask.translateText
private

The documentation for this class was generated from the following file:

Copyright © 2012-2022 Basis Technology. Generated on: Mon Nov 28 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.