1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hivegui.table; |
16 | |
17 | import java.lang.reflect.Array; |
18 | |
19 | /** |
20 | * @author Jean-Francois Poilpret |
21 | */ |
22 | public final class EmptyDataListModel<T> implements DataListModel<T> |
23 | { |
24 | public void setRows(T[] items) |
25 | { |
26 | } |
27 | |
28 | public void addRow(T item) |
29 | { |
30 | } |
31 | |
32 | public void addRow(int row, T item) |
33 | { |
34 | } |
35 | |
36 | public void setRow(int row, T item) |
37 | { |
38 | } |
39 | |
40 | public void removeRow(T item) |
41 | { |
42 | } |
43 | |
44 | public void removeRow(int row) |
45 | { |
46 | } |
47 | |
48 | public void clear() |
49 | { |
50 | } |
51 | |
52 | @SuppressWarnings("unchecked") |
53 | public EmptyDataListModel(Class<T> beanClass) |
54 | { |
55 | _beanClass = beanClass; |
56 | _emptyArray = (T[]) Array.newInstance(beanClass, 0); |
57 | } |
58 | |
59 | public Class<T> getRowClass() |
60 | { |
61 | return _beanClass; |
62 | } |
63 | public int getRowCount() |
64 | { |
65 | return 0; |
66 | } |
67 | public T getRow(int row) |
68 | { |
69 | return null; |
70 | } |
71 | public T[] getRows() |
72 | { |
73 | return _emptyArray; |
74 | } |
75 | |
76 | // No need for listeners since this model is immutable |
77 | public void addDataListModelListener(DataListModelListener listener) |
78 | { |
79 | } |
80 | |
81 | public void removeDataListModelListener(DataListModelListener listener) |
82 | { |
83 | } |
84 | |
85 | final protected Class<T> _beanClass; |
86 | final private T[] _emptyArray; |
87 | } |