root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / languages / AbstractGeneralLanguage.java @ 2985
History | View | Annotate | Download (3.01 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package es.gva.cit.catalogClient.languages; |
42 |
|
43 |
import java.util.Iterator; |
44 |
import java.util.StringTokenizer; |
45 |
import java.util.Vector; |
46 |
|
47 |
/**
|
48 |
* All classes that implement a "Language" must to inherit of this class
|
49 |
*
|
50 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
51 |
*/
|
52 |
public abstract class AbstractGeneralLanguage implements ILanguages { |
53 |
String currentQuery = null; |
54 |
String currentClause = null; |
55 |
|
56 |
/**
|
57 |
* Divide a phrase in lines
|
58 |
*
|
59 |
* @param line
|
60 |
* phrase to search
|
61 |
* @param concordancia
|
62 |
* If is 'E' (exact) don't divide
|
63 |
* @return Iteraror
|
64 |
* A set of words
|
65 |
*/
|
66 |
public Iterator parseValues(String line, String titleKeys) { |
67 |
Vector values = new Vector(); |
68 |
|
69 |
if (titleKeys.equals("E")) { |
70 |
values.add(line); |
71 |
|
72 |
return values.iterator();
|
73 |
} |
74 |
|
75 |
StringTokenizer doubleQuotesTokenizer = new StringTokenizer(line, "\"", |
76 |
true);
|
77 |
boolean inside = false; |
78 |
|
79 |
while (doubleQuotesTokenizer.hasMoreTokens()) {
|
80 |
String token = doubleQuotesTokenizer.nextToken();
|
81 |
|
82 |
if (token.equals("\"")) { |
83 |
inside = !inside; |
84 |
} else if (inside) { |
85 |
values.add(token); |
86 |
} else {
|
87 |
StringTokenizer spaceTokenizer = new StringTokenizer(token, " "); |
88 |
|
89 |
while (spaceTokenizer.hasMoreTokens()) {
|
90 |
String value = spaceTokenizer.nextToken();
|
91 |
values.add(value); |
92 |
} |
93 |
} |
94 |
} |
95 |
|
96 |
return values.iterator();
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Return logic operators
|
101 |
* @param titleKeys
|
102 |
* E,A o Y --> Exact, All, anY
|
103 |
* @return
|
104 |
* Or or And
|
105 |
*/
|
106 |
public String getOperator(String titleKeys) { |
107 |
if (titleKeys.equals("Y")) { |
108 |
return "Or"; |
109 |
} else {
|
110 |
return "And"; |
111 |
} |
112 |
} |
113 |
} |