Revision 368
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/utils/URIUtilsTest.java | ||
---|---|---|
1 |
package org.gvsig.catalog.catalog.utils; |
|
2 |
|
|
3 |
import java.net.URI; |
|
4 |
import java.net.URISyntaxException; |
|
5 |
|
|
6 |
import junit.framework.TestCase; |
|
7 |
|
|
8 |
import org.gvsig.catalog.utils.URIUtils; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id: URIUtilsTest.java,v 1.1.2.1 2007/07/10 11:18:04 jorpiell Exp $ |
|
53 |
* $Log: URIUtilsTest.java,v $ |
|
54 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
55 |
* Added the registers |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
61 |
*/ |
|
62 |
public class URIUtilsTest extends TestCase { |
|
63 |
|
|
64 |
public void test1() throws URISyntaxException{ |
|
65 |
URI uri = URIUtils.createUri("http://www.upv.es", "http", 80); |
|
66 |
assertEquals(uri.getHost(), "www.upv.es"); |
|
67 |
assertEquals(uri.getScheme(), "http"); |
|
68 |
assertEquals(uri.getPort(), 80); |
|
69 |
assertEquals(uri.getPath(), ""); |
|
70 |
} |
|
71 |
|
|
72 |
public void test2() throws URISyntaxException{ |
|
73 |
URI uri = URIUtils.createUri("www.upv.es", "http", 80); |
|
74 |
assertEquals(uri.getHost(), "www.upv.es"); |
|
75 |
assertEquals(uri.getScheme(), "http"); |
|
76 |
assertEquals(uri.getPort(), 80); |
|
77 |
assertEquals(uri.getPath(), ""); |
|
78 |
} |
|
79 |
|
|
80 |
public void test3() throws URISyntaxException{ |
|
81 |
URI uri = URIUtils.createUri("www.upv.es", "z3950", 2100); |
|
82 |
assertEquals(uri.getHost(), "www.upv.es"); |
|
83 |
assertEquals(uri.getScheme(), "z3950"); |
|
84 |
assertEquals(uri.getPort(), 2100); |
|
85 |
assertEquals(uri.getPath(), ""); |
|
86 |
} |
|
87 |
|
|
88 |
public void test4() throws URISyntaxException{ |
|
89 |
URI uri = URIUtils.createUri("http://193.144.250.29/webservices/services/IDEC_GeoServeisPort", "http", 80); |
|
90 |
assertEquals(uri.getHost(), "193.144.250.29"); |
|
91 |
assertEquals(uri.getScheme(), "http"); |
|
92 |
assertEquals(uri.getPort(), 80); |
|
93 |
assertEquals(uri.getPath(), "/webservices/services/IDEC_GeoServeisPort"); |
|
94 |
} |
|
95 |
} |
|
0 | 96 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriver.java | ||
---|---|---|
1 |
package org.gvsig.catalog.catalog.drivers; |
|
2 |
|
|
3 |
import java.net.URI; |
|
4 |
|
|
5 |
import org.gvsig.catalog.CatalogLocator; |
|
6 |
import org.gvsig.catalog.CatalogManager; |
|
7 |
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver; |
|
8 |
import org.gvsig.catalog.drivers.CatalogCapabilities; |
|
9 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
10 |
import org.gvsig.catalog.drivers.GetRecordsReply; |
|
11 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
12 |
import org.gvsig.catalog.schemas.Record; |
|
13 |
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel; |
|
14 |
|
|
15 |
|
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
17 |
* |
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
19 |
* |
|
20 |
* This program is free software; you can redistribute it and/or |
|
21 |
* modify it under the terms of the GNU General Public License |
|
22 |
* as published by the Free Software Foundation; either version 2 |
|
23 |
* of the License, or (at your option) any later version. |
|
24 |
* |
|
25 |
* This program is distributed in the hope that it will be useful, |
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
28 |
* GNU General Public License for more details. |
|
29 |
* |
|
30 |
* You should have received a copy of the GNU General Public License |
|
31 |
* along with this program; if not, write to the Free Software |
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
33 |
* |
|
34 |
* For more information, contact: |
|
35 |
* |
|
36 |
* Generalitat Valenciana |
|
37 |
* Conselleria d'Infraestructures i Transport |
|
38 |
* Av. Blasco Ib??ez, 50 |
|
39 |
* 46010 VALENCIA |
|
40 |
* SPAIN |
|
41 |
* |
|
42 |
* +34 963862235 |
|
43 |
* gvsig@gva.es |
|
44 |
* www.gvsig.gva.es |
|
45 |
* |
|
46 |
* or |
|
47 |
* |
|
48 |
* IVER T.I. S.A |
|
49 |
* Salamanca 50 |
|
50 |
* 46005 Valencia |
|
51 |
* Spain |
|
52 |
* |
|
53 |
* +34 963163400 |
|
54 |
* dac@iver.es |
|
55 |
*/ |
|
56 |
/* CVS MESSAGES: |
|
57 |
* |
|
58 |
* $Id: ExampleNewDriver.java 537 2007-07-26 11:21:10Z jpiera $ |
|
59 |
* $Log$ |
|
60 |
* Revision 1.1.2.1 2007/07/13 12:00:35 jorpiell |
|
61 |
* Add the posibility to add a new panel |
|
62 |
* |
|
63 |
* |
|
64 |
*/ |
|
65 |
/** |
|
66 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
67 |
*/ |
|
68 |
public class ExampleNewDriver extends AbstractCatalogServiceDriver { |
|
69 |
private static final CatalogManager catalogManager = CatalogLocator.getCatalogManager(); |
|
70 |
|
|
71 |
/* |
|
72 |
* (non-Javadoc) |
|
73 |
* @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI) |
|
74 |
*/ |
|
75 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) { |
|
76 |
return new CatalogCapabilities(); |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see es.gva.cit.catalog.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalog.querys.CatalogQuery, int) |
|
82 |
*/ |
|
83 |
public GetRecordsReply getRecords(URI uri, CatalogQuery query, |
|
84 |
int firstRecord) { |
|
85 |
GetRecordsReply reply = new GetRecordsReply(1); |
|
86 |
Record record = catalogManager.createRecord(uri, null); |
|
87 |
record.setTitle("Record example"); |
|
88 |
record.setAbstract_("Just for testing"); |
|
89 |
reply.addRecord(record); |
|
90 |
return reply; |
|
91 |
} |
|
92 |
|
|
93 |
/* |
|
94 |
* (non-Javadoc) |
|
95 |
* @see es.gva.cit.catalog.drivers.IDiscoveryServiceDriver#getServiceName() |
|
96 |
*/ |
|
97 |
public String getServiceName() { |
|
98 |
return "My catalog service"; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel() |
|
104 |
*/ |
|
105 |
public SearchAditionalPropertiesPanel getAditionalSearchPanel(){ |
|
106 |
return new ExampleNewPanel(); |
|
107 |
} |
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
} |
|
0 | 113 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriverTest.java | ||
---|---|---|
1 |
package org.gvsig.catalog.catalog.drivers; |
|
2 |
|
|
3 |
import javax.swing.UIManager; |
|
4 |
import javax.swing.UnsupportedLookAndFeelException; |
|
5 |
|
|
6 |
import org.gvsig.catalog.CatalogLocator; |
|
7 |
import org.gvsig.catalog.ui.serverconnect.ServerConnectDialog; |
|
8 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
9 |
|
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id: ExampleNewDriverTest.java 512 2007-07-24 11:25:43Z jorpiell $ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1.2.2 2007/07/24 11:25:42 jorpiell |
|
56 |
* The registers has been refactorized |
|
57 |
* |
|
58 |
* Revision 1.1.2.1 2007/07/13 12:00:35 jorpiell |
|
59 |
* Add the posibility to add a new panel |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
65 |
*/ |
|
66 |
public class ExampleNewDriverTest { |
|
67 |
|
|
68 |
/** |
|
69 |
* @param args |
|
70 |
*/ |
|
71 |
public static void main(String[] args) { |
|
72 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
73 |
// DefaultCatalogLibrary library = new DefaultCatalogLibrary(); |
|
74 |
// library.initialize(); |
|
75 |
// library.postInitialize(); |
|
76 |
|
|
77 |
CatalogLocator.getCatalogManager().register("My catalog service", ExampleNewDriver.class); |
|
78 |
//Get the currently installed look and feel |
|
79 |
UIManager.getLookAndFeel(); |
|
80 |
// Install a different look and feel; specifically, the Windows look and feel |
|
81 |
try { |
|
82 |
UIManager.setLookAndFeel( |
|
83 |
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
|
84 |
} catch (InstantiationException e) { |
|
85 |
} catch (ClassNotFoundException e) { |
|
86 |
} catch (UnsupportedLookAndFeelException e) { |
|
87 |
} catch (IllegalAccessException e) { |
|
88 |
} |
|
89 |
|
|
90 |
new ServerConnectDialog(); |
|
91 |
} |
|
92 |
|
|
93 |
} |
|
0 | 94 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewPanel.java | ||
---|---|---|
1 |
package org.gvsig.catalog.catalog.drivers; |
|
2 |
|
|
3 |
import java.util.Properties; |
|
4 |
|
|
5 |
import javax.swing.JLabel; |
|
6 |
import javax.swing.JTextField; |
|
7 |
|
|
8 |
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel; |
|
9 |
|
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id: ExampleNewPanel.java 537 2007-07-26 11:21:10Z jpiera $ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1.2.1 2007/07/13 12:00:35 jorpiell |
|
56 |
* Add the posibility to add a new panel |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
62 |
*/ |
|
63 |
public class ExampleNewPanel extends SearchAditionalPropertiesPanel{ |
|
64 |
JLabel label = null; |
|
65 |
JTextField text = null; |
|
66 |
|
|
67 |
public ExampleNewPanel(){ |
|
68 |
label = new JLabel(); |
|
69 |
text = new JTextField(); |
|
70 |
setLayout(new java.awt.BorderLayout()); |
|
71 |
label.setText("Label"); |
|
72 |
add(label, java.awt.BorderLayout.WEST); |
|
73 |
add(text, java.awt.BorderLayout.CENTER); |
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see es.gva.cit.gazetteer.ui.search.SearchAditionalPropertiesPanel#getProperties() |
|
79 |
*/ |
|
80 |
public Properties getProperties() { |
|
81 |
Properties properties = new Properties(); |
|
82 |
properties.put("PROP1", text.getText()); |
|
83 |
return properties; |
|
84 |
} |
|
85 |
|
|
86 |
} |
|
0 | 87 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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/tags/org.gvsig.catalog-2.0.61/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 |
* This class implements the Filter Encoding Language. It is used to |
|
49 |
* create queries in this language |
|
50 |
* @author Jorge Piera Llodra (jorge.piera@iver.es) |
|
51 |
* @see http://portal.opengeospatial.org/files/?artifact_id=8340 |
|
52 |
*/ |
|
53 |
public class FilterEncoding extends AbstractGeneralLanguage { |
|
54 |
//Properties |
|
55 |
public static final String PROPERTY_IS_LIKE = "PropertyIsLike"; |
|
56 |
public static final String PROPERTY_IS_LESS = "PropertyIsLess"; |
|
57 |
public static final String PROPERTY_IS_GREATER = "PropertyIsGreater"; |
|
58 |
public static final String PROPERTY_IS_GREATER_THAN = "PropertyIsGreaterThan"; |
|
59 |
public static final String PROPERTY_IS_LESS_THAN = "PropertyIsLessThan"; |
|
60 |
public static final String PROPERTY_IS_EQUALS_TO = "PropertyIsEqualTo"; |
|
61 |
//Type options |
|
62 |
public static final String TYPE_LITERAL = "Literal"; |
|
63 |
public static final String TYPE_TWO_PROPERTIES = "PropertyName"; |
|
64 |
//Default values |
|
65 |
public static final String DEFAULT_PREFIX = "ogc"; |
|
66 |
public static final String DEFAULT_WILDCARD = "*"; |
|
67 |
public static final String DEFAULT_SINGLECHAR = "?"; |
|
68 |
public static final String DEFAULT_ESCAPE = "\\"; |
|
69 |
public static final String DEFAULT_NAMESPACE = "xmlns:ogc=\"http://www.opengis.net/ogc\""; |
|
70 |
//Private labels |
|
71 |
private static final String FILTER = "Filter"; |
|
72 |
|
|
73 |
private String prefix = null; |
|
74 |
private String wildCard = null; |
|
75 |
private String singleChar = null; |
|
76 |
private String escape = null; |
|
77 |
private String namespace = null; |
|
78 |
private String wildCardLabel = "wildCard"; |
|
79 |
private String escapeCharLabel = "escapeChar"; |
|
80 |
private String singleCharLabel = "singleChar"; |
|
81 |
|
|
82 |
/** |
|
83 |
* Create a new Filter Encoding Parser |
|
84 |
* @param prefix Prefix of the labels (if its necessary). |
|
85 |
* Typically "ogc". |
|
86 |
* @param wildCard It Depends of the server |
|
87 |
* @param singleChar It Depends of the server |
|
88 |
* @param escape It Depends of the server |
|
89 |
*/ |
|
90 |
public FilterEncoding(String prefix, String wildCard, String singleChar, String escape) { |
|
91 |
this.prefix = prefix + ":"; |
|
92 |
this.wildCard = wildCard; |
|
93 |
this.singleChar = singleChar; |
|
94 |
this.escape = escape; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Create a new Filter Encoding Parser with the |
|
99 |
* deafault values |
|
100 |
*/ |
|
101 |
public FilterEncoding() { |
|
102 |
this.prefix = DEFAULT_PREFIX + ":"; |
|
103 |
this.wildCard = DEFAULT_WILDCARD; |
|
104 |
this.singleChar = DEFAULT_SINGLECHAR; |
|
105 |
this.escape = DEFAULT_ESCAPE; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* It Adds a new clause of the query |
|
110 |
* @param propertyName The property name |
|
111 |
* @param propertyValue The property value |
|
112 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
113 |
* or "Y" (anY word). |
|
114 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
115 |
* Documentation. |
|
116 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
117 |
* and one literal value) |
|
118 |
* @param operator "And" or "Or". Operator between fields |
|
119 |
*/ |
|
120 |
public void addClauses(String propertyName, String propertyValue, |
|
121 |
String concordancia, String relationship, String type, |
|
122 |
String operator) { |
|
123 |
currentClause = null; |
|
124 |
//Seperating the words |
|
125 |
Iterator values = parseValues(propertyValue, concordancia, relationship, wildCard); |
|
126 |
//Filling the words |
|
127 |
addClauses(propertyName, values, concordancia, relationship, type, operator); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* It Adds a new clause of the query |
|
132 |
* @param propertyName The property name |
|
133 |
* @param propertyValue The property value |
|
134 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
135 |
* or "Y" (anY word). |
|
136 |
*/ |
|
137 |
public void addClauses(String propertyName, String propertyValue, |
|
138 |
String concordancia) { |
|
139 |
addClauses(propertyName, propertyValue, concordancia, |
|
140 |
FilterEncoding.PROPERTY_IS_LIKE, |
|
141 |
FilterEncoding.TYPE_LITERAL, |
|
142 |
FilterEncoding.AND); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* It Adds a new clause of the query |
|
147 |
* @param propertyName The property name |
|
148 |
* @param propertyValues The property value separated by blank spaces |
|
149 |
* @param concordancia "E" (Exact phrase), "A" (All words) |
|
150 |
* or "Y" (anY word). |
|
151 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
152 |
* Documentation. |
|
153 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
154 |
* and one literal value) |
|
155 |
* @param operator "And" or "Or". Operator between fields |
|
156 |
*/ |
|
157 |
public void addClauses(String propertyName, Iterator propertyValues, |
|
158 |
String concordancia, String relationship, String type, |
|
159 |
String operator) { |
|
160 |
while (propertyValues.hasNext()) |
|
161 |
addTerm(propertyName, (String) propertyValues.next(), concordancia, |
|
162 |
relationship, type); |
|
163 |
addCurrentClauseQuery(operator); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* It adds a new term to the full query |
|
168 |
* @param propertyName The property name |
|
169 |
* @param propertyValue The property value |
|
170 |
* @param concordancia "E" (Exact phrase), "A" (All words) or "Y" (anY word). |
|
171 |
* @param relationship PropertyIsLike, PropertyIsLess, PropertyIsGreater,... See the File encoding |
|
172 |
* Documentation. |
|
173 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
174 |
* and one literal value) |
|
175 |
*/ |
|
176 |
private void addTerm(String propertyName, String propertyValue, |
|
177 |
String concordancia, String relationship, String type) { |
|
178 |
StringBuffer term = new StringBuffer(); |
|
179 |
term.append(propertyIsXXX(relationship, propertyName, propertyValue, type)); |
|
180 |
if (currentClause == null) { |
|
181 |
currentClause = term.toString(); |
|
182 |
} else { |
|
183 |
currentClause = currentClause + term.toString(); |
|
184 |
currentClause = enterLabel(currentClause, getOperator(concordancia)); |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* It adds the "and" label to join different operations |
|
190 |
* @param operator |
|
191 |
*/ |
|
192 |
protected void addCurrentClauseQuery(String operator) { |
|
193 |
if (currentClause != null) { |
|
194 |
if (currentQuery == null) { |
|
195 |
currentQuery = currentClause; |
|
196 |
} else { |
|
197 |
currentQuery = currentQuery + currentClause; |
|
198 |
currentQuery = enterLabel(currentQuery, operator); |
|
199 |
} |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* It returns the encoded query |
|
205 |
* @return |
|
206 |
*/ |
|
207 |
public String toString() { |
|
208 |
return enterLabel(currentQuery, FILTER); |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* Involves a query with a label |
|
213 |
* @param query Query to involve |
|
214 |
* @param label Label name |
|
215 |
* @return a filter encoding query |
|
216 |
*/ |
|
217 |
private String enterLabel(String query, String label) { |
|
218 |
if (label.equals(FILTER) && (this.namespace != null)) { |
|
219 |
return "<" + prefix + label + " " + this.namespace + ">" + |
|
220 |
query + "</" + prefix + label + ">"; |
|
221 |
} else { |
|
222 |
return "<" + prefix + label + ">" + query + "</" + prefix + |
|
223 |
label + ">"; |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* It writes a "PropertyIsXXX" part of a filter encoding query |
|
229 |
* @param relationship Possible Values: PropertIsLike, PropertyIsLess, |
|
230 |
* PropertyIsGreater,... See the Filter Encoding documentation |
|
231 |
* @param propertyName The property name |
|
232 |
* @param propertyValue The property value |
|
233 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
234 |
* and one literal value) |
|
235 |
* @return The part of the query |
|
236 |
*/ |
|
237 |
private String propertyIsXXX(String relationship, String propertyName, |
|
238 |
String propertyValue, String type) { |
|
239 |
String cadena = ""; |
|
240 |
cadena = "<" + prefix + relationship; |
|
241 |
if (relationship.equals("PropertyIsLike")) { |
|
242 |
if (this.wildCard != null) { |
|
243 |
cadena = cadena + " " + getWildCardLabel() + "=\"" + this.wildCard + "\""; |
|
244 |
} |
|
245 |
if (this.singleChar != null) { |
|
246 |
cadena = cadena + " " + getSingleCharLabel() + "=\"" + this.singleChar + "\""; |
|
247 |
} |
|
248 |
if (this.escape != null) { |
|
249 |
cadena = cadena + " " + getEscapeCharLabel() + "=\"" + this.escape + "\""; |
|
250 |
} |
|
251 |
} |
|
252 |
cadena = cadena + ">" + enterLabel(propertyName, TYPE_TWO_PROPERTIES); |
|
253 |
cadena = cadena + enterLabel(propertyValue, type); |
|
254 |
return cadena + "</" + prefix + relationship + ">"; |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* It Adds a Bounding Box query |
|
259 |
* |
|
260 |
* |
|
261 |
* @param coordinates Coordinates to find |
|
262 |
* @param propertyName Property that contains the geom field |
|
263 |
* @param not If we have to envolve the query with the "NOT" tag. |
|
264 |
*/ |
|
265 |
public void addBoundingBox(Coordinates coordinates, String propertyName, boolean not) { |
|
266 |
// sNorth -> Uly(); |
|
267 |
// sWest -> Ulx(); |
|
268 |
// sSouth -> Bry(); |
|
269 |
// sEast -> Brx(); |
|
270 |
String bbox = "<ogc:BBOX>" + "<ogc:PropertyName>" + propertyName + |
|
271 |
"</ogc:PropertyName>" + "<gml:Box>" + "<gml:coord>" + "<gml:X>" + |
|
272 |
coordinates.ulx + "</gml:X>" + "<gml:Y>" + coordinates.bry + |
|
273 |
"</gml:Y>" + "</gml:coord>" + "<gml:coord>" + "<gml:X>" + |
|
274 |
coordinates.brx + "</gml:X>" + "<gml:Y>" + coordinates.uly + |
|
275 |
"</gml:Y>" + "</gml:coord>" + "</gml:Box>" + "</ogc:BBOX>"; |
|
276 |
if (not){ |
|
277 |
bbox = "<ogc:Not>" + bbox + "</ogc:Not>"; |
|
278 |
} |
|
279 |
if (currentQuery == null) { |
|
280 |
currentQuery = bbox; |
|
281 |
} else { |
|
282 |
currentQuery = currentQuery + bbox; |
|
283 |
currentQuery = enterLabel(currentQuery, "And"); |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
/** |
|
288 |
* @return the wildCard |
|
289 |
*/ |
|
290 |
public String getWildCard() { |
|
291 |
return wildCard; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* @return the wildCardLabel |
|
296 |
*/ |
|
297 |
public String getWildCardLabel() { |
|
298 |
return wildCardLabel; |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* @param wildCardLabel the wildCardLabel to set |
|
303 |
*/ |
|
304 |
public void setWildCardLabel(String wildCardLabel) { |
|
305 |
this.wildCardLabel = wildCardLabel; |
|
306 |
} |
|
307 |
|
|
308 |
/** |
|
309 |
* @return the escapeCharLabel |
|
310 |
*/ |
|
311 |
public String getEscapeCharLabel() { |
|
312 |
return escapeCharLabel; |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* @param escapeCharLabel the escapeCharLabel to set |
|
317 |
*/ |
|
318 |
public void setEscapeCharLabel(String escapeCharLabel) { |
|
319 |
this.escapeCharLabel = escapeCharLabel; |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* @return the singleCharLabel |
|
324 |
*/ |
|
325 |
public String getSingleCharLabel() { |
|
326 |
return singleCharLabel; |
|
327 |
} |
|
328 |
|
|
329 |
/** |
|
330 |
* @param singleCharLabel the singleCharLabel to set |
|
331 |
*/ |
|
332 |
public void setSingleCharLabel(String singleCharLabel) { |
|
333 |
this.singleCharLabel = singleCharLabel; |
|
334 |
} |
|
335 |
} |
|
0 | 336 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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 |
|
|
0 | 61 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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 |
} |
|
0 | 158 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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 |
} |
|
0 | 153 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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 |
//en la ver. de CSW 2.0.2 no funciona el filtro si no es may. |
|
59 |
public static final String and = "and"; |
|
60 |
public static final String or = "or"; |
|
61 |
|
|
62 |
protected String currentQuery = null; |
|
63 |
protected String currentClause = null; |
|
64 |
|
|
65 |
/** |
|
66 |
* Divide a phrase in lines |
|
67 |
* @param concordancia If is 'E' (exact) don't divide |
|
68 |
* @return Iteraror |
|
69 |
* A set of words |
|
70 |
* @param line phrase to search |
|
71 |
* @param titleKeys |
|
72 |
*/ |
|
73 |
public Iterator parseValues(String line, String titleKeys){ |
|
74 |
return parseValues(line, titleKeys, FilterEncoding.PROPERTY_IS_EQUALS_TO, null); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Divide a phrase in lines |
|
79 |
*@param concordancia If is 'E' (exact) don't divide |
|
80 |
* @return Iteraror |
|
81 |
* A set of words |
|
82 |
* @param line phrase to search |
|
83 |
* @param titleKeys |
|
84 |
* @param relationship |
|
85 |
* @param wildCard |
|
86 |
*/ |
|
87 |
public Iterator parseValues(String line, String titleKeys, String relationship, String wildCard) { |
|
88 |
Vector values = new Vector(); |
|
89 |
|
|
90 |
if (titleKeys == null){ |
|
91 |
titleKeys = EXACT_WORDS; |
|
92 |
} |
|
93 |
|
|
94 |
if (titleKeys.equals(EXACT_WORDS)) { |
|
95 |
values.add(line); |
|
96 |
return values.iterator(); |
|
97 |
} |
|
98 |
StringTokenizer doubleQuotesTokenizer = new StringTokenizer(line, "\"", |
|
99 |
true); |
|
100 |
boolean inside = false; |
|
101 |
while (doubleQuotesTokenizer.hasMoreTokens()) { |
|
102 |
String token = doubleQuotesTokenizer.nextToken(); |
|
103 |
if (token.equals("\"")) { |
|
104 |
inside = !inside; |
|
105 |
} else if (inside) { |
|
106 |
if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0){ |
|
107 |
token = wildCard + token + wildCard; |
|
108 |
} |
|
109 |
values.add(token); |
|
110 |
} else { |
|
111 |
StringTokenizer spaceTokenizer = new StringTokenizer(token, " "); |
|
112 |
while (spaceTokenizer.hasMoreTokens()) { |
|
113 |
String value = spaceTokenizer.nextToken(); |
|
114 |
if (relationship.compareTo(FilterEncoding.PROPERTY_IS_LIKE) == 0){ |
|
115 |
value = wildCard + value + wildCard; |
|
116 |
} |
|
117 |
values.add(value); |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
return values.iterator(); |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Return logic operators |
|
126 |
* @return Or or And |
|
127 |
* @param titleKeys E,A o Y --> Exact, All, anY |
|
128 |
*/ |
|
129 |
public String getOperator(String titleKeys) { |
|
130 |
if (titleKeys == null){ |
|
131 |
titleKeys = EXACT_WORDS; |
|
132 |
} |
|
133 |
if (titleKeys.equals(ANY_WORDS)) { |
|
134 |
return OR; |
|
135 |
} else { |
|
136 |
return AND; |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
0 | 140 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.61/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 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
14 |
import org.gvsig.catalog.drivers.IDiscoveryServiceDriver; |
|
15 |
import org.gvsig.catalog.exceptions.NotSupportedProtocolException; |
|
16 |
import org.gvsig.catalog.exceptions.NotSupportedVersionException; |
|
17 |
import org.gvsig.catalog.exceptions.ServerIsNotReadyException; |
|
18 |
import org.gvsig.catalog.querys.DiscoveryServiceQuery; |
|
19 |
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel; |
|
20 |
import org.gvsig.catalog.utils.URIUtils; |
|
21 |
|
|
22 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
23 |
* |
|
24 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
25 |
* |
|
26 |
* This program is free software; you can redistribute it and/or |
|
27 |
* modify it under the terms of the GNU General Public License |
|
28 |
* as published by the Free Software Foundation; either version 2 |
|
29 |
* of the License, or (at your option) any later version. |
|
30 |
* |
|
31 |
* This program is distributed in the hope that it will be useful, |
|
32 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
33 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
34 |
* GNU General Public License for more details. |
|
35 |
* |
|
36 |
* You should have received a copy of the GNU General Public License |
|
37 |
* along with this program; if not, write to the Free Software |
|
38 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
39 |
* |
|
40 |
* For more information, contact: |
|
41 |
* |
|
42 |
* Generalitat Valenciana |
|
43 |
* Conselleria d'Infraestructures i Transport |
|
44 |
* Av. Blasco Ib??ez, 50 |
|
45 |
* 46010 VALENCIA |
|
46 |
* SPAIN |
|
47 |
* |
|
48 |
* +34 963862235 |
|
49 |
* gvsig@gva.es |
|
50 |
* www.gvsig.gva.es |
|
51 |
* |
|
52 |
* or |
|
53 |
* |
|
54 |
* IVER T.I. S.A |
|
55 |
* Salamanca 50 |
|
56 |
* 46005 Valencia |
|
57 |
* Spain |
|
58 |
* |
|
59 |
* +34 963163400 |
|
60 |
* dac@iver.es |
|
61 |
*/ |
|
62 |
/* CVS MESSAGES: |
|
63 |
* |
|
64 |
* $Id$ |
|
65 |
* $Log$ |
|
66 |
* |
|
67 |
*/ |
|
68 |
/** |
|
69 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
70 |
*/ |
|
71 |
public class DiscoveryServiceClient { |
|
72 |
/** |
|
73 |
* The server URI |
|
74 |
*/ |
|
75 |
private URI uri = null; |
|
76 |
/** |
|
77 |
* The driver to make the querys |
|
78 |
*/ |
|
79 |
private IDiscoveryServiceDriver driver; |
|
80 |
/** |
|
81 |
* The service capabilities |
|
82 |
*/ |
|
83 |
private DiscoveryServiceCapabilities capabilities; |
|
84 |
/** |
|
85 |
* The server status message |
|
86 |
*/ |
|
87 |
private String serverStatus = null; |
|
88 |
|
|
89 |
public DiscoveryServiceClient(String sUri,IDiscoveryServiceDriver driver) { |
|
90 |
setDriver(driver); |
|
91 |
if (driver == null){ |
|
92 |
serverStatus = "errorServerNotFound"; |
|
93 |
}else{ |
|
94 |
try { |
|
95 |
this.uri = URIUtils.createUri(sUri, |
|
96 |
driver.getDefaultSchema(), |
|
97 |
driver.getDefaultPort()); |
|
98 |
} catch (URISyntaxException e) { |
|
99 |
serverStatus = "errorServerNotFound"; |
|
100 |
} |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* It make a getCapabilities operation |
|
106 |
* @return the service version |
|
107 |
* @throws ServerIsNotReadyException |
|
108 |
*/ |
|
109 |
public DiscoveryServiceCapabilities getCapabilities() throws ServerIsNotReadyException { |
|
110 |
if (serverIsReady()){ |
|
111 |
try { |
|
112 |
if (getDriver().isProtocolSupported(getUri())) { |
|
113 |
capabilities = getDriver().getCapabilities(getUri()); |
|
114 |
return capabilities; |
|
115 |
} |
|
116 |
} catch (NotSupportedProtocolException e) { |
|
117 |
capabilities = new DiscoveryServiceCapabilities(); |
|
118 |
capabilities.setAvailable(false); |
|
119 |
capabilities.setServerMessage("notSupportedProtocol"); |
|
120 |
} catch (NotSupportedVersionException e) { |
|
121 |
capabilities = new DiscoveryServiceCapabilities(); |
|
122 |
capabilities.setAvailable(false); |
|
123 |
capabilities.setServerMessage("notSupportedVersion"); |
|
124 |
} |
|
125 |
} |
|
126 |
return capabilities; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* It tries if the server is ready |
Also available in: Unified diff