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.shp / src / main / java / org / gvsig / fmap / dal / store / shp / SHPStoreSaveEncodingMethod.java @ 43246
History | View | Annotate | Download (2.14 KB)
1 | 43246 | jjdelcerro | package org.gvsig.fmap.dal.store.shp; |
---|---|---|---|
2 | |||
3 | |||
4 | import java.io.File; |
||
5 | import org.gvsig.fmap.dal.DataStore; |
||
6 | import org.gvsig.fmap.dal.OpenDataStoreParameters; |
||
7 | import org.gvsig.fmap.dal.spi.DataStoreProvider; |
||
8 | import org.gvsig.fmap.dal.store.dbf.utils.DbaseCodepage; |
||
9 | import org.gvsig.tools.dynobject.AbstractDynMethod; |
||
10 | import org.gvsig.tools.dynobject.DynObject; |
||
11 | import org.gvsig.tools.dynobject.exception.DynMethodException; |
||
12 | |||
13 | /**
|
||
14 | * gvSIG. Desktop Geographic Information System.
|
||
15 | *
|
||
16 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
17 | *
|
||
18 | * This program is free software; you can redistribute it and/or
|
||
19 | * modify it under the terms of the GNU General Public License
|
||
20 | * as published by the Free Software Foundation; either version 3
|
||
21 | * of the License, or (at your option) any later version.
|
||
22 | *
|
||
23 | * This program is distributed in the hope that it will be useful,
|
||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
26 | * GNU General Public License for more details.
|
||
27 | *
|
||
28 | * You should have received a copy of the GNU General Public License
|
||
29 | * along with this program; if not, write to the Free Software
|
||
30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
31 | * MA 02110-1301, USA.
|
||
32 | *
|
||
33 | * For any additional information, do not hesitate to contact us
|
||
34 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
35 | */
|
||
36 | |||
37 | |||
38 | public class SHPStoreSaveEncodingMethod extends AbstractDynMethod { |
||
39 | |||
40 | public SHPStoreSaveEncodingMethod() {
|
||
41 | super("saveEncoding", "Save the current encoding in the '.cpg' file associated to this shape."); |
||
42 | } |
||
43 | |||
44 | @Override
|
||
45 | public Object invoke(DynObject self, Object[] args) throws DynMethodException { |
||
46 | SHPStoreProvider provider = (SHPStoreProvider)self; |
||
47 | OpenDataStoreParameters shapeOpenParameters = (OpenDataStoreParameters) provider.getParameters(); |
||
48 | File f = (File) shapeOpenParameters.getDynValue(SHPStoreParameters.SHPFILE_PARAMTER_NAME); |
||
49 | String encoding = (String) shapeOpenParameters.getDynValue(SHPStoreParameters.ENCODING_PARAMTER_NAME); |
||
50 | DbaseCodepage cp = new DbaseCodepage(f);
|
||
51 | cp.write(encoding); |
||
52 | return true; |
||
53 | } |
||
54 | |||
55 | } |