Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libTools / src / org / gvsig / tools / exception / ListBaseException.java @ 24064

History | View | Annotate | Download (5.08 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 */
26
package org.gvsig.tools.exception;
27

    
28
import java.util.ArrayList;
29
import java.util.Collection;
30
import java.util.Iterator;
31
import java.util.List;
32
import java.util.ListIterator;
33

    
34
/**
35
 * @author Equipo de desarrollo de gvSIG
36
 *
37
 */
38
public abstract class ListBaseException extends BaseException implements List{
39
        private List exceptions = new ArrayList();
40

    
41
        /* (non-Javadoc)
42
         * @see java.util.Collection#size()
43
         */
44
        public int size() {
45
                return this.exceptions.size();
46
        }
47

    
48
        /* (non-Javadoc)
49
         * @see java.util.Collection#isEmpty()
50
         */
51
        public boolean isEmpty() {
52
                return this.exceptions.isEmpty();
53
        }
54

    
55
        /* (non-Javadoc)
56
         * @see java.util.Collection#contains(java.lang.Object)
57
         */
58
        public boolean contains(Object arg0) {
59
                return this.exceptions.contains(arg0);
60
        }
61

    
62
        /* (non-Javadoc)
63
         * @see java.util.Collection#toArray()
64
         */
65
        public Object[] toArray() {
66
                return this.exceptions.toArray();
67
        }
68

    
69
        /**
70
         * @param arg0
71
         * @return
72
         */
73
        public Object[] toArray(Object[] arg0) {
74
                return this.exceptions.toArray(arg0);
75
        }
76

    
77
        /**
78
         * @param arg0
79
         * @return
80
         */
81
        public boolean add(Object arg0) {
82
                return this.exceptions.add(arg0);
83
        }
84

    
85
        /* (non-Javadoc)
86
         * @see java.util.Collection#remove(java.lang.Object)
87
         */
88
        public boolean remove(Object arg0) {
89
                return this.exceptions.remove(arg0);
90
        }
91

    
92
        /**
93
         * @param arg0
94
         * @return
95
         */
96
        public boolean containsAll(Collection arg0) {
97
                return this.exceptions.contains(arg0);
98
        }
99

    
100
        /**
101
         * @param arg0
102
         * @return
103
         */
104
        public boolean addAll(Collection arg0) {
105
                return this.exceptions.addAll(arg0);
106
        }
107

    
108
        /**
109
         * @param arg0
110
         * @param arg1
111
         * @return
112
         */
113
        public boolean addAll(int arg0, Collection arg1) {
114
                return this.exceptions.addAll(arg0, arg1);
115
        }
116

    
117
        /**
118
         * @param arg0
119
         * @return
120
         */
121
        public boolean removeAll(Collection arg0) {
122
                return this.exceptions.removeAll(arg0);
123
        }
124

    
125
        /**
126
         * @param arg0
127
         * @return
128
         */
129
        public boolean retainAll(Collection arg0) {
130
                return this.exceptions.retainAll(arg0);
131
        }
132

    
133
        /* (non-Javadoc)
134
         * @see java.util.Collection#clear()
135
         */
136
        public void clear() {
137
                this.exceptions.clear();
138
        }
139

    
140
        /* (non-Javadoc)
141
         * @see java.util.List#get(int)
142
         */
143
        public Object get(int arg0) {
144
                return this.exceptions.get(arg0);
145
        }
146

    
147
        /**
148
         * @param arg0
149
         * @param arg1
150
         * @return
151
         */
152
        public Object set(int arg0, Object arg1) {
153
                return this.exceptions.set(arg0, arg1);
154
        }
155

    
156
        /**
157
         * @param arg0
158
         * @param arg1
159
         */
160
        public void add(int arg0, Object arg1) {
161
                this.exceptions.add(arg0, arg1);
162
        }
163

    
164
        /* (non-Javadoc)
165
         * @see java.util.List#remove(int)
166
         */
167
        public Object remove(int arg0) {
168
                return this.exceptions.remove(arg0);
169
        }
170

    
171
        /* (non-Javadoc)
172
         * @see java.util.List#indexOf(java.lang.Object)
173
         */
174
        public int indexOf(Object arg0) {
175
                return this.exceptions.indexOf(arg0);
176
        }
177

    
178
        /* (non-Javadoc)
179
         * @see java.util.List#lastIndexOf(java.lang.Object)
180
         */
181
        public int lastIndexOf(Object arg0) {
182
                return this.exceptions.lastIndexOf(arg0);
183
        }
184

    
185
        /* (non-Javadoc)
186
         * @see java.util.List#listIterator()
187
         */
188
        public ListIterator listIterator() {
189
                return this.exceptions.listIterator();
190
        }
191

    
192
        /* (non-Javadoc)
193
         * @see java.util.List#listIterator(int)
194
         */
195
        public ListIterator listIterator(int arg0) {
196
                return this.exceptions.listIterator(arg0);
197
        }
198

    
199
        /* (non-Javadoc)
200
         * @see java.util.List#subList(int, int)
201
         */
202
        public List subList(int arg0, int arg1) {
203
                return this.exceptions.subList(arg0, arg1);
204
        }
205

    
206
        /* (non-Javadoc)
207
         * @see java.lang.Throwable#getMessage()
208
         */
209
        public String getMessage() {
210
                String msg = super.getMessage();
211
                Exception bex;
212
                Iterator iter=this.exceptions.iterator();
213
                while (iter.hasNext()) {
214
                        bex = (Exception) iter.next();
215
                        msg = msg + "\n  " + bex.getMessage();
216
                }
217
                return msg;
218
        }
219

    
220
        public String getLocalizedMessage(ExceptionTranslator exceptionTranslator,
221
                        int indent) {
222
                String msg = super.getLocalizedMessage(exceptionTranslator, indent);
223
                Exception bex;
224
                Iterator iter=this.exceptions.iterator();
225
                while (iter.hasNext()) {
226
                        bex = (Exception) iter.next();
227
                        if( bex instanceof BaseException ) {
228
                                msg = msg + "\n  " + ((BaseException)bex).getLocalizedMessage(exceptionTranslator, indent);
229
                        } else {
230
                                msg = msg + "\n  " + bex.getLocalizedMessage();
231
                        }
232
                }
233
                return BaseException.insertBlanksAtStart(msg,indent);
234
        }
235

    
236
}