Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / raster / spi / AbstractCoverageStoreProvider.java @ 27723

History | View | Annotate | Download (5.04 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.raster.spi;
32

    
33
import org.gvsig.fmap.dal.DALLocator;
34
import org.gvsig.fmap.dal.DataServerExplorer;
35
import org.gvsig.fmap.dal.exception.CloseException;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.InitializeException;
38
import org.gvsig.fmap.dal.exception.OpenException;
39
import org.gvsig.fmap.dal.exception.ReadException;
40
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
41
import org.gvsig.fmap.dal.raster.CoverageSelection;
42
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
43
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
44
import org.gvsig.fmap.geom.primitive.Envelope;
45
import org.gvsig.tools.dynobject.DelegatedDynObject;
46
import org.gvsig.tools.dynobject.DynClass;
47
import org.gvsig.tools.dynobject.DynObject;
48
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
49
import org.gvsig.tools.dynobject.exception.DynMethodException;
50
import org.slf4j.Logger;
51
import org.slf4j.LoggerFactory;
52

    
53

    
54
/**
55
 * @author jmvivo
56
 *
57
 */
58
public abstract class AbstractCoverageStoreProvider implements
59
                CoverageStoreProvider {
60
        protected CoverageStoreProviderServices store;
61
        protected Logger logger;
62
        protected DelegatedDynObject dynObject;
63

    
64
        public AbstractCoverageStoreProvider() {
65
                this.store = null;
66
                this.logger = null;
67
                this.dynObject = null;
68
        }
69

    
70
        public CoverageStoreProvider initialize(CoverageStoreProviderServices store)
71
                        throws InitializeException {
72
                this.store = store;
73
                return this;
74
        }
75

    
76
        protected ResourceProvider createResource(String type, Object[] params)
77
                        throws InitializeException {
78
                ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
79
                                .getResourceManager();
80
                ResourceProvider resource = manager.createResource(type, params);
81
                return resource;
82
        }
83

    
84
        public CoverageStoreProviderServices getStoreServices() {
85
                return this.store;
86
        }
87

    
88
        public String getClassName() {
89
                return this.getClass().getName();
90
        }
91

    
92
        public Logger getLogger() {
93
                if (this.logger == null) {
94
                        this.logger = LoggerFactory.getLogger(this.getClass());
95
                }
96
                return this.logger;
97
        }
98

    
99
        public boolean allowWrite() {
100
                return false;
101
        }
102

    
103
        public CoverageSelection createCoverageSelection() throws DataException {
104
                return this.store.createDefaultCoverageSelection();
105
        }
106

    
107
        public void refresh() throws OpenException {
108
                // Do nothing by default
109
        }
110

    
111
        public void close() throws CloseException {
112
                // Do nothing by default
113
        }
114

    
115
        public void dispose() throws CloseException {
116
                this.dynObject = null;
117
                this.store = null;
118
                this.logger = null;
119
        }
120

    
121
        public Envelope getEnvelope() throws DataException {
122
                return null;
123
        }
124

    
125
        public abstract DataServerExplorer getExplorer() throws ReadException,
126
                        ValidateDataParametersException;
127

    
128
        public void delegate(DynObject dynObject) {
129
                if (this.dynObject == null) {
130
                        return;
131
                }
132
                this.dynObject.delegate(dynObject);
133
        }
134

    
135
        public DynClass getDynClass() {
136
                if (this.dynObject == null) {
137
                        return null;
138
                }
139
                return this.dynObject.getDynClass();
140
        }
141

    
142
        public Object getDynValue(String name) throws DynFieldNotFoundException {
143
                if (this.dynObject == null) {
144
                        return null;
145
                }
146
                // TODO this.open??
147
                return this.dynObject.getDynValue(name);
148
        }
149

    
150
        public boolean hasDynValue(String name) {
151
                if (this.dynObject == null) {
152
                        return false;
153
                }
154
                // TODO this.open??
155
                return this.dynObject.hasDynValue(name);
156
        }
157

    
158
        public void implement(DynClass dynClass) {
159
                if (this.dynObject == null) {
160
                        return;
161
                }
162
                this.dynObject.implement(dynClass);
163

    
164
        }
165

    
166
        public Object invokeDynMethod(int code, DynObject context)
167
                        throws DynMethodException {
168
                if (this.dynObject == null) {
169
                        return null;
170
                }
171
                // TODO this.open??
172
                return this.dynObject.invokeDynMethod(this, code, context);
173
        }
174

    
175
        public Object invokeDynMethod(String name, DynObject context)
176
                        throws DynMethodException {
177
                if (this.dynObject == null) {
178
                        return null;
179
                }
180
                // TODO this.open??
181
                return this.dynObject.invokeDynMethod(this, name, context);
182
        }
183

    
184
        public void setDynValue(String name, Object value)
185
                        throws DynFieldNotFoundException {
186
                if (this.dynObject == null) {
187
                        return;
188
                }
189
                // TODO this.open??
190
                this.dynObject.setDynValue(name, value);
191
        }
192

    
193
}