svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.sqlite / org.gvsig.sqlite.provider / src / main / java / org / gvsig / sqlite / dal / SQLiteStoreParameters.java @ 47779
History | View | Annotate | Download (3.27 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 |
package org.gvsig.sqlite.dal; |
23 |
|
24 |
import java.io.File; |
25 |
import java.io.IOException; |
26 |
import java.util.Properties; |
27 |
import org.apache.commons.io.FilenameUtils; |
28 |
import org.gvsig.fmap.dal.DataStoreParameters; |
29 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
30 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParametersBase; |
31 |
|
32 |
public class SQLiteStoreParameters extends JDBCStoreParametersBase implements SQLiteConnectionParameters { |
33 |
|
34 |
private final SQLiteConnectionParametersHelper helper; |
35 |
|
36 |
public SQLiteStoreParameters() {
|
37 |
super(
|
38 |
SQLiteLibrary.NAME + "StoreParameters",
|
39 |
SQLiteLibrary.NAME |
40 |
); |
41 |
this.helper = new SQLiteConnectionParametersHelper(this); |
42 |
} |
43 |
|
44 |
@Override
|
45 |
public String getUrl() { |
46 |
return this.helper.getUrl(); |
47 |
} |
48 |
|
49 |
@Override
|
50 |
public void validate() throws ValidateDataParametersException { |
51 |
this.helper.validate();
|
52 |
super.validate();
|
53 |
} |
54 |
|
55 |
@Override
|
56 |
public boolean getEnableLoadExtension() { |
57 |
return this.helper.getEnableLoadExtension(); |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public boolean getEnableSharedCache() { |
62 |
return this.helper.getEnableSharedCache(); |
63 |
} |
64 |
|
65 |
@Override
|
66 |
public void setEnableLoadExtension(boolean v) { |
67 |
this.helper.setEnableLoadExtension(v);
|
68 |
} |
69 |
|
70 |
@Override
|
71 |
public void setEnableSharedCache(boolean v) { |
72 |
this.helper.setEnableSharedCache(v);
|
73 |
} |
74 |
|
75 |
@Override
|
76 |
public Properties getProperties() { |
77 |
return this.helper.getProperties(); |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public File getFile() { |
82 |
return this.helper.getFile(); |
83 |
} |
84 |
|
85 |
@Override
|
86 |
public void setFile(File database) { |
87 |
this.helper.setFile(database);
|
88 |
} |
89 |
|
90 |
@Override
|
91 |
public boolean isTheSameStore(DataStoreParameters params) { |
92 |
if(!(params instanceof SQLiteStoreParameters)){ |
93 |
return false; |
94 |
} |
95 |
File f1 = SQLiteUtils.normalizeFile(this.getFile()); |
96 |
File f2 = SQLiteUtils.normalizeFile(((SQLiteStoreParameters)params).getFile());
|
97 |
try {
|
98 |
if(!FilenameUtils.equalsOnSystem(f1.getCanonicalPath(), f2.getCanonicalPath())){
|
99 |
return false; |
100 |
} |
101 |
} catch (IOException ex) { |
102 |
if(!FilenameUtils.equalsOnSystem(f1.getAbsolutePath(), f2.getAbsolutePath())){
|
103 |
return false; |
104 |
} |
105 |
} |
106 |
return super.isTheSameStore(params); |
107 |
|
108 |
} |
109 |
|
110 |
|
111 |
} |