com.octo.captcha.service.captchastore
Interface CaptchaStore

All Known Implementing Classes:
FastHashMapCaptchaStore, JBossCacheCaptchaStore, MapCaptchaStore

public interface CaptchaStore

Provides a way to temporally store captchas with a unique key


Method Summary
 void cleanAndShutdown()
          Called by the service in order to clean and shutdown the store.
 void empty()
          Empty the store
 Captcha getCaptcha(java.lang.String id)
          Retrieve the captcha for this key from the store.
 java.util.Collection getKeys()
          Return all the contained keys
 java.util.Locale getLocale(java.lang.String id)
          Retrieve the locale for this key from the store.
 int getSize()
          get the size of this store
 boolean hasCaptcha(java.lang.String id)
          Check if a captcha is stored for this id
 void initAndStart()
          Called by the service in order to initialize and start the Store.
 boolean removeCaptcha(java.lang.String id)
          Remove the captcha with the provided id as key.
 void storeCaptcha(java.lang.String id, Captcha captcha)
          Deprecated. in order to implement the by locale generation, use the storeCaptcha(String, com.octo.captcha.Captcha, java.util.Locale)
 void storeCaptcha(java.lang.String id, Captcha captcha, java.util.Locale locale)
          Store the captcha with the provided id as key.
 

Method Detail

hasCaptcha

boolean hasCaptcha(java.lang.String id)
Check if a captcha is stored for this id

Returns:
true if a captcha for this id is stored, false otherwise

storeCaptcha

void storeCaptcha(java.lang.String id,
                  Captcha captcha)
                  throws CaptchaServiceException
Deprecated. in order to implement the by locale generation, use the storeCaptcha(String, com.octo.captcha.Captcha, java.util.Locale)

Store the captcha with the provided id as key. The key is assumed to be unique, so if the same key is used twice to store a captcha, the store will return an exception

Parameters:
id - the key
captcha - the captcha
Throws:
CaptchaServiceException - if the captcha already exists, or if an error occurs during storing routine.

storeCaptcha

void storeCaptcha(java.lang.String id,
                  Captcha captcha,
                  java.util.Locale locale)
                  throws CaptchaServiceException
Store the captcha with the provided id as key. The key is assumed to be unique, so if the same key is used twice to store a captcha, the store will return an exception

Parameters:
id - the key
captcha - the captcha
locale - the locale used that triggers the captcha generation
Throws:
CaptchaServiceException - if the captcha already exists, or if an error occurs during storing routine.

removeCaptcha

boolean removeCaptcha(java.lang.String id)
Remove the captcha with the provided id as key.

Parameters:
id - the key
Returns:
true if found, false otherwise
Throws:
CaptchaServiceException - if an error occurs during remove routine

getCaptcha

Captcha getCaptcha(java.lang.String id)
                   throws CaptchaServiceException
Retrieve the captcha for this key from the store.

Returns:
the captcha for this id, null if not found
Throws:
CaptchaServiceException - if an error occurs during retrieving routine.

getLocale

java.util.Locale getLocale(java.lang.String id)
                           throws CaptchaServiceException
Retrieve the locale for this key from the store.

Returns:
the locale for this id, null if not found
Throws:
CaptchaServiceException - if an error occurs during retrieving routine.

getSize

int getSize()
get the size of this store


getKeys

java.util.Collection getKeys()
Return all the contained keys


empty

void empty()
Empty the store


initAndStart

void initAndStart()
Called by the service in order to initialize and start the Store.


cleanAndShutdown

void cleanAndShutdown()
Called by the service in order to clean and shutdown the store.



Copyright 2003-2009 JCaptcha. All Rights Reserved.