Revision 66
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.catalog.CatalogLibrary |
|
2 |
org.gvsig.catalog.impl.DefaultCatalogLibrary |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/languages/FilterEncoding.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.languages; |
|
43 |
import java.util.Iterator; |
|
44 |
|
|
45 |
import org.gvsig.catalog.querys.Coordinates; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* This class implements the Filter Encoding Language. It is used to |
|
50 |
* create queries in this language |
|
51 |
* @author Jorge Piera Llodra (jorge.piera@iver.es) |
|
52 |
* @see http://portal.opengeospatial.org/files/?artifact_id=8340 |
|
53 |
*/ |
|
54 |
public class FilterEncoding extends AbstractGeneralLanguage { |
|
55 |
//Properties |
|
56 |
public static final String PROPERTY_IS_LIKE = "PropertyIsLike"; |
|
57 |
public static final String PROPERTY_IS_LESS = "PropertyIsLess"; |
|
58 |
public static final String PROPERTY_IS_GREATER = "PropertyIsGreater"; |
|
59 |
public static final String PROPERTY_IS_GREATER_THAN = "PropertyIsGreaterThan"; |
|
60 |
public static final String PROPERTY_IS_LESS_THAN = "PropertyIsLessThan"; |
|
61 |
public static final String PROPERTY_IS_EQUALS_TO = "PropertyIsEqualTo"; |
|
62 |
//Type options |
|
63 |
public static final String TYPE_LITERAL = "Literal"; |
|
64 |
public static final String TYPE_TWO_PROPERTIES = "PropertyName"; |
|
65 |
//Default values |
|
66 |
public static final String DEFAULT_PREFIX = "ogc"; |
|
67 |
public static final String DEFAULT_WILDCARD = "*"; |
|
68 |
public static final String DEFAULT_SINGLECHAR = "?"; |
|
69 |
public static final String DEFAULT_ESCAPE = "\\"; |
|
70 |
public static final String DEFAULT_NAMESPACE = "xmlns:ogc=\"http://www.opengis.net/ogc\""; |
|
71 |
//Private labels |
|
72 |
private static final String FILTER = "Filter"; |
|
73 |
|
|
74 |
private String prefix = null; |
|
75 |
private String wildCard = null; |
|
76 |
private String singleChar = null; |
|
77 |
private String escape = null; |
|
78 |
private String namespace = null; |
|
79 |
private String wildCardLabel = "wildCard"; |
|
80 |
private String escapeCharLabel = "escapeChar"; |
|
81 |
private String singleCharLabel = "singleChar"; |
|
82 |
|
|
83 |
/** |
|
84 |
* Create a new Filter Encoding Parser |
|
85 |
* @param prefix Prefix of the labels (if its necessary). |
|
86 |
* Typically "ogc". |
|
87 |
* @param wildCard It Depends of the server |
|
88 |
* @param singleChar It Depends of the server |
|
89 |
* @param escape It Depends of the server |
|
90 |
*/ |
|
91 |
public FilterEncoding(String prefix, String wildCard, String singleChar, String escape) { |
|
92 |
this.prefix = prefix + ":"; |
|
93 |
this.wildCard = wildCard; |
|
94 |
this.singleChar = singleChar; |
|
95 |
this.escape = escape; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Create a new Filter Encoding Parser with the |
|
100 |
* deafault values |
|
101 |
*/ |
|
102 |
public FilterEncoding() { |
|
103 |
this.prefix = DEFAULT_PREFIX + ":"; |
|
104 |
this.wildCard = DEFAULT_WILDCARD; |
|
105 |
this.singleChar = DEFAULT_SINGLECHAR; |
|
106 |
this.escape = DEFAULT_ESCAPE; |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* It Adds a new clause of the query |
|
111 |
* @param propertyName The property name |
|
112 |
* @param propertyValue The property value |
|
113 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
114 |
* or "Y" (anY word). |
|
115 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
116 |
* Documentation. |
|
117 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
118 |
* and one literal value) |
|
119 |
* @param operator "And" or "Or". Operator between fields |
|
120 |
*/ |
|
121 |
public void addClauses(String propertyName, String propertyValue, |
|
122 |
String concordancia, String relationship, String type, |
|
123 |
String operator) { |
|
124 |
currentClause = null; |
|
125 |
//Seperating the words |
|
126 |
Iterator values = parseValues(propertyValue, concordancia, relationship, wildCard); |
|
127 |
//Filling the words |
|
128 |
addClauses(propertyName, values, concordancia, relationship, type, operator); |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* It Adds a new clause of the query |
|
133 |
* @param propertyName The property name |
|
134 |
* @param propertyValue The property value |
|
135 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
136 |
* or "Y" (anY word). |
|
137 |
*/ |
|
138 |
public void addClauses(String propertyName, String propertyValue, |
|
139 |
String concordancia) { |
|
140 |
addClauses(propertyName, propertyValue, concordancia, |
|
141 |
FilterEncoding.PROPERTY_IS_LIKE, |
|
142 |
FilterEncoding.TYPE_LITERAL, |
|
143 |
FilterEncoding.AND); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* It Adds a new clause of the query |
|
148 |
* @param propertyName The property name |
|
149 |
* @param propertyValues The property value separated by blank spaces |
|
150 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
151 |
* or "Y" (anY word). |
|
152 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
153 |
* Documentation. |
|
154 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
155 |
* and one literal value) |
|
156 |
* @param operator "And" or "Or". Operator between fields |
|
157 |
*/ |
|
158 |
public void addClauses(String propertyName, Iterator propertyValues, |
|
159 |
String concordancia, String relationship, String type, |
|
160 |
String operator) { |
|
161 |
while (propertyValues.hasNext()) |
|
162 |
addTerm(propertyName, (String) propertyValues.next(), concordancia, |
|
163 |
relationship, type); |
|
164 |
addCurrentClauseQuery(operator); |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* It adds a new term to the full query |
|
169 |
* @param propertyName The property name |
|
170 |
* @param propertyValue The property value |
|
171 |
* @param concordancia "E" (Exact phrase), "A" (All words) or "Y" (anY word). |
|
172 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
173 |
* Documentation. |
|
174 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
175 |
* and one literal value) |
|
176 |
*/ |
|
177 |
private void addTerm(String propertyName, String propertyValue, |
|
178 |
String concordancia, String relationship, String type) { |
|
179 |
StringBuffer term = new StringBuffer(); |
|
180 |
term.append(propertyIsXXX(relationship, propertyName, propertyValue, type)); |
|
181 |
if (currentClause == null) { |
|
182 |
currentClause = term.toString(); |
|
183 |
} else { |
|
184 |
currentClause = currentClause + term.toString(); |
|
185 |
currentClause = enterLabel(currentClause, getOperator(concordancia)); |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* It adds the "and" label to join different operations |
|
191 |
* @param operator |
|
192 |
*/ |
|
193 |
protected void addCurrentClauseQuery(String operator) { |
|
194 |
if (currentClause != null) { |
|
195 |
if (currentQuery == null) { |
|
196 |
currentQuery = currentClause; |
|
197 |
} else { |
|
198 |
currentQuery = currentQuery + currentClause; |
|
199 |
currentQuery = enterLabel(currentQuery, operator); |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* It returns the encoded query |
|
206 |
* @return |
|
207 |
*/ |
|
208 |
public String toString() { |
|
209 |
return enterLabel(currentQuery, FILTER); |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Involves a query with a label |
|
214 |
* @param query Query to involve |
|
215 |
* @param label Label name |
|
216 |
* @return a filter encoding query |
|
217 |
*/ |
|
218 |
private String enterLabel(String query, String label) { |
|
219 |
if (label.equals(FILTER) && (this.namespace != null)) { |
|
220 |
return "<" + prefix + label + " " + this.namespace + ">" + |
|
221 |
query + "</" + prefix + label + ">"; |
|
222 |
} else { |
|
223 |
return "<" + prefix + label + ">" + query + "</" + prefix + |
|
224 |
label + ">"; |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* It writes a "PropertyIsXXX" part of a filter encoding query |
|
230 |
* @param relationship Possible Values: PropertIsLike, PropertyIsLess, |
|
231 |
* PropertyIsGreater,... See the Filter Encoding documentation |
|
232 |
* @param propertyName The property name |
|
233 |
* @param propertyValue The property value |
|
234 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
235 |
* and one literal value) |
|
236 |
* @return The part of the query |
|
237 |
*/ |
|
238 |
private String propertyIsXXX(String relationship, String propertyName, |
|
239 |
String propertyValue, String type) { |
|
240 |
String cadena = ""; |
|
241 |
cadena = "<" + prefix + relationship; |
|
242 |
if (relationship.equals("PropertyIsLike")) { |
|
243 |
if (this.wildCard != null) { |
|
244 |
cadena = cadena + " " + getWildCardLabel() + "=\"" + this.wildCard + "\""; |
|
245 |
} |
|
246 |
if (this.singleChar != null) { |
|
247 |
cadena = cadena + " " + getSingleCharLabel() + "=\"" + this.singleChar + "\""; |
|
248 |
} |
|
249 |
if (this.escape != null) { |
|
250 |
cadena = cadena + " " + getEscapeCharLabel() + "=\"" + this.escape + "\""; |
|
251 |
} |
|
252 |
} |
|
253 |
cadena = cadena + ">" + enterLabel(propertyName, TYPE_TWO_PROPERTIES); |
|
254 |
cadena = cadena + enterLabel(propertyValue, type); |
|
255 |
return cadena + "</" + prefix + relationship + ">"; |
|
256 |
} |
|
257 |
|
|
258 |
/** |
|
259 |
* It Adds a Bounding Box query |
|
260 |
* |
|
261 |
* |
|
262 |
* @param coordinates Coordinates to find |
|
263 |
* @param propertyName Property that contains the geom field |
|
264 |
* @param not If we have to envolve the query with the "NOT" tag. |
|
265 |
*/ |
|
266 |
public void addBoundingBox(Coordinates coordinates, String propertyName, boolean not) { |
|
267 |
// sNorth -> Uly(); |
|
268 |
// sWest -> Ulx(); |
|
269 |
// sSouth -> Bry(); |
|
270 |
// sEast -> Brx(); |
|
271 |
String bbox = "<ogc:BBOX>" + "<ogc:PropertyName>" + propertyName + |
|
272 |
"</ogc:PropertyName>" + "<gml:Box>" + "<gml:coord>" + "<gml:X>" + |
|
273 |
coordinates.ulx + "</gml:X>" + "<gml:Y>" + coordinates.bry + |
|
274 |
"</gml:Y>" + "</gml:coord>" + "<gml:coord>" + "<gml:X>" + |
|
275 |
coordinates.brx + "</gml:X>" + "<gml:Y>" + coordinates.uly + |
|
276 |
"</gml:Y>" + "</gml:coord>" + "</gml:Box>" + "</ogc:BBOX>"; |
|
277 |
if (not){ |
|
278 |
bbox = "<ogc:Not>" + bbox + "</ogc:Not>"; |
|
279 |
} |
|
280 |
if (currentQuery == null) { |
|
281 |
currentQuery = bbox; |
|
282 |
} else { |
|
283 |
currentQuery = currentQuery + bbox; |
|
284 |
currentQuery = enterLabel(currentQuery, "And"); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* @return the wildCard |
|
290 |
*/ |
|
291 |
public String getWildCard() { |
|
292 |
return wildCard; |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* @return the wildCardLabel |
|
297 |
*/ |
|
298 |
public String getWildCardLabel() { |
|
299 |
return wildCardLabel; |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* @param wildCardLabel the wildCardLabel to set |
|
304 |
*/ |
|
305 |
public void setWildCardLabel(String wildCardLabel) { |
|
306 |
this.wildCardLabel = wildCardLabel; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* @return the escapeCharLabel |
|
311 |
*/ |
|
312 |
public String getEscapeCharLabel() { |
|
313 |
return escapeCharLabel; |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* @param escapeCharLabel the escapeCharLabel to set |
|
318 |
*/ |
|
319 |
public void setEscapeCharLabel(String escapeCharLabel) { |
|
320 |
this.escapeCharLabel = escapeCharLabel; |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* @return the singleCharLabel |
|
325 |
*/ |
|
326 |
public String getSingleCharLabel() { |
|
327 |
return singleCharLabel; |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* @param singleCharLabel the singleCharLabel to set |
|
332 |
*/ |
|
333 |
public void setSingleCharLabel(String singleCharLabel) { |
|
334 |
this.singleCharLabel = singleCharLabel; |
|
335 |
} |
|
336 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/languages/ILanguages.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.languages; |
|
43 |
/** |
|
44 |
* This interface must be implementeded by all the CSW profiles |
|
45 |
* |
|
46 |
* |
|
47 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
48 |
*/ |
|
49 |
public interface ILanguages { |
|
50 |
/** |
|
51 |
* |
|
52 |
* |
|
53 |
* |
|
54 |
* @return |
|
55 |
*/ |
|
56 |
public String toString(); |
|
57 |
} |
|
58 |
//Return the query |
|
59 |
|
|
60 |
|
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/languages/CommonQueryLanguage.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.languages; |
|
43 |
import java.util.Iterator; |
|
44 |
import java.util.StringTokenizer; |
|
45 |
|
|
46 |
/** |
|
47 |
* This class is used to create a Common Query Language query. |
|
48 |
* See the specification for more information. |
|
49 |
* |
|
50 |
* |
|
51 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
52 |
* @see http://www.loc.gov/z3950/agency/zing/cql/ |
|
53 |
*/ |
|
54 |
public class CommonQueryLanguage extends AbstractGeneralLanguage { |
|
55 |
|
|
56 |
/** |
|
57 |
* |
|
58 |
* |
|
59 |
* |
|
60 |
* @param parameter |
|
61 |
* @param line |
|
62 |
* @param concordancia |
|
63 |
*/ |
|
64 |
public void addClauses(String parameter, String line, String concordancia,String operator) { |
|
65 |
currentClause = null; |
|
66 |
|
|
67 |
Iterator values = parseValues(line, concordancia); |
|
68 |
addClauses(parameter, values, concordancia,operator); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
* |
|
74 |
* |
|
75 |
* @param parameter |
|
76 |
* @param values |
|
77 |
* @param concordancia |
|
78 |
*/ |
|
79 |
public void addClauses(String parameter, Iterator values, String concordancia, String operator) { |
|
80 |
while (values.hasNext()) |
|
81 |
addTerm(parameter, (String) values.next(), concordancia); |
|
82 |
addCurrentClauseQuery(operator); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* It adds a new search field to the string |
|
87 |
* |
|
88 |
* |
|
89 |
* @param parameter |
|
90 |
* @param value |
|
91 |
* @param concordancia |
|
92 |
*/ |
|
93 |
private void addTerm(String parameter, String value, String concordancia) { |
|
94 |
StringBuffer term = new StringBuffer(); |
|
95 |
term.append(parameter + "=" + cutWord(value, concordancia)); |
|
96 |
if (currentClause == null) { |
|
97 |
currentClause = term.toString(); |
|
98 |
} else { |
|
99 |
currentClause = "(" + currentClause + " " + |
|
100 |
getOperator(concordancia) + " " + term.toString() + ")"; |
|
101 |
|
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* |
|
107 |
* |
|
108 |
*/ |
|
109 |
protected void addCurrentClauseQuery(String operator) { |
|
110 |
if (currentClause != null) { |
|
111 |
if (currentQuery == null) { |
|
112 |
currentQuery = currentClause; |
|
113 |
} else { |
|
114 |
currentQuery = "(" + currentQuery + " " + |
|
115 |
operator + " " + currentClause + ")"; |
|
116 |
} |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* |
|
122 |
* |
|
123 |
* |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
public String toString() { |
|
127 |
return currentQuery; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* |
|
132 |
* |
|
133 |
* |
|
134 |
* @return |
|
135 |
* @param line |
|
136 |
* @param titleKeys |
|
137 |
*/ |
|
138 |
public String cutWord(String line, String titleKeys) { |
|
139 |
|
|
140 |
if (titleKeys.equals("E")) { |
|
141 |
StringTokenizer sti = new StringTokenizer(line, " ", true); |
|
142 |
boolean first = true; |
|
143 |
String token = ""; |
|
144 |
while (sti.hasMoreTokens()) { |
|
145 |
String currentToken = sti.nextToken(); |
|
146 |
if (first) { |
|
147 |
token = currentToken; |
|
148 |
first = !first; |
|
149 |
} else if (!(currentToken.equals(" "))) { |
|
150 |
token = "(" + token + " and " + currentToken + ")"; |
|
151 |
} |
|
152 |
} |
|
153 |
return token; |
|
154 |
} |
|
155 |
return line; |
|
156 |
} |
|
157 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/languages/BasicEncodingRules.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.languages; |
|
43 |
import java.util.Iterator; |
|
44 |
|
|
45 |
/** |
|
46 |
* This class is used to create a Basic Encoding Rules (BER) query. |
|
47 |
* See the specification for more information. |
|
48 |
* |
|
49 |
* |
|
50 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
51 |
* @see http://www.loc.gov/z3950/agency/ |
|
52 |
*/ |
|
53 |
public class BasicEncodingRules extends AbstractGeneralLanguage { |
|
54 |
|
|
55 |
/** |
|
56 |
* It adds a new clause to the query |
|
57 |
* |
|
58 |
* |
|
59 |
* @param use It is a number that represent an attribute (4=Title,62=abstract,...) |
|
60 |
* @param structure It defines the attribute type (1=Phrase,2=wors,...) |
|
61 |
* @param relation Relation between the attribute and the query (1=LessThan,3=equal,...) |
|
62 |
* @param line String with the user introduced value |
|
63 |
* @param concordancia Relationship between different words of the same field (more than one words) |
|
64 |
* E,A o Y --> Exact, All, anY |
|
65 |
* @param operator Relationship between fields (title, abstract) |
|
66 |
* 'and' or 'or' |
|
67 |
*/ |
|
68 |
public void addClauses(String use, String structure, String relation, String line, String concordancia, String operator) { |
|
69 |
currentClause = null; |
|
70 |
//Cut the words |
|
71 |
Iterator values = parseValues(line, concordancia); |
|
72 |
addClauses(use, structure, relation, values, concordancia,operator); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* It realize the same function than the "addClauses(String use, String structure |
|
77 |
* String relation,String line, String concordancia)" function, but the words |
|
78 |
* to find are in a vector. |
|
79 |
* |
|
80 |
* |
|
81 |
* @param use |
|
82 |
* @param structure |
|
83 |
* @param relation |
|
84 |
* @param values |
|
85 |
* @param concordancia |
|
86 |
* @param operator |
|
87 |
*/ |
|
88 |
public void addClauses(String use, String structure, String relation, Iterator values, String concordancia, String operator) { |
|
89 |
while (values.hasNext()) |
|
90 |
addTerm(use, structure, relation, (String) values.next(), |
|
91 |
getOperator(concordancia)); |
|
92 |
addCurrentClauseQuery(operator); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* Add a new serch field |
|
97 |
* |
|
98 |
* |
|
99 |
* @param use BER use |
|
100 |
* @param structure BER structure |
|
101 |
* @param relation BER relation |
|
102 |
* @param value Filed value |
|
103 |
* @param operator "and" or "or" |
|
104 |
*/ |
|
105 |
private void addTerm(String use, String structure, String relation, String value, String operator) { |
|
106 |
StringBuffer term = new StringBuffer(); |
|
107 |
if (use != null) { |
|
108 |
term.append("@attr 1=" + use + " "); |
|
109 |
} |
|
110 |
if (structure != null) { |
|
111 |
term.append("@attr 4=" + structure + " "); |
|
112 |
} |
|
113 |
if (relation != null) { |
|
114 |
term.append("@attr 2=" + relation + " "); |
|
115 |
} |
|
116 |
term.append("\"" + value + "\" "); |
|
117 |
if (currentClause == null) { |
|
118 |
currentClause = term.toString(); |
|
119 |
} else { |
|
120 |
currentClause = "@" + operator + " " + currentClause + " " + term; |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* It adds a new query to the current query. |
|
126 |
* |
|
127 |
* |
|
128 |
* @param operator 'and' or 'or'. Relation between fields |
|
129 |
*/ |
|
130 |
protected void addCurrentClauseQuery(String operator) { |
|
131 |
if (currentClause != null) { |
|
132 |
if (currentQuery == null) { |
|
133 |
currentQuery = currentClause; |
|
134 |
} else { |
|
135 |
currentQuery = "@" + operator + " " + currentQuery + " " + currentClause; |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* It returns the complete BER query |
|
142 |
* |
|
143 |
* |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
public String toString(String database) { |
|
147 |
if ((database == null) || (database.equals(""))){ |
|
148 |
database = "geo"; |
|
149 |
} |
|
150 |
return "@attrset bib-1 " + currentQuery; |
|
151 |
} |
|
152 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/languages/AbstractGeneralLanguage.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.languages; |
|
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 |
|
49 |
* inherit of this class |
|
50 |
* @author Jorge Piera Llodra (jorge.piera@iver.es) |
|
51 |
*/ |
|
52 |
public abstract class AbstractGeneralLanguage implements ILanguages { |
|
53 |
public static final String EXACT_WORDS = "E"; |
|
54 |
public static final String ANY_WORDS = "Y"; |
|
55 |
public static final String ALL_WORDS = "A"; |
|
56 |
public static final String AND = "And"; |
|
57 |
public static final String OR = "Or"; |
|
58 |
|
|
59 |
protected String currentQuery = null; |
|
60 |
protected String currentClause = null; |
|
61 |
|
|
62 |
/** |
|
63 |
* Divide a phrase in lines |
|
64 |
* @param concordancia If is 'E' (exact) don't divide |
|
65 |
* @return Iteraror |
|
66 |
* A set of words |
|
67 |
* @param line phrase to search |
|
68 |
* @param titleKeys |
|
69 |
*/ |
|
70 |
public Iterator parseValues(String line, String titleKeys){ |
|
71 |
return parseValues(line, titleKeys, FilterEncoding.PROPERTY_IS_EQUALS_TO, null); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Divide a phrase in lines |
|
76 |
*@param concordancia If is 'E' (exact) don't divide |
|
77 |
* @return Iteraror |
|
78 |
* A set of words |
|
79 |
* @param line phrase to search |
|
80 |
* @param titleKeys |
|
81 |
* @param relationship |
|
82 |
* @param wildCard |
|
83 |
*/ |
|
84 |
public Iterator parseValues(String line, String titleKeys, String relationship, String wildCard) { |
|
85 |
Vector values = new Vector(); |
|
86 |
|
|
87 |
if (titleKeys == null){ |
|
88 |
titleKeys = EXACT_WORDS; |
|
89 |
} |
|
90 |
|
|
91 |
if (titleKeys.equals(EXACT_WORDS)) { |
|
92 |
values.add(line); |
|
93 |
return values.iterator(); |
|
94 |
} |
|
95 |
StringTokenizer doubleQuotesTokenizer = new StringTokenizer(line, "\"", |
|
96 |
true); |
|
97 |
boolean inside = false; |
|
98 |
while (doubleQuotesTokenizer.hasMoreTokens()) { |
|
99 |
String token = doubleQuotesTokenizer.nextToken(); |
|
100 |
if (token.equals("\"")) { |
|
101 |
inside = !inside; |
|
102 |
} else if (inside) { |
|
103 |
if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0){ |
|
104 |
token = wildCard + token + wildCard; |
|
105 |
} |
|
106 |
values.add(token); |
|
107 |
} else { |
|
108 |
StringTokenizer spaceTokenizer = new StringTokenizer(token, " "); |
|
109 |
while (spaceTokenizer.hasMoreTokens()) { |
|
110 |
String value = spaceTokenizer.nextToken(); |
|
111 |
if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0){ |
|
112 |
value = wildCard + value + wildCard; |
|
113 |
} |
|
114 |
values.add(value); |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
return values.iterator(); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Return logic operators |
|
123 |
* @return Or or And |
|
124 |
* @param titleKeys E,A o Y --> Exact, All, anY |
|
125 |
*/ |
|
126 |
public String getOperator(String titleKeys) { |
|
127 |
if (titleKeys == null){ |
|
128 |
titleKeys = EXACT_WORDS; |
|
129 |
} |
|
130 |
if (titleKeys.equals(ANY_WORDS)) { |
|
131 |
return OR; |
|
132 |
} else { |
|
133 |
return AND; |
|
134 |
} |
|
135 |
} |
|
136 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/DiscoveryServiceClient.java | ||
---|---|---|
1 |
package org.gvsig.catalog; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.net.Authenticator; |
|
5 |
import java.net.PasswordAuthentication; |
|
6 |
import java.net.Socket; |
|
7 |
import java.net.URI; |
|
8 |
import java.net.URISyntaxException; |
|
9 |
import java.net.UnknownHostException; |
|
10 |
import java.util.Properties; |
|
11 |
|
|
12 |
import org.apache.commons.httpclient.HttpConnection; |
|
13 |
|
|
14 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
15 |
import org.gvsig.catalog.drivers.IDiscoveryServiceDriver; |
|
16 |
import org.gvsig.catalog.exceptions.DiscoveryServiceException; |
|
17 |
import org.gvsig.catalog.exceptions.NotSupportedProtocolException; |
|
18 |
import org.gvsig.catalog.exceptions.NotSupportedVersionException; |
|
19 |
import org.gvsig.catalog.exceptions.ServerIsNotReadyException; |
|
20 |
import org.gvsig.catalog.querys.DiscoveryServiceQuery; |
|
21 |
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel; |
|
22 |
import org.gvsig.catalog.utils.URIUtils; |
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
27 |
* |
|
28 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
29 |
* |
|
30 |
* This program is free software; you can redistribute it and/or |
|
31 |
* modify it under the terms of the GNU General Public License |
|
32 |
* as published by the Free Software Foundation; either version 2 |
|
33 |
* of the License, or (at your option) any later version. |
|
34 |
* |
|
35 |
* This program is distributed in the hope that it will be useful, |
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
38 |
* GNU General Public License for more details. |
|
39 |
* |
|
40 |
* You should have received a copy of the GNU General Public License |
|
41 |
* along with this program; if not, write to the Free Software |
|
42 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
43 |
* |
|
44 |
* For more information, contact: |
|
45 |
* |
|
46 |
* Generalitat Valenciana |
|
47 |
* Conselleria d'Infraestructures i Transport |
|
48 |
* Av. Blasco Ib??ez, 50 |
|
49 |
* 46010 VALENCIA |
|
50 |
* SPAIN |
|
51 |
* |
|
52 |
* +34 963862235 |
|
53 |
* gvsig@gva.es |
|
54 |
* www.gvsig.gva.es |
|
55 |
* |
|
56 |
* or |
|
57 |
* |
|
58 |
* IVER T.I. S.A |
|
59 |
* Salamanca 50 |
|
60 |
* 46005 Valencia |
|
61 |
* Spain |
|
62 |
* |
|
63 |
* +34 963163400 |
|
64 |
* dac@iver.es |
|
65 |
*/ |
|
66 |
/* CVS MESSAGES: |
|
67 |
* |
|
68 |
* $Id$ |
|
69 |
* $Log$ |
|
70 |
* |
|
71 |
*/ |
|
72 |
/** |
|
73 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
74 |
*/ |
|
75 |
public class DiscoveryServiceClient { |
|
76 |
/** |
|
77 |
* The server URI |
|
78 |
*/ |
|
79 |
private URI uri = null; |
|
80 |
/** |
|
81 |
* The driver to make the querys |
|
82 |
*/ |
|
83 |
private IDiscoveryServiceDriver driver; |
|
84 |
/** |
|
85 |
* The service capabilities |
|
86 |
*/ |
|
87 |
private DiscoveryServiceCapabilities capabilities; |
|
88 |
/** |
|
89 |
* The server status message |
|
90 |
*/ |
|
91 |
private String serverStatus = null; |
|
92 |
|
|
93 |
public DiscoveryServiceClient(String sUri,IDiscoveryServiceDriver driver) { |
|
94 |
setDriver(driver); |
|
95 |
if (driver == null){ |
|
96 |
serverStatus = "errorServerNotFound"; |
|
97 |
}else{ |
|
98 |
try { |
|
99 |
this.uri = URIUtils.createUri(sUri, |
|
100 |
driver.getDefaultSchema(), |
|
101 |
driver.getDefaultPort()); |
|
102 |
} catch (URISyntaxException e) { |
|
103 |
serverStatus = "errorServerNotFound"; |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* It make a getCapabilities operation |
|
110 |
* @return the service version |
|
111 |
* @throws ServerIsNotReadyException |
|
112 |
*/ |
|
113 |
public DiscoveryServiceCapabilities getCapabilities() throws DiscoveryServiceException { |
|
114 |
if (serverIsReady()){ |
|
115 |
try { |
|
116 |
if (getDriver().isProtocolSupported(getUri())) { |
|
117 |
capabilities = getDriver().getCapabilities(getUri()); |
|
118 |
return capabilities; |
|
119 |
} |
|
120 |
} catch (NotSupportedProtocolException e) { |
|
121 |
capabilities = new DiscoveryServiceCapabilities(); |
|
122 |
capabilities.setAvailable(false); |
|
123 |
capabilities.setServerMessage("notSupportedProtocol"); |
|
124 |
} catch (NotSupportedVersionException e) { |
|
125 |
capabilities = new DiscoveryServiceCapabilities(); |
|
126 |
capabilities.setAvailable(false); |
|
127 |
capabilities.setServerMessage("notSupportedVersion"); |
|
128 |
} |
|
129 |
} |
|
130 |
return capabilities; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* It tries if the server is ready |
|
135 |
* @return boolean |
|
136 |
* true --> server is ready |
|
137 |
* false --> server is not ready |
|
138 |
*/ |
|
139 |
public boolean serverIsReady() throws ServerIsNotReadyException { |
|
140 |
Properties systemSettings = System.getProperties(); |
|
141 |
|
|
142 |
|
|
143 |
Object isProxyEnabled = systemSettings.get("http.proxySet"); |
|
144 |
if ((isProxyEnabled == null) || (isProxyEnabled.equals("false"))){ |
|
145 |
Socket sock; |
|
146 |
try{ |
|
147 |
sock = new Socket(getUri().getHost(), |
|
148 |
getUri().getPort()); |
|
149 |
} catch (UnknownHostException e) { |
|
150 |
throw new ServerIsNotReadyException(e); |
|
151 |
} catch (IOException e) { |
|
152 |
throw new ServerIsNotReadyException(e); |
|
153 |
} |
|
154 |
return (sock != null); |
|
155 |
}else{ |
|
156 |
Object host = systemSettings.get("http.proxyHost"); |
|
157 |
Object port = systemSettings.get("http.proxyPort"); |
|
158 |
Object user = systemSettings.get("http.proxyUserName"); |
|
159 |
Object password = systemSettings.get("http.proxyPassword"); |
|
160 |
if ((host != null) && (port != null)){ |
|
161 |
int iPort = 80; |
|
162 |
try{ |
|
163 |
iPort = Integer.parseInt((String)port); |
|
164 |
}catch (Exception e) { |
|
165 |
//Use 80 |
|
166 |
} |
|
167 |
HttpConnection connection = new HttpConnection(getUri().getHost(), |
|
168 |
getUri().getPort()); |
|
169 |
connection.setProxyHost((String)host); |
|
170 |
connection.setProxyPort(iPort); |
|
171 |
Authenticator.setDefault(new SimpleAuthenticator( |
|
172 |
user,password)); |
|
173 |
|
|
174 |
try { |
|
175 |
connection.open(); |
|
176 |
connection.close(); |
|
177 |
} catch (IOException e) { |
|
178 |
throw new ServerIsNotReadyException(e); |
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
return true; |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* @return the server URI |
|
187 |
*/ |
|
188 |
public URI getUri() { |
|
189 |
return uri; |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* @return Return the server URI like a String |
|
194 |
*/ |
|
195 |
public String getSUri() { |
|
196 |
return uri.toString(); |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* @return Returns the driver. |
|
201 |
*/ |
|
202 |
protected IDiscoveryServiceDriver getDriver() { |
|
203 |
return driver; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* |
|
208 |
* @param driver the driver to set |
|
209 |
*/ |
|
210 |
protected void setDriver(IDiscoveryServiceDriver driver) { |
|
211 |
this.driver = driver; |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* @return the server protocol |
|
216 |
*/ |
|
217 |
public String getProtocol() { |
|
218 |
return driver.getServiceName(); |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* Gets the aditional panel |
|
223 |
* @return |
|
224 |
*/ |
|
225 |
public SearchAditionalPropertiesPanel getAditionalSearchPanel(){ |
|
226 |
return driver.getAditionalSearchPanel(); |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Gets a query |
|
231 |
* @return |
|
232 |
*/ |
|
233 |
public DiscoveryServiceQuery createQuery(){ |
|
234 |
return driver.createQuery(); |
|
235 |
} |
|
236 |
|
|
237 |
private class SimpleAuthenticator |
|
238 |
extends Authenticator |
|
239 |
{ |
|
240 |
private String username, |
|
241 |
password; |
|
242 |
|
|
243 |
public SimpleAuthenticator(Object username, Object password) |
|
244 |
{ |
|
245 |
if (username != null){ |
|
246 |
this.username = (String)username; |
|
247 |
} |
|
248 |
if (password != null){ |
|
249 |
this.password = (String)password; |
|
250 |
} |
|
251 |
} |
|
252 |
|
|
253 |
protected PasswordAuthentication getPasswordAuthentication() |
|
254 |
{ |
|
255 |
return new PasswordAuthentication( |
|
256 |
username,password.toCharArray()); |
|
257 |
} |
|
258 |
} |
|
259 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/AdditionalClauses.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.filters; |
|
43 |
|
|
44 |
/** |
|
45 |
* This class is used like an structure. It contains the fields needed to add a new |
|
46 |
* operation to the query language. |
|
47 |
* |
|
48 |
* |
|
49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
50 |
*/ |
|
51 |
public class AdditionalClauses { |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
private String property; |
|
58 |
|
|
59 |
/** |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
private String value; |
|
64 |
|
|
65 |
/** |
|
66 |
* |
|
67 |
* |
|
68 |
*/ |
|
69 |
private String concorancia; |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
* |
|
74 |
*/ |
|
75 |
private String relationship; |
|
76 |
|
|
77 |
/** |
|
78 |
* |
|
79 |
* |
|
80 |
*/ |
|
81 |
private String type; |
|
82 |
|
|
83 |
/** |
|
84 |
* |
|
85 |
* |
|
86 |
* |
|
87 |
* @param property |
|
88 |
* @param value |
|
89 |
* @param concorancia |
|
90 |
* @param relationship |
|
91 |
* @param type |
|
92 |
*/ |
|
93 |
public AdditionalClauses(String property, String value, String concorancia, String relationship, String type) { |
|
94 |
super(); |
|
95 |
this.property = property; |
|
96 |
this.value = value; |
|
97 |
this.concorancia = concorancia; |
|
98 |
this.relationship = relationship; |
|
99 |
this.type = type; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* |
|
104 |
* |
|
105 |
* |
|
106 |
* @return Returns the concorancia. |
|
107 |
*/ |
|
108 |
public String getConcorancia() { |
|
109 |
return concorancia; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* |
|
114 |
* |
|
115 |
* |
|
116 |
* @return Returns the property. |
|
117 |
*/ |
|
118 |
public String getProperty() { |
|
119 |
return property; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* |
|
124 |
* |
|
125 |
* |
|
126 |
* @return Returns the relationship. |
|
127 |
*/ |
|
128 |
public String getRelationship() { |
|
129 |
return relationship; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* |
|
134 |
* |
|
135 |
* |
|
136 |
* @return Returns the type. |
|
137 |
*/ |
|
138 |
public String getType() { |
|
139 |
return type; |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* |
|
144 |
* |
|
145 |
* |
|
146 |
* @return Returns the value. |
|
147 |
*/ |
|
148 |
public String getValue() { |
|
149 |
return value; |
|
150 |
} |
|
151 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/AbstractFilter.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
/* |
|
43 |
* CVS MESSAGES: |
|
44 |
* |
|
45 |
* $Id: AbstractFilter.java 561 2007-07-27 06:49:30 +0000 (Fri, 27 Jul 2007) jpiera $ |
|
46 |
* $Log$ |
|
47 |
* Revision 1.4 2006/01/18 09:57:01 jorpiell |
|
48 |
* Eliminados algunos ficheros innecesarios |
|
49 |
* |
|
50 |
* Revision 1.3 2006/01/12 13:52:24 jorpiell |
|
51 |
* Se ha a?adido un boton close en las dos pantallas de connect. Adem?s se ha cambiado el comportamiento de las ventanas para adaptarlo a la nueva forma de buscar multihilo |
|
52 |
* |
|
53 |
* Revision 1.2 2006/01/10 09:32:48 jorpiell |
|
54 |
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n. |
|
55 |
* |
|
56 |
* Revision 1.1 2005/12/22 08:31:43 jorpiell |
|
57 |
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente. |
|
58 |
* |
|
59 |
* |
|
60 |
*/ |
|
61 |
package org.gvsig.catalog.filters; |
|
62 |
|
|
63 |
/** |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
public abstract class AbstractFilter implements IFilter { |
|
68 |
} |
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/IFilter.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog.filters; |
|
43 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
44 |
/** |
|
45 |
* All the clases that implement a "Query" class must to |
|
46 |
* implemet this interface |
|
47 |
* |
|
48 |
* |
|
49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
50 |
*/ |
|
51 |
public interface IFilter { |
|
52 |
/** |
|
53 |
* |
|
54 |
* |
|
55 |
* |
|
56 |
* @return |
|
57 |
* @param query |
|
58 |
* @param profile |
|
59 |
*/ |
|
60 |
public String getQuery(CatalogQuery query); |
|
61 |
} |
|
62 |
//Return the query that will be used for the driver |
|
63 |
|
|
64 |
|
org.gvsig.catalog/branches/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/CatalogAP.java | ||
---|---|---|
1 |
|
|
2 |
/* 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 |
package org.gvsig.catalog; |
|
43 |
import java.io.File; |
|
44 |
import java.net.MalformedURLException; |
|
45 |
import java.util.Locale; |
|
46 |
|
|
47 |
import javax.swing.UIManager; |
|
48 |
import javax.swing.UnsupportedLookAndFeelException; |
|
49 |
|
|
50 |
import org.gvsig.catalog.ui.serverconnect.ServerConnectDialog; |
|
51 |
import org.gvsig.i18n.Messages; |
|
52 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
53 |
|
|
54 |
|
|
55 |
/** |
|
56 |
* This class is the launcher application |
|
57 |
* |
|
58 |
* |
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
60 |
*/ |
Also available in: Unified diff