Statistics
| Revision:

root / branches / CatalogYNomenclator_v1_1_0_1005 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / schemas / records / RecordFactory.java @ 12733

History | View | Annotate | Download (2.98 KB)

1
package es.gva.cit.catalogClient.schemas.records;
2

    
3
import java.lang.reflect.InvocationTargetException;
4
import java.net.URI;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7

    
8
import com.iver.utiles.swing.jcomboServer.ServerData;
9

    
10
import es.gva.cit.catalogClient.metadataxml.XMLNode;
11

    
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: RecordFactory.java 12733 2007-07-23 07:14:25Z jorpiell $
55
 * $Log$
56
 * Revision 1.1.2.1  2007-07-23 07:14:24  jorpiell
57
 * Catalog refactoring
58
 *
59
 *
60
 */
61
/**
62
 * This class creates a parsed record from a uri and a 
63
 * XMLNode. 
64
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
65
 */
66
public class RecordFactory {
67
        private static ArrayList records = null; 
68
        
69
        static{
70
                records = new ArrayList();
71
                records.add(new GeonetworkISO19115Record());
72
                records.add(new DeegreeISO19115Record());
73
                records.add(new DublinCoreRecord());
74
                records.add(new IdecISO19115Record());
75
                records.add(new IdeeISO19115Record());
76
                records.add(new Iso19139Record());
77
                records.add(new LaitsGmuRecord());
78
                records.add(new LaitsGmuServicesRecord());
79
        }
80
        
81
        /**
82
         * Adds a new record
83
         * @param record
84
         * New record to add
85
         */
86
        public static void addRecord(Record record){
87
                records.add(record);
88
        }
89
        
90
        
91
        /**
92
         * Try to identify the XML format and return a record
93
         * @param uri
94
         * Server URI (used to retrieve the images)
95
         * @param node
96
         * XML node
97
         * @return
98
         */
99
        public static Record createRecord(URI uri, XMLNode node){
100
                for (int i=0 ; i<records.size() ; i++){
101
                        Record record = (Record)records.get(i);
102
                        if (record.accept(uri, node)){
103
                                Object[] values = {uri, node};
104
                                Class[] types = {URI.class, XMLNode.class}; 
105
                                try {
106
                                        return (Record)record.getClass().getConstructor(types).newInstance(values);
107
                                } catch (Exception e) {
108
                                        //It the instance can be created the 
109
                                        //default record has to be returned
110
                                } 
111
                        }                        
112
                }
113
                return new UnknownRecord(uri,node);        
114
        }
115
}