Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.csv / src / main / java / org / gvsig / fmap / dal / store / json / JsonStoreProvider.java @ 47643

History | View | Annotate | Download (3.08 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.store.json;
24

    
25
import java.io.IOException;
26
import java.io.Reader;
27
import org.gvsig.fmap.dal.FileHelper;
28
import org.gvsig.fmap.dal.exception.InitializeException;
29
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
30
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
31
import org.gvsig.fmap.dal.store.gml.simplereaders.GMLReader;
32
import org.gvsig.fmap.dal.store.json.simplereaders.JsonReader;
33
import org.gvsig.fmap.dal.store.simplereader.simplereaders.SimpleReader;
34
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderFeatureTypeLoader;
35
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreParameters;
36
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreProvider;
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

    
40
@SuppressWarnings("UseSpecificCatch")
41
public class JsonStoreProvider extends SimpleReaderStoreProvider implements
42
        ResourceConsumer {
43

    
44
    private static final Logger LOGGER = LoggerFactory.getLogger(JsonStoreProvider.class);
45

    
46
    public static final String NAME = "Json";
47
    public static final String DESCRIPTION = "Json file";
48

    
49
    public static final String METADATA_DEFINITION_NAME = NAME;
50

    
51
    @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
52
    public JsonStoreProvider(
53
            JsonStoreParameters parameters,
54
            DataStoreProviderServices storeServices
55
        ) throws InitializeException {
56
        super(
57
                parameters,
58
                storeServices,
59
                FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
60
        );
61
    }
62

    
63
    private JsonStoreParameters getJsonParameters() {
64
        return (JsonStoreParameters) this.getParameters();
65
    }
66

    
67
    @Override
68
    public String getProviderName() {
69
        return NAME;
70
    }
71

    
72
    @Override
73
    protected SimpleReader getSimpleReader(SimpleReaderStoreParameters parameters, Reader in) throws IOException {
74
        SimpleReader reader = new JsonReader(in, (JsonStoreParameters) parameters);
75
        return reader;
76
    }
77

    
78
    @Override
79
    protected SimpleReaderFeatureTypeLoader getFeatureTypeLoader() {
80
        return new JsonFeatureTypeLoader(getJsonParameters());
81
    }
82

    
83
}