root / trunk / applications / appCatalogAndGazetteerClient / src / es / gva / cit / catalog / csw / messages / CSWMessagesFactory.java @ 15558
History | View | Annotate | Download (2.6 KB)
1 |
package es.gva.cit.catalog.csw.messages; |
---|---|
2 |
|
3 |
import java.lang.reflect.InvocationTargetException; |
4 |
import java.util.HashMap; |
5 |
|
6 |
import org.gvsig.i18n.Messages; |
7 |
|
8 |
import es.gva.cit.catalog.csw.drivers.profiles.CSWAbstractProfile; |
9 |
import es.gva.cit.catalog.csw.parsers.CSWConstants; |
10 |
import es.gva.cit.catalog.exceptions.NotSupportedVersionException; |
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$
|
54 |
* $Log$
|
55 |
*
|
56 |
*/
|
57 |
/**
|
58 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
59 |
*/
|
60 |
public class CSWMessagesFactory { |
61 |
private static HashMap messages = null; |
62 |
|
63 |
static{
|
64 |
messages = new HashMap(); |
65 |
messages.put(CSWConstants.VERSION_2_0_0, CSWMessages2_0_0.class); |
66 |
messages.put(CSWConstants.VERSION_2_0_1, CSWMessages2_0_1.class); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* Gets a messages class
|
71 |
* @param version
|
72 |
* The CSW version
|
73 |
* @param profile
|
74 |
* The CSW profile
|
75 |
* @return
|
76 |
* A CSWAbstractMessages class
|
77 |
* @throws NotSupportedVersionException
|
78 |
*/
|
79 |
public static CSWAbstractMessages getMessages(String version, CSWAbstractProfile profile) throws NotSupportedVersionException{ |
80 |
if ((version != null) && (messages.containsKey(version))){ |
81 |
Class clazz = (Class)messages.get(version); |
82 |
Class[] parameters = {CSWAbstractProfile.class}; |
83 |
Object[] args = {profile}; |
84 |
try {
|
85 |
return (CSWAbstractMessages)clazz.getConstructor(parameters).newInstance(args);
|
86 |
} catch (Exception e) { |
87 |
throw new NotSupportedVersionException(e); |
88 |
} |
89 |
} |
90 |
throw new NotSupportedVersionException(); |
91 |
} |
92 |
} |