svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.utils / src / main / java / org / gvsig / utils / DefaultCharSet.java @ 40561
History | View | Annotate | Download (2.63 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.utils; |
25 |
|
26 |
import java.util.ArrayList; |
27 |
import java.util.HashSet; |
28 |
|
29 |
|
30 |
/**
|
31 |
* DOCUMENT ME!
|
32 |
*
|
33 |
* @author Fernando Gonz?lez Cort?s
|
34 |
*/
|
35 |
public class DefaultCharSet implements SymbolSet { |
36 |
private HashSet caracteres = new HashSet(); |
37 |
private ArrayList intervalos = new ArrayList(); |
38 |
|
39 |
/**
|
40 |
* DOCUMENT ME!
|
41 |
*
|
42 |
* @param c DOCUMENT ME!
|
43 |
*/
|
44 |
public void addCharacter(char c) { |
45 |
caracteres.add(new Character(c)); |
46 |
} |
47 |
|
48 |
/**
|
49 |
* DOCUMENT ME!
|
50 |
*
|
51 |
* @param c1 DOCUMENT ME!
|
52 |
* @param c2 DOCUMENT ME!
|
53 |
*/
|
54 |
public void addInterval(char c1, char c2) { |
55 |
intervalos.add(new Interval(c1, c2));
|
56 |
} |
57 |
|
58 |
/**
|
59 |
* @see org.gvsig.utils.SymbolSet#contains(char)
|
60 |
*/
|
61 |
public boolean contains(char c) { |
62 |
if (caracteres.contains(new Character(c))) { |
63 |
return true; |
64 |
} |
65 |
|
66 |
for (int i = 0; i < intervalos.size(); i++) { |
67 |
if (((Interval) intervalos.get(i)).contains(c)) {
|
68 |
return true; |
69 |
} |
70 |
} |
71 |
|
72 |
return false; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* DOCUMENT ME!
|
77 |
*
|
78 |
* @author Fernando Gonz?lez Cort?s
|
79 |
*/
|
80 |
public class Interval implements SymbolSet { |
81 |
public int ini; |
82 |
public int fin; |
83 |
|
84 |
/**
|
85 |
* Crea un nuevo Interval.
|
86 |
*
|
87 |
* @param c1 DOCUMENT ME!
|
88 |
* @param c2 DOCUMENT ME!
|
89 |
*/
|
90 |
public Interval(char c1, char c2) { |
91 |
ini = c1; |
92 |
fin = c2; |
93 |
} |
94 |
|
95 |
/**
|
96 |
* @see org.gvsig.utils.SymbolSet#contains(char)
|
97 |
*/
|
98 |
public boolean contains(char c) { |
99 |
if ((ini <= c) && (c <= fin)) {
|
100 |
return true; |
101 |
} |
102 |
|
103 |
return false; |
104 |
} |
105 |
} |
106 |
} |