root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / generictoolbar / BinarySearch.java @ 22365
History | View | Annotate | Download (2.54 KB)
1 | 18824 | bsanchez | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | */
|
||
19 | package org.gvsig.rastertools.generictoolbar; |
||
20 | |||
21 | import java.util.Arrays; |
||
22 | import java.util.List; |
||
23 | import java.util.Vector; |
||
24 | |||
25 | import org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp; |
||
26 | import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
||
27 | import org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator; |
||
28 | /**
|
||
29 | * Clase para reimplementar una nueva busqueda para el componente
|
||
30 | * {@link JComboBoxConfigurableLookUp}
|
||
31 | *
|
||
32 | * @version 13/02/2008
|
||
33 | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
||
34 | */
|
||
35 | public class BinarySearch implements ILookUp { |
||
36 | /*
|
||
37 | * (non-Javadoc)
|
||
38 | * @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpConsideringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator)
|
||
39 | */
|
||
40 | public List doLookUpConsideringCaseSensitive(String text, Vector sortOrderedItems, StringComparator comp) { |
||
41 | Vector list = new Vector(); |
||
42 | for (int i = 0; i < sortOrderedItems.size(); i++) |
||
43 | if (sortOrderedItems.get(i).toString().indexOf(text) != -1) |
||
44 | list.add(sortOrderedItems.get(i)); |
||
45 | return Arrays.asList(list.toArray()); |
||
46 | } |
||
47 | |||
48 | /*
|
||
49 | * (non-Javadoc)
|
||
50 | * @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpIgnoringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator)
|
||
51 | */
|
||
52 | public List doLookUpIgnoringCaseSensitive(String text, Vector sortOrderedItems, StringComparator comp) { |
||
53 | Vector list = new Vector(); |
||
54 | for (int i = 0; i < sortOrderedItems.size(); i++) |
||
55 | if (sortOrderedItems.get(i).toString().toLowerCase().indexOf(text.toLowerCase()) != -1) |
||
56 | list.add(sortOrderedItems.get(i)); |
||
57 | return Arrays.asList(list.toArray()); |
||
58 | } |
||
59 | } |