root / branches / v2_0_0_prep / libraries / libFMap_dalfile / src / org / gvsig / fmap / dal / store / shp / SHPStoreParameters.java @ 25789
History | View | Annotate | Download (4.64 KB)
1 | 24447 | jmvivo | /* 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 | * 2008 IVER T.I. S.A. {{Task}}
|
||
26 | */
|
||
27 | |||
28 | 24498 | jmvivo | package org.gvsig.fmap.dal.store.shp; |
29 | 24447 | jmvivo | |
30 | import java.io.File; |
||
31 | |||
32 | 25551 | cordinyana | import org.gvsig.fmap.dal.DataTypes; |
33 | 24498 | jmvivo | import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
34 | import org.gvsig.fmap.dal.store.shp.utils.SHP; |
||
35 | 25362 | jmvivo | import org.gvsig.tools.ToolsLocator; |
36 | 25789 | jmvivo | import org.gvsig.tools.dynobject.DelegatedDynObject; |
37 | 25551 | cordinyana | import org.gvsig.tools.dynobject.DynClass; |
38 | import org.gvsig.tools.dynobject.DynField; |
||
39 | import org.gvsig.tools.dynobject.DynObjectManager; |
||
40 | 24447 | jmvivo | import org.gvsig.tools.exception.NotYetImplemented; |
41 | import org.gvsig.tools.persistence.PersistenceException; |
||
42 | import org.gvsig.tools.persistence.PersistentState; |
||
43 | |||
44 | public class SHPStoreParameters extends DBFStoreParameters { |
||
45 | |||
46 | 25789 | jmvivo | public static final String DYNCLASS_NAME = "SHPStoreParameters"; |
47 | 25657 | jmvivo | |
48 | 25551 | cordinyana | private static final String FIELD_SHXFILENAME = "shxfilename"; |
49 | private static final String FIELD_SHPFILENAME = "shpfilename"; |
||
50 | |||
51 | 25789 | jmvivo | protected static DynClass DYNCLASS = null; |
52 | |||
53 | 25551 | cordinyana | protected void initialize() { |
54 | 25789 | jmvivo | this.delegatedDynObjet = (DelegatedDynObject) ToolsLocator
|
55 | .getDynObjectManager() |
||
56 | .createDynObject(DYNCLASS); |
||
57 | 24447 | jmvivo | } |
58 | |||
59 | public String getDataStoreName() { |
||
60 | return SHPStoreProvider.NAME;
|
||
61 | } |
||
62 | |||
63 | public boolean isValid() { |
||
64 | 24791 | jmvivo | return super.isValid() && (this.getSHPFileName() != null); |
65 | 24447 | jmvivo | } |
66 | |||
67 | 24642 | jmvivo | public File getFile() { |
68 | 24791 | jmvivo | return new File(this.getSHPFileName()); |
69 | 24447 | jmvivo | } |
70 | |||
71 | public void setFile(File aFile) { |
||
72 | this.setSHPFile(aFile);
|
||
73 | } |
||
74 | |||
75 | 24791 | jmvivo | public String getSHPFileName() { |
76 | 25551 | cordinyana | return (String) this.getDynValue(FIELD_SHPFILENAME); |
77 | 24447 | jmvivo | } |
78 | |||
79 | 24791 | jmvivo | public File getSHPFile() { |
80 | 25551 | cordinyana | return new File((String) this.getDynValue(FIELD_SHPFILENAME)); |
81 | 24447 | jmvivo | } |
82 | |||
83 | public void setSHPFile(File aFile) { |
||
84 | 25551 | cordinyana | this.setDynValue(FIELD_SHPFILENAME, aFile.getPath());
|
85 | 24710 | jmvivo | if (this.getDBFFileName() == null){ |
86 | 24447 | jmvivo | this.setDBFFile(SHP.getDbfFile(aFile));
|
87 | } |
||
88 | 24791 | jmvivo | if (this.getSHXFileName() == null) { |
89 | 24447 | jmvivo | this.setSHXFile(SHP.getShxFile(aFile));
|
90 | } |
||
91 | } |
||
92 | |||
93 | 24791 | jmvivo | public void setSHPFileName(String aFileName) { |
94 | 25551 | cordinyana | this.setDynValue(FIELD_SHPFILENAME, aFileName);
|
95 | 24710 | jmvivo | if (this.getDBFFileName() == null) { |
96 | 24447 | jmvivo | this.setDBFFile(SHP.getDbfFile(new File(aFileName))); |
97 | } |
||
98 | 24791 | jmvivo | if (this.getSHXFileName() == null) { |
99 | 24447 | jmvivo | this.setSHXFile(SHP.getShxFile(new File(aFileName))); |
100 | } |
||
101 | } |
||
102 | |||
103 | 24791 | jmvivo | public String getSHXFileName() { |
104 | 25551 | cordinyana | return (String) this.getDynValue(FIELD_SHXFILENAME); |
105 | 24447 | jmvivo | } |
106 | |||
107 | 24791 | jmvivo | public File getSHXFile() { |
108 | 25551 | cordinyana | return new File((String) this.getDynValue(FIELD_SHXFILENAME)); |
109 | 24447 | jmvivo | } |
110 | public void setSHXFile(File aFile) { |
||
111 | 25551 | cordinyana | this.setDynValue(FIELD_SHXFILENAME, aFile.getPath());
|
112 | 24447 | jmvivo | } |
113 | |||
114 | 24791 | jmvivo | public void setSHXFileName(String aFileName) { |
115 | 25551 | cordinyana | this.setDynValue(FIELD_SHXFILENAME, aFileName);
|
116 | 24447 | jmvivo | } |
117 | |||
118 | |||
119 | |||
120 | public String getDescription() { |
||
121 | return SHPStoreProvider.DESCRIPTION;
|
||
122 | } |
||
123 | |||
124 | public void getState(PersistentState arg0) throws PersistenceException { |
||
125 | // TODO Auto-generated method stub
|
||
126 | throw new NotYetImplemented(); |
||
127 | } |
||
128 | |||
129 | public void setState(PersistentState state) throws PersistenceException { |
||
130 | // TODO Auto-generated method stub
|
||
131 | super.setState(state);
|
||
132 | throw new NotYetImplemented(); |
||
133 | } |
||
134 | |||
135 | 25789 | jmvivo | protected static void registerDynClass() { |
136 | 25551 | cordinyana | DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
137 | 25789 | jmvivo | DynClass dynClass; |
138 | 25551 | cordinyana | DynField field; |
139 | 25789 | jmvivo | if (DYNCLASS == null) { |
140 | DynClass dbfDynClass = DBFStoreParameters.DYNCLASS; |
||
141 | dynClass = dynman.add(DYNCLASS_NAME); |
||
142 | 24447 | jmvivo | |
143 | 25551 | cordinyana | field = dynClass.addDynField(FIELD_SHPFILENAME); |
144 | 25789 | jmvivo | field.setDescription("SHP file name");
|
145 | field.setType(DataTypes.STRING); |
||
146 | field.setMandatory(true);
|
||
147 | 25551 | cordinyana | |
148 | field = dynClass.addDynField(FIELD_SHXFILENAME); |
||
149 | 25789 | jmvivo | field.setDescription("SHX file name");
|
150 | field.setType(DataTypes.STRING); |
||
151 | field.setMandatory(true);
|
||
152 | 25657 | jmvivo | |
153 | 25551 | cordinyana | // The SHP store parameters extend the DBF store parameters
|
154 | dynClass.extend(dbfDynClass); |
||
155 | 25789 | jmvivo | |
156 | DYNCLASS = dynClass; |
||
157 | 25551 | cordinyana | } |
158 | } |
||
159 | 24447 | jmvivo | } |