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.json / src / main / java / org / gvsig / fmap / dal / store / json / JsonStoreProvider.java @ 47655

History | View | Annotate | Download (3.02 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.json.simplereaders.JsonReader;
32
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderFeatureTypeLoader;
33
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreParameters;
34
import org.gvsig.fmap.dal.store.simplereader.SimpleReaderStoreProvider;
35
import org.gvsig.fmap.dal.store.simplereader.simplereaders.SimpleReader;
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

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

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

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

    
48
    public static final String METADATA_DEFINITION_NAME = NAME;
49

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

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

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

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

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

    
82
}