cz.vity.freerapid.plugins.webclient.hoster
Class CaptchaSupport

java.lang.Object
  extended by cz.vity.freerapid.plugins.webclient.hoster.CaptchaSupport

public class CaptchaSupport
extends Object

Class that help to manage working with CAPTCHA in plugins.

Author:
Ladislav Vitasek

Constructor Summary
CaptchaSupport(HttpDownloadClient client, DialogSupport dialogSupport)
          Constructor
 
Method Summary
 String askForCaptcha(BufferedImage image)
          Shows default simple input dialog for getting input from user.
 String getCaptcha(String url)
          Shows default simple input dialog for getting input from user.
 BufferedImage getCaptchaImage(String url)
          Method downloads image from given URL.
 BufferedImage loadCaptcha(InputStream inputStream)
          Method creates image from given data input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptchaSupport

public CaptchaSupport(HttpDownloadClient client,
                      DialogSupport dialogSupport)
Constructor

Parameters:
client - current HTTP connection manager
dialogSupport - support for showing simple dialogs to user
Method Detail

askForCaptcha

public String askForCaptcha(BufferedImage image)
                     throws Exception
Shows default simple input dialog for getting input from user.

Parameters:
image - CAPTCHA image to show user
Returns:
returns string given from user - returns null if user cancelled dialog; method can return empty string
Throws:
Exception - if something went wrong - thread interruption
See Also:
DialogSupport.askForCaptcha(java.awt.image.BufferedImage)

getCaptcha

public String getCaptcha(String url)
                  throws FailedToLoadCaptchaPictureException
Shows default simple input dialog for getting input from user. Method loads CAPTCHA image and show it to user.

Parameters:
url - CAPTCHA image url
Returns:
returns string given from user - returns null if user cancelled dialog; method can return empty string
Throws:
FailedToLoadCaptchaPictureException - if http operation failed to load remote image

getCaptchaImage

public BufferedImage getCaptchaImage(String url)
                              throws FailedToLoadCaptchaPictureException
Method downloads image from given URL. Usually used to load CAPTCHA image for CAPTCHA recognition (OCR).

Parameters:
url - CAPTCHA image url
Returns:
returns instance of loaded image
Throws:
FailedToLoadCaptchaPictureException - if http operation failed to load remote image

loadCaptcha

public BufferedImage loadCaptcha(InputStream inputStream)
                          throws FailedToLoadCaptchaPictureException
Method creates image from given data input stream.

Parameters:
inputStream - data input stream
Returns:
instance of loaded image
Throws:
FailedToLoadCaptchaPictureException - if reading from input stream failed to load image
NullPointerException - if given input stream is null