svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / test / java / org / gvsig / gui / beans / comboboxconfigurablelookup / programmertests / SampleAgent.java @ 40561
History | View | Annotate | Download (2.73 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.comboboxconfigurablelookup.programmertests; |
25 |
|
26 |
import java.util.ArrayList; |
27 |
import java.util.List; |
28 |
import java.util.Vector; |
29 |
|
30 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp; |
31 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator; |
32 |
|
33 |
/**
|
34 |
* <p>Sample of personalized look up algorithm for the model of a <code>JComboBoxConfigurableLookUp</code> object.</p>
|
35 |
*
|
36 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
37 |
* @version 08/02/2008
|
38 |
*/
|
39 |
public class SampleAgent implements ILookUp { |
40 |
/**
|
41 |
* <p>Creates a new instance of the class <code>StartsWithLookUpAgent</code>.</p>
|
42 |
*/
|
43 |
public SampleAgent() {
|
44 |
} |
45 |
|
46 |
/*
|
47 |
* (non-Javadoc)
|
48 |
* @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpConsideringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator)
|
49 |
*/
|
50 |
public List<Object> doLookUpConsideringCaseSensitive(String text, Vector<Object> sortOrderedItems, StringComparator comp) { |
51 |
if (sortOrderedItems == null) |
52 |
return null; |
53 |
|
54 |
List<Object> list = new ArrayList<Object>(); |
55 |
|
56 |
for (int i = 0; i < (sortOrderedItems.size()); i++) { |
57 |
if (i % 2 == 0) |
58 |
list.add(sortOrderedItems.get(i)); |
59 |
} |
60 |
|
61 |
return list;
|
62 |
} |
63 |
|
64 |
/*
|
65 |
* (non-Javadoc)
|
66 |
* @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpIgnoringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator)
|
67 |
*/
|
68 |
public List<Object> doLookUpIgnoringCaseSensitive(String text, Vector<Object> sortOrderedItems, StringComparator comp) { |
69 |
if (sortOrderedItems == null) |
70 |
return null; |
71 |
|
72 |
List<Object> list = new ArrayList<Object>(); |
73 |
|
74 |
for (int i = 0; i < (sortOrderedItems.size()); i++) { |
75 |
if (i % 2 == 0) |
76 |
list.add(sortOrderedItems.get(i)); |
77 |
} |
78 |
|
79 |
return list;
|
80 |
} |
81 |
} |