Statistics
| Revision:

root / trunk / applications / appCatalogAndGazetteerClient / src / es / gva / cit / catalog / protocols / Z3950Protocol.java @ 15558

History | View | Annotate | Download (3.55 KB)

1
package es.gva.cit.catalog.protocols;
2

    
3
import java.net.URI;
4
import java.util.StringTokenizer;
5

    
6
import org.jzkit.search.provider.iface.SearchException;
7
import org.jzkit.search.util.ResultSet.IRResultSetException;
8

    
9
import es.gva.cit.catalog.drivers.GetRecordsReply;
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: Z3950Protocol.java 561 2007-07-27 06:49:30 +0000 (Fri, 27 Jul 2007) jpiera $
54
 * $Log$
55
 * Revision 1.21.2.2.4.3  2007/07/23 07:14:25  jorpiell
56
 * Catalog refactoring
57
 *
58
 * Revision 1.21.2.2.4.2  2007/07/13 12:00:35  jorpiell
59
 * Add the posibility to add a new panel
60
 *
61
 * Revision 1.21.2.2.4.1  2007/07/10 11:18:04  jorpiell
62
 * Added the registers
63
 *
64
 * Revision 1.21.2.2  2006/11/15 00:08:08  jjdelcerro
65
 * *** empty log message ***
66
 *
67
 * Revision 1.23  2006/10/02 08:29:07  jorpiell
68
 * Modificados los cambios del Branch 10 al head
69
 *
70
 * Revision 1.21.2.1  2006/09/20 12:01:18  jorpiell
71
 * Se ha cambiado la versi?n de la jzkit, se ha incorporado la funcionalidad de cargar arcims
72
 *
73
 * Revision 1.22  2006/09/20 11:20:17  jorpiell
74
 * Se ha cambiado la versi?n de la librer?a jzkit de la 1 a la 2.0
75
 *
76
 *
77
 */
78
/**
79
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
80
 */
81
public class Z3950Protocol {
82

    
83
        /**
84
           * Makes a query
85
           * @param url
86
           * @param object
87
           * @param firstRecord
88
           * @return
89
         * @throws IRResultSetException 
90
         * @throws SearchException 
91
           */
92
          public GetRecordsReply doQuery(GetRecordsReply recordsReply, URI uri, Object object, int firstRecord){    
93
                  Z3950Connection connection = Z3950ConnectionFactory.getConnection(uri);
94
                  return connection.search(recordsReply,(String)object,firstRecord);
95
         }  
96

    
97
          
98
          /**
99
           * 
100
           * @param url
101
           * @return
102
           */
103
          public String openConnection(URI uri) {      
104
                  Z3950Connection connection = Z3950ConnectionFactory.getConnection(uri);
105
                  return connection.connect();
106
          }
107
          
108
          /**
109
           * 
110
           * @param url
111
           * @return
112
           */
113
          public boolean isProtocolSupported(URI uri) {    
114
             Z3950Connection connection = Z3950ConnectionFactory.getConnection(uri);
115
             if (connection.connect() == null){
116
                     return false;
117
             }
118
             return true;
119
          }
120

    
121
          /**
122
           * Return the database
123
           * @param url
124
           * @return
125
           */
126
          public static String getDatabase(URI uri) {
127
                  StringTokenizer sti = new StringTokenizer(uri.getPath(), "/");
128
                  if (sti.countTokens() == 0) {
129
                          return "geo";
130
                  } else {
131
                          return sti.nextToken();
132
                  }
133
          }
134
}