com.octo.captcha.engine.bufferedengine.buffer
Class DatabaseCaptchaBuffer

java.lang.Object
  extended by com.octo.captcha.engine.bufferedengine.buffer.DatabaseCaptchaBuffer
All Implemented Interfaces:
CaptchaBuffer

public class DatabaseCaptchaBuffer
extends java.lang.Object
implements CaptchaBuffer

A database Captcha Buffer.

The database should have the following structure : default Column Name , type


Constructor Summary
DatabaseCaptchaBuffer(javax.sql.DataSource datasource)
           
DatabaseCaptchaBuffer(javax.sql.DataSource datasource, java.lang.String table)
           
DatabaseCaptchaBuffer(javax.sql.DataSource datasource, java.lang.String table, java.lang.String timeMillisColumn, java.lang.String hashCodeColumn, java.lang.String captchaColumn, java.lang.String localeColumn)
           
 
Method Summary
 void clear()
          Clear the buffer from all locale
 void dispose()
          Release all the ressources and close the buffer.
 java.util.Collection getLocales()
          Get all the locales used
 void putAllCaptcha(java.util.Collection captchas)
          Put a collection of captchas with the default locale
 void putAllCaptcha(java.util.Collection captchas, java.util.Locale locale)
          Put a collection of captchas with his locale
 void putCaptcha(Captcha captcha)
          Put a captcha with default locale
 void putCaptcha(Captcha captcha, java.util.Locale locale)
          Put a captcha with a locale
 Captcha removeCaptcha()
          remove a captcha from the buffer
 java.util.Collection removeCaptcha(int number)
          Remove a precise number of captcha
 java.util.Collection removeCaptcha(int number, java.util.Locale locale)
          Remove a precise number of captcha with a locale
 Captcha removeCaptcha(java.util.Locale locale)
          remove a captcha from the buffer corresponding to the locale
 int size()
          Get the size of the buffer for all locales
 int size(java.util.Locale locale)
          Get the size of the buffer for a locale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseCaptchaBuffer

public DatabaseCaptchaBuffer(javax.sql.DataSource datasource)

DatabaseCaptchaBuffer

public DatabaseCaptchaBuffer(javax.sql.DataSource datasource,
                             java.lang.String table)

DatabaseCaptchaBuffer

public DatabaseCaptchaBuffer(javax.sql.DataSource datasource,
                             java.lang.String table,
                             java.lang.String timeMillisColumn,
                             java.lang.String hashCodeColumn,
                             java.lang.String captchaColumn,
                             java.lang.String localeColumn)
Method Detail

removeCaptcha

public Captcha removeCaptcha()
                      throws java.util.NoSuchElementException
remove a captcha from the buffer

Specified by:
removeCaptcha in interface CaptchaBuffer
Returns:
a captcha
Throws:
java.util.NoSuchElementException - if there is no captcha throw NoSuchElementException

removeCaptcha

public Captcha removeCaptcha(java.util.Locale locale)
                      throws java.util.NoSuchElementException
remove a captcha from the buffer corresponding to the locale

Specified by:
removeCaptcha in interface CaptchaBuffer
Parameters:
locale - The locale the catcha to remove
Returns:
a captcha correponding to the locale
Throws:
java.util.NoSuchElementException - if there is no captcha throw NoSuchElementException

removeCaptcha

public java.util.Collection removeCaptcha(int number)
Remove a precise number of captcha

Specified by:
removeCaptcha in interface CaptchaBuffer
Parameters:
number - The number of captchas to remove
Returns:
a collection of captchas

removeCaptcha

public java.util.Collection removeCaptcha(int number,
                                          java.util.Locale locale)
Remove a precise number of captcha with a locale

Specified by:
removeCaptcha in interface CaptchaBuffer
Parameters:
number - The number of captchas to remove
locale - The locale of the removed captchas
Returns:
a collection of captchas

putCaptcha

public void putCaptcha(Captcha captcha)
Put a captcha with default locale

Specified by:
putCaptcha in interface CaptchaBuffer

putCaptcha

public void putCaptcha(Captcha captcha,
                       java.util.Locale locale)
Put a captcha with a locale

Specified by:
putCaptcha in interface CaptchaBuffer
Parameters:
captcha - The captcha to add
locale - the locale of the captcha

putAllCaptcha

public void putAllCaptcha(java.util.Collection captchas)
Put a collection of captchas with the default locale

Specified by:
putAllCaptcha in interface CaptchaBuffer
Parameters:
captchas - The captchas to add

putAllCaptcha

public void putAllCaptcha(java.util.Collection captchas,
                          java.util.Locale locale)
Put a collection of captchas with his locale

Specified by:
putAllCaptcha in interface CaptchaBuffer
Parameters:
captchas - The captchas to add
locale - The locale of the captchas

size

public int size()
Get the size of the buffer for all locales

Specified by:
size in interface CaptchaBuffer
Returns:
The size of the buffer

size

public int size(java.util.Locale locale)
Get the size of the buffer for a locale

Specified by:
size in interface CaptchaBuffer
Parameters:
locale - the locale to get the size
Returns:
The size of the buffer

dispose

public void dispose()
Release all the ressources and close the buffer.

Specified by:
dispose in interface CaptchaBuffer

clear

public void clear()
Clear the buffer from all locale

Specified by:
clear in interface CaptchaBuffer

getLocales

public java.util.Collection getLocales()
Get all the locales used

Specified by:
getLocales in interface CaptchaBuffer


Copyright 2003-2009 JCaptcha. All Rights Reserved.