svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libGeocoding / src / org / gvsig / geocoding / pattern / GeocodingSource.java @ 27064
History | View | Annotate | Download (3.7 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 Prodevelop S.L. main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.geocoding.pattern; |
29 |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
31 |
import org.gvsig.geocoding.styles.AbstractGeocodingStyle; |
32 |
import org.gvsig.tools.persistence.AbstractPersistenceManager; |
33 |
import org.gvsig.tools.persistence.PersistenceException; |
34 |
import org.gvsig.tools.persistence.Persistent; |
35 |
import org.gvsig.tools.persistence.PersistentState; |
36 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
/**
|
40 |
* Class Source. this class has the geocoding style and the FeatureStore of the
|
41 |
* data source
|
42 |
*
|
43 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
44 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
45 |
*/
|
46 |
public class GeocodingSource implements Persistent { |
47 |
|
48 |
private static final Logger log = LoggerFactory |
49 |
.getLogger(GeocodingSource.class); |
50 |
|
51 |
private static final String STYLE = "style"; |
52 |
private static final String LAYERSOURCE = "layersource"; |
53 |
|
54 |
private AbstractGeocodingStyle style;
|
55 |
private FeatureStore layerSource;
|
56 |
|
57 |
/**
|
58 |
* default constructor
|
59 |
*/
|
60 |
public GeocodingSource() {
|
61 |
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* constructor with parameters
|
66 |
*
|
67 |
* @param _style
|
68 |
* @param _layerSource
|
69 |
*/
|
70 |
public GeocodingSource(AbstractGeocodingStyle _style,
|
71 |
FeatureStore _layerSource) { |
72 |
this.style = _style;
|
73 |
this.layerSource = _layerSource;
|
74 |
} |
75 |
|
76 |
/**
|
77 |
* get the style
|
78 |
*
|
79 |
* @return
|
80 |
*/
|
81 |
public AbstractGeocodingStyle getStyle() {
|
82 |
return style;
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Set the style
|
87 |
*
|
88 |
* @param style
|
89 |
*/
|
90 |
public void setStyle(AbstractGeocodingStyle style) { |
91 |
this.style = style;
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* get layer source
|
96 |
*
|
97 |
* @return
|
98 |
*/
|
99 |
public FeatureStore getLayerSource() {
|
100 |
return layerSource;
|
101 |
} |
102 |
|
103 |
/**
|
104 |
* set layer sourdce
|
105 |
*
|
106 |
* @param layerSource
|
107 |
*/
|
108 |
public void setLayerSource(FeatureStore layerSource) { |
109 |
this.layerSource = layerSource;
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* Get the persistent state of the GeocodingSource and append to the passed
|
114 |
* state.
|
115 |
*
|
116 |
* @param state
|
117 |
*/
|
118 |
public PersistentState getState() throws PersistenceException { |
119 |
return AbstractPersistenceManager.getState(this); |
120 |
} |
121 |
|
122 |
/**
|
123 |
* Load the state of the GeocodingSource over the passed state.
|
124 |
*
|
125 |
* @param state
|
126 |
*/
|
127 |
public void loadState(PersistentState state) throws PersistenceException { |
128 |
state.setTheClass(this);
|
129 |
state.set(LAYERSOURCE, this.layerSource);
|
130 |
state.set(STYLE, this.style);
|
131 |
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Set the state of the GeocodingSource from the state passed as parameter.
|
136 |
*
|
137 |
* @param state
|
138 |
*/
|
139 |
public void setState(PersistentState state) throws PersistenceException { |
140 |
this.layerSource = (FeatureStore) state.get(LAYERSOURCE);
|
141 |
this.style = (AbstractGeocodingStyle) state.get(STYLE);
|
142 |
} |
143 |
|
144 |
} |