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

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

public class MemoryCaptchaBuffer
extends java.lang.Object
implements CaptchaBuffer

Simple implmentation of a memory captcha buffer with HashedMap from commons collection.


Field Summary
protected  HashedMap buffers
           
 
Constructor Summary
MemoryCaptchaBuffer()
           
 
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 laocale
 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
 

Field Detail

buffers

protected HashedMap buffers
Constructor Detail

MemoryCaptchaBuffer

public MemoryCaptchaBuffer()
Method Detail

removeCaptcha

public Captcha removeCaptcha(java.util.Locale locale)
                      throws java.util.NoSuchElementException
Description copied from interface: CaptchaBuffer
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
See Also:
CaptchaBuffer.removeCaptcha(java.util.Locale)

removeCaptcha

public java.util.Collection removeCaptcha(int number,
                                          java.util.Locale locale)
Description copied from interface: CaptchaBuffer
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
See Also:
CaptchaBuffer.removeCaptcha(int, java.util.Locale)

removeCaptcha

public java.util.Collection removeCaptcha(int number)
Description copied from interface: CaptchaBuffer
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
See Also:
CaptchaBuffer.removeCaptcha(int)

removeCaptcha

public Captcha removeCaptcha()
                      throws java.util.NoSuchElementException
Description copied from interface: CaptchaBuffer
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

putCaptcha

public void putCaptcha(Captcha captcha,
                       java.util.Locale locale)
Description copied from interface: CaptchaBuffer
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,
                          java.util.Locale locale)
Description copied from interface: CaptchaBuffer
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
See Also:
CaptchaBuffer.putAllCaptcha(java.util.Collection)

size

public int size()
Description copied from interface: CaptchaBuffer
Get the size of the buffer for all locales

Specified by:
size in interface CaptchaBuffer
Returns:
The size of the buffer
See Also:
CaptchaBuffer.size()

size

public int size(java.util.Locale locale)
Description copied from interface: CaptchaBuffer
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
See Also:
CaptchaBuffer.size()

putCaptcha

public void putCaptcha(Captcha captcha)
Description copied from interface: CaptchaBuffer
Put a captcha with default laocale

Specified by:
putCaptcha in interface CaptchaBuffer
See Also:
CaptchaBuffer.putCaptcha(com.octo.captcha.Captcha)

putAllCaptcha

public void putAllCaptcha(java.util.Collection captchas)
Description copied from interface: CaptchaBuffer
Put a collection of captchas with the default locale

Specified by:
putAllCaptcha in interface CaptchaBuffer
Parameters:
captchas - The captchas to add
See Also:
CaptchaBuffer.putAllCaptcha(java.util.Collection)

dispose

public void dispose()
Description copied from interface: CaptchaBuffer
Release all the ressources and close the buffer.

Specified by:
dispose in interface CaptchaBuffer
See Also:
CaptchaBuffer.dispose()

clear

public void clear()
Description copied from interface: CaptchaBuffer
Clear the buffer from all locale

Specified by:
clear in interface CaptchaBuffer
See Also:
CaptchaBuffer.clear()

getLocales

public java.util.Collection getLocales()
Description copied from interface: CaptchaBuffer
Get all the locales used

Specified by:
getLocales in interface CaptchaBuffer
See Also:
CaptchaBuffer.getLocales()


Copyright 2003-2009 JCaptcha. All Rights Reserved.