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 40846 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 42775 jjdelcerro
 * 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 40846 jjdelcerro
 *
11 42775 jjdelcerro
 * 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 40846 jjdelcerro
 *
16 42775 jjdelcerro
 * 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 40846 jjdelcerro
 *
20 42775 jjdelcerro
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22 40846 jjdelcerro
 */
23 47643 jjdelcerro
package org.gvsig.fmap.dal.store.json;
24 40846 jjdelcerro
25 45836 fdiaz
import java.io.IOException;
26 47636 fdiaz
import java.io.Reader;
27 40846 jjdelcerro
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 47638 jjdelcerro
import org.gvsig.fmap.dal.store.gml.simplereaders.GMLReader;
32 47643 jjdelcerro
import org.gvsig.fmap.dal.store.json.simplereaders.JsonReader;
33 47638 jjdelcerro
import org.gvsig.fmap.dal.store.simplereader.simplereaders.SimpleReader;
34 47636 fdiaz
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 40846 jjdelcerro
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39
40 44309 omartinez
@SuppressWarnings("UseSpecificCatch")
41 47643 jjdelcerro
public class JsonStoreProvider extends SimpleReaderStoreProvider implements
42 41617 jjdelcerro
        ResourceConsumer {
43
44 47643 jjdelcerro
    private static final Logger LOGGER = LoggerFactory.getLogger(JsonStoreProvider.class);
45 40846 jjdelcerro
46 47643 jjdelcerro
    public static final String NAME = "Json";
47
    public static final String DESCRIPTION = "Json file";
48 40846 jjdelcerro
49
    public static final String METADATA_DEFINITION_NAME = NAME;
50
51 45721 jjdelcerro
    @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
52 47643 jjdelcerro
    public JsonStoreProvider(
53
            JsonStoreParameters parameters,
54 47199 jjdelcerro
            DataStoreProviderServices storeServices
55
        ) throws InitializeException {
56 40846 jjdelcerro
        super(
57 41617 jjdelcerro
                parameters,
58
                storeServices,
59
                FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME)
60 40846 jjdelcerro
        );
61
    }
62
63 47643 jjdelcerro
    private JsonStoreParameters getJsonParameters() {
64
        return (JsonStoreParameters) this.getParameters();
65 40846 jjdelcerro
    }
66
67 44309 omartinez
    @Override
68 40846 jjdelcerro
    public String getProviderName() {
69
        return NAME;
70
    }
71
72 44309 omartinez
    @Override
73 47636 fdiaz
    protected SimpleReader getSimpleReader(SimpleReaderStoreParameters parameters, Reader in) throws IOException {
74 47643 jjdelcerro
        SimpleReader reader = new JsonReader(in, (JsonStoreParameters) parameters);
75 47636 fdiaz
        return reader;
76 40846 jjdelcerro
    }
77
78 44309 omartinez
    @Override
79 47636 fdiaz
    protected SimpleReaderFeatureTypeLoader getFeatureTypeLoader() {
80 47643 jjdelcerro
        return new JsonFeatureTypeLoader(getJsonParameters());
81 40846 jjdelcerro
    }
82
83
}