Revision 23913

View differences:

branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/spi/DataExplorerProvider.java
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
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.data.spi;
29

  
30
import org.gvsig.fmap.data.DataExplorer;
31
import org.gvsig.fmap.data.DataExplorerParameters;
32
import org.gvsig.fmap.data.exceptions.InitializeException;
33

  
34
import com.iver.utiles.XMLEntity;
35

  
36
public interface DataExplorerProvider extends DataExplorer {
37

  
38

  
39
	public void init(DataExplorerParameters parameters)
40
			throws InitializeException;
41

  
42
	public void init(XMLEntity xmlEntity) throws InitializeException;
43

  
44
}
0 45

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/explorer/filesystem/FilesystemExplorer.java
14 14
import org.gvsig.fmap.data.exceptions.DataException;
15 15
import org.gvsig.fmap.data.exceptions.InitializeException;
16 16
import org.gvsig.fmap.data.exceptions.ReadException;
17
import org.gvsig.fmap.data.exceptions.WriteException;
18
import org.gvsig.fmap.data.feature.FeatureExplorer;
19
import org.gvsig.fmap.data.feature.FeatureType;
17
import org.gvsig.fmap.data.spi.DataExplorerProvider;
18
import org.gvsig.tools.exception.NotYetImplemented;
20 19
import org.gvsig.tools.extensionPoint.ExtensionPoint;
21 20
import org.gvsig.tools.extensionPoint.ExtensionPoints;
22 21
import org.gvsig.tools.extensionPoint.ExtensionPointsSingleton;
23 22

  
23
import com.iver.utiles.XMLEntity;
24 24

  
25
public class FilesystemExplorer implements FeatureExplorer {
25

  
26
public class FilesystemExplorer implements DataExplorerProvider {
26 27
	// FIXME: , IPersistence{
27 28

  
28 29

  
......
30 31
	final private static String FILE_FILTER_EPSDESCRIPTION = "Registro de filtros asociados al explorador del sistema de ficheros.";
31 32

  
32 33
	FilesystemExplorerParameters parameters;
34
	private File path;
33 35

  
34
	public class FilterWraper {
36
	public static class FilterWraper {
35 37

  
36 38
		private FileFilter filter;
37 39

  
......
53 55

  
54 56
	}
55 57

  
56
	public class FilterWraperIterator implements Iterator {
58
	public static class FilterWraperIterator implements Iterator {
57 59
		private Iterator it;
58 60

  
59 61
		public FilterWraperIterator(Iterator it) {
......
93 95
		return it;
94 96
	}
95 97

  
96
	public void initialice(DataExplorerParameters parameters)
98
	public void init(DataExplorerParameters parameters)
97 99
			throws InitializeException {
98 100
		this.parameters = (FilesystemExplorerParameters) parameters;
101
		this.path = new File(this.parameters.getPath());
99 102
	}
100 103

  
104
	public void init(XMLEntity xmlEntity) throws InitializeException {
105
		// TODO Auto-generated method stub
106
		throw new NotYetImplemented();
107

  
108
	}
109

  
110

  
101 111
	public DataExplorerType getType() {
102 112
		return parameters.getType();
103 113
	}
......
110 120

  
111 121
	}
112 122

  
113
	public boolean add(DataStoreParameters params, FeatureType type)
114
			throws WriteException, InitializeException {
115
		// TODO Auto-generated method stub
116
		return false;
117
	}
118

  
119 123
	public List list() throws DataException {
120 124
		if (!this.path.exists()) {
125
			//TODO crear excepcion de Data??
121 126
			new FileNotFoundException(this.getName() + ": Path not found '"
122
					+ this.path + "'", new Exception());
127
					+ this.path + "'");
123 128
		}
124 129
		// DataManager dsm=DataManager.getManager();
125 130

  
......
131 136

  
132 137
		for (i = 0; i < files.length; i++) {
133 138
			theFile = new File(this.path, files[i]);
134
			if (this.accept(filters, theFile)) {
139
			if (this.accept(theFile)) {
135 140
				fileList.add(theFile);
136 141
			}
137 142

  
138 143
		}
139
		DataStoreParameters[] x = new DataStoreParameters[1];
140
		x[0] = dsp;
141
		return (DataStoreParameters[]) fileList.toArray(x);
144
		return fileList;
142 145
	}
143 146

  
144 147
	private boolean accept(File file) {
......
169 172

  
170 173
	}
171 174

  
175
	public boolean add(DataStoreParameters ndsp) throws DataException {
176
		// TODO Auto-generated method stub
177
		return false;
178
	}
179

  
180
	public boolean canCreate() {
181
		return this.path.canWrite();
182
	}
183

  
184
	public String getName() {
185
		// TODO Auto-generated method stub
186
		return null;
187
	}
188

  
172 189
	// ==========================================
173 190

  
174 191

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/explorer/filesystem/FilesystemExplorerParameters.java
2 2

  
3 3
import org.gvsig.fmap.data.DataExplorerParameters;
4 4
import org.gvsig.fmap.data.DataExplorerType;
5
import org.gvsig.fmap.data.DataParameters;
6 5
import org.gvsig.fmap.data.DataTypes;
7
import org.gvsig.fmap.data.exceptions.DataException;
8 6
import org.gvsig.fmap.data.spi.AbstractDataParameters;
9 7

  
10 8
public class FilesystemExplorerParameters extends AbstractDataParameters
......
19 17
		return null;
20 18
	}
21 19

  
22
	public DataParameters getCopy() throws DataException {
23
		// TODO Auto-generated method stub
24
		return null;
25
	}
26

  
27 20
	public void setPath(String path) {
28 21
		this.set("path", path);
29 22
	}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorer.java
3 3
import java.util.List;
4 4

  
5 5
import org.gvsig.fmap.data.exceptions.DataException;
6
import org.gvsig.fmap.data.exceptions.InitializeException;
7 6

  
8
import com.iver.utiles.XMLEntity;
9

  
10 7
public interface DataExplorer {
11 8

  
12 9
	public String getName();
13 10

  
14
	public void init(DataExplorerParameters parameters) throws InitializeException;
15
	public void init(XMLEntity xmlEntity) throws InitializeException;
16

  
17 11
	public boolean canCreate();
18 12

  
19 13
	public List list() throws DataException;

Also available in: Unified diff