View Javadoc

1   /*
2    * JCaptcha, the open source java framework for captcha definition and integration
3    * Copyright (c)  2007 jcaptcha.net. All Rights Reserved.
4    * See the LICENSE.txt file distributed with this package.
5    */
6   
7   /*
8    * jcaptcha, the open source java framework for captcha definition and integration
9    * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
10   * See the LICENSE.txt file distributed with this package.
11   */
12  
13  /*
14   * jcaptcha, the open source java framework for captcha definition and integration
15   * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
16   * See the LICENSE.txt file distributed with this package.
17   */
18  package com.octo.captcha.engine.bufferedengine.buffer;
19  
20  import com.octo.captcha.Captcha;
21  
22  import java.util.Collection;
23  import java.util.Locale;
24  import java.util.NoSuchElementException;
25  
26  /***
27   * CaptchaBuffer is the interface to describe buffers of captchas.
28   *
29   * @author Benoit Doumas
30   */
31  public interface CaptchaBuffer {
32      /***
33       * remove a captcha from the buffer
34       *
35       * @return a captcha
36       *
37       * @throws NoSuchElementException if there is no captcha throw NoSuchElementException
38       */
39      public Captcha removeCaptcha() throws NoSuchElementException;
40  
41      /***
42       * remove a captcha from the buffer corresponding to the locale
43       *
44       * @param locale The locale the catcha to remove
45       *
46       * @return a captcha correponding to the locale
47       *
48       * @throws NoSuchElementException if there is no captcha throw NoSuchElementException
49       */
50      public Captcha removeCaptcha(Locale locale) throws NoSuchElementException;
51  
52      /***
53       * Remove a precise number of captcha
54       *
55       * @param number The number of captchas to remove
56       *
57       * @return a collection of captchas
58       */
59      public Collection removeCaptcha(int number);
60  
61      /***
62       * Remove a precise number of captcha with a locale
63       *
64       * @param number The number of captchas to remove
65       * @param locale The locale of the removed captchas
66       *
67       * @return a collection of captchas
68       */
69      public Collection removeCaptcha(int number, Locale locale);
70  
71      /***
72       * Put a captcha with default laocale
73       */
74      public void putCaptcha(Captcha captcha);
75  
76      /***
77       * Put a captcha with a locale
78       *
79       * @param captcha The captcha to add
80       * @param locale  the locale of the captcha
81       */
82      public void putCaptcha(Captcha captcha, Locale locale);
83  
84      /***
85       * Put a collection of captchas with the default locale
86       *
87       * @param captchas The captchas to add
88       */
89      public void putAllCaptcha(Collection captchas);
90  
91      /***
92       * Put a collection of captchas with his locale
93       *
94       * @param captchas The captchas to add
95       * @param locale   The locale of the captchas
96       */
97      public void putAllCaptcha(Collection captchas, Locale locale);
98  
99      /***
100      * Get the size of the buffer for all locales
101      *
102      * @return The size of the buffer
103      */
104     public int size();
105 
106     /***
107      * Get the size of the buffer for a locale
108      *
109      * @param locale the locale to get the size
110      *
111      * @return The size of the buffer
112      */
113     public int size(Locale locale);
114 
115     /***
116      * Release all the ressources and close the buffer.
117      */
118     public void dispose();
119 
120     /***
121      * Clear the buffer from all locale
122      */
123     public void clear();
124 
125     /***
126      * Get all the locales used
127      */
128     public Collection getLocales();
129 }