Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_915 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / languages / AbstractGeneralLanguage.java @ 12217

History | View | Annotate | Download (3.16 KB)

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