root / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / languages / AbstractGeneralLanguage.java @ 2658
History | View | Annotate | Download (1.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 23-may-2005
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Style - Code Templates
|
6 |
*/
|
7 |
package es.gva.cit.catalogClient.languages; |
8 |
|
9 |
import java.util.Iterator; |
10 |
import java.util.StringTokenizer; |
11 |
import java.util.Vector; |
12 |
|
13 |
/**
|
14 |
* @author jpiera
|
15 |
*
|
16 |
* TODO To change the template for this generated type comment go to
|
17 |
* Window - Preferences - Java - Code Style - Code Templates
|
18 |
*/
|
19 |
public abstract class AbstractGeneralLanguage implements ILanguages{ |
20 |
String currentQuery = null; |
21 |
String currentClause = null; |
22 |
|
23 |
/**
|
24 |
* Divide a phrase in lines
|
25 |
*
|
26 |
* @param line
|
27 |
* phrase to search
|
28 |
* @param concordancia
|
29 |
* If is 'E' (exact) don't divide
|
30 |
* @return Iteraror
|
31 |
* A set of words
|
32 |
*/
|
33 |
public Iterator parseValues(String line,String titleKeys) |
34 |
{ |
35 |
Vector values = new Vector(); |
36 |
|
37 |
if (titleKeys.equals("E")){ |
38 |
values.add(line); |
39 |
return values.iterator();
|
40 |
} |
41 |
|
42 |
StringTokenizer doubleQuotesTokenizer = new StringTokenizer(line, "\"", true); |
43 |
boolean inside = false; |
44 |
while (doubleQuotesTokenizer.hasMoreTokens())
|
45 |
{ |
46 |
String token = doubleQuotesTokenizer.nextToken();
|
47 |
if (token.equals("\"")) |
48 |
inside = !inside; |
49 |
else if (inside) values.add(token); |
50 |
else
|
51 |
{ |
52 |
StringTokenizer spaceTokenizer = new StringTokenizer(token, " "); |
53 |
while (spaceTokenizer.hasMoreTokens())
|
54 |
{ |
55 |
String value = spaceTokenizer.nextToken();
|
56 |
values.add(value); |
57 |
} |
58 |
} |
59 |
} |
60 |
return values.iterator();
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Return logic operators
|
65 |
*
|
66 |
* @param titleKeys
|
67 |
* E,A o Y --> Exact, All, anY
|
68 |
* @return String
|
69 |
*
|
70 |
*/
|
71 |
public String getOperator(String titleKeys){ |
72 |
if (titleKeys.equals("Y")) |
73 |
return "Or"; |
74 |
else
|
75 |
return "And"; |
76 |
} |
77 |
} |