KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > web > FormErrorList


1 /*
2  * $Id: FormErrorList.java,v 1.1 2004/11/24 18:36:22 michelson Exp $
3  *
4  * Copyright (c) 2004 j2biz Group, http://www.j2biz.com
5  * Koeln / Duesseldorf , Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.web;
27
28 import java.util.ArrayList JavaDoc;
29 import java.util.List JavaDoc;
30
31 /**
32  * @author michelson
33  * @version $$
34  * @since 0.1
35  *
36  *
37  */

38 public class FormErrorList {
39
40     private ArrayList JavaDoc errors = new ArrayList JavaDoc();
41
42     public FormErrorList() {
43
44     }
45
46     public void add(FormError error) {
47         errors.add(error);
48     }
49
50     public FormError get(int index) {
51         return (FormError) errors.get(index);
52     }
53
54     public List JavaDoc get(String JavaDoc key) {
55         ArrayList JavaDoc list = new ArrayList JavaDoc();
56         for (int i = 0; i < errors.size(); i++) {
57             FormError e = (FormError) errors.get(i);
58             if (key.equals(e.getKey())) {
59                 list.add(e);
60             }
61         }
62         return list;
63     }
64
65     public List JavaDoc getAll() {
66         return errors;
67     }
68
69     public int size() {
70         return errors.size();
71     }
72
73     public boolean containsErrorsForKey(String JavaDoc key) {
74         return (get(key).size() > 0);
75     }
76
77 }
Popular Tags