root / trunk / libraries / libRaster / src / org / gvsig / raster / buffer / cache / HddPage.java @ 11074
History | View | Annotate | Download (3.69 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*/
|
20 |
package org.gvsig.raster.buffer.cache; |
21 |
|
22 |
import java.io.FileNotFoundException; |
23 |
import java.io.IOException; |
24 |
|
25 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
26 |
import org.gvsig.raster.dataset.RasterDataset; |
27 |
import org.gvsig.raster.dataset.RasterDriverException; |
28 |
import org.gvsig.raster.shared.Extent; |
29 |
|
30 |
|
31 |
/**
|
32 |
* Esta clase representa una p?gina de disco. Una p?gina de disco tendr? un n?mero de
|
33 |
* p?gina asociado y un servidor de datos de disco por cada banda.
|
34 |
*
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
36 |
*/
|
37 |
public class HddPage{ |
38 |
/**
|
39 |
* Objeto que guarda y recupera trozos de cache de disco.
|
40 |
*/
|
41 |
private ICacheDataSource[] dataSource = null; |
42 |
private int nPag = 0; |
43 |
|
44 |
/**
|
45 |
* Constructor: crea un objeto dataSource.
|
46 |
* @param nPag N?mero de p?gina
|
47 |
* @param nBands N?mero de bandas del dataset
|
48 |
* @throws RasterDriverException
|
49 |
* @throws NotSupportedExtensionException
|
50 |
* @throws FileNotFoundException
|
51 |
*/
|
52 |
public HddPage(int nPag, RasterDataset dataset, Extent extent) throws FileNotFoundException, NotSupportedExtensionException, RasterDriverException{ |
53 |
this.nPag = nPag;
|
54 |
dataSource = new CacheDataFromDriverServer[1]; |
55 |
dataSource[0] = new CacheDataFromDriverServer(dataset, nPag, extent); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* Constructor: crea un objeto dataSource para cada banda. Para todos los datasource de un
|
60 |
* mismo HddPage se usa el mismo identificador.
|
61 |
* @param nPag N?mero de p?gina
|
62 |
* @param nBands N?mero de bandas del dataset
|
63 |
*/
|
64 |
public HddPage(int nPag, int nBands){ |
65 |
this.nPag = nPag;
|
66 |
dataSource = new CacheDataServer[nBands];
|
67 |
for (int iBand = 0; iBand < nBands; iBand++) |
68 |
dataSource[iBand] = new CacheDataServer(Long.toString(System.currentTimeMillis()), iBand, nPag); |
69 |
} |
70 |
|
71 |
/**
|
72 |
* Obtiene el servidor de datos de disco para una banda de la p?gina de
|
73 |
* disco actual
|
74 |
* @param nBand N?mero de banda
|
75 |
* @return Servidor de datos de disco
|
76 |
*/
|
77 |
public ICacheDataSource getDataServer(int nBand){ |
78 |
if(nBand >= 0 && nBand < dataSource.length) |
79 |
return dataSource[nBand];
|
80 |
return null; |
81 |
} |
82 |
|
83 |
/**
|
84 |
* Elimina una banda de la cach?. Antes salva a disco todos los trozos cacheados e inicializa
|
85 |
* las estructuras de control de cach?.
|
86 |
* @param nBand N?mero de banda a eliminar
|
87 |
* @throws IOException
|
88 |
*/
|
89 |
public void deleteBand(int nBand) throws IOException{ |
90 |
if(nBand >= 0 && nBand < dataSource.length) |
91 |
dataSource[nBand].delete(); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* Asigna una banda de disco a todas las p?ginas.
|
96 |
* @param cacheDataSource Fuente de las p?ginas. Es la referencia a disco de ellas.
|
97 |
*/
|
98 |
public void assignBand(int nBand, ICacheDataSource cacheDataSource){ |
99 |
if(nBand >= 0 && nBand < dataSource.length) |
100 |
dataSource[nBand] = cacheDataSource; |
101 |
} |
102 |
|
103 |
/**
|
104 |
* Obtiene la fuente de datos que corresponde a una banda.
|
105 |
* @param nBand Banda a recuperar
|
106 |
* @return ICacheDataSource
|
107 |
*/
|
108 |
public ICacheDataSource getBandDataSource(int nBand){ |
109 |
return dataSource[nBand];
|
110 |
} |
111 |
} |