Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / MemoryExpansionFile.java @ 5576

History | View | Annotate | Download (4.12 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.edition;
42

    
43
import java.io.IOException;
44
import java.util.ArrayList;
45
import java.util.HashMap;
46

    
47
import com.iver.cit.gvsig.fmap.core.IRow;
48

    
49

    
50
/**
51
 * Implementaci?n en memoria de ExpansionFile.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class MemoryExpansionFile implements ExpansionFile {
56
        ArrayList rows = new ArrayList();
57
        //BitSet invalidRows = new BitSet();
58
        /**
59
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#addRow(IRow, int)
60
         */
61
        public int addRow(IRow row, int status) throws IOException {
62
                int newIndex = rows.size();
63
                IRowEdited edRow = new DefaultRowEdited(row,
64
                                status, newIndex);
65
                rows.add(edRow);
66

    
67
                return newIndex;
68
        }
69

    
70
        /**
71
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#modifyRow(int,
72
         *                 IRow)
73
         */
74
        public int modifyRow(int index, IRow row) throws IOException {
75
                /*if (invalidRows.get(index)) {
76
                        throw new RuntimeException(
77
                                "Se ha intentado modificar una geometr?a que ha sido borrada anteriormente");
78
                }
79
*/
80
                //invalidateRow(index);
81
                IRowEdited edRow = new DefaultRowEdited(row,
82
                                IRowEdited.STATUS_MODIFIED, index);
83

    
84
                rows.add(edRow);
85

    
86
                return rows.size() - 1;
87
        }
88

    
89
        /**
90
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#getRow(int)
91
         */
92
        public IRowEdited getRow(int index) throws IOException {
93
                /*if (invalidRows.get(index)) {
94
                        return null;
95
                }
96
*/
97
                return (IRowEdited) rows.get(index);
98
        }
99

    
100
        /**
101
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#invalidateRow(int)
102
         */
103
        /*public void invalidateRow(int index) {
104
                invalidRows.set(index, true);
105
        }
106
*/
107
        /**
108
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#compact()
109
         */
110
        public void compact(HashMap relations) {
111
        /*        ArrayList geoAux = new ArrayList();
112
                Iterator iter = relations.keySet().iterator();
113
                HashMap aux = new HashMap();
114
                int n = 0;
115

116
                while (iter.hasNext()) {
117
                        Integer virtualIndex = (Integer) iter.next();
118
                        Integer expansionIndex = (Integer) relations.get(virtualIndex);
119

120
                        if (!invalidRows.get(expansionIndex.intValue())){
121
                                geoAux.add(rows.get(expansionIndex.intValue()));
122
                                aux.put(new Integer(n), new Integer(geoAux.size()-1));
123
                                n++;
124
                        }
125
                }
126

127
                invalidRows.clear();
128
                rows = geoAux;
129
                relations.clear();
130
                relations.putAll(aux);
131
*/
132

    
133
        }
134

    
135
        /**
136
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#getRowCount()
137
         */
138
        /*public int getRowCount() {
139
                return rows.size() - invalidRows.cardinality();
140
        }
141
*/
142
        public void deleteLastRow() {
143
                //invalidRows.set(rows.size()-1,false);
144
                rows.remove(rows.size()-1);
145

    
146
        }
147

    
148
        public void open() throws IOException {
149
                // TODO Auto-generated method stub
150

    
151
        }
152

    
153
        public void close() throws IOException {
154
                // TODO Auto-generated method stub
155

    
156
        }
157

    
158
        public int getSize() {
159
                return rows.size();
160
        }
161

    
162
        /* (non-Javadoc)
163
         * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#validateRow(int)
164
         */
165
        /*public void validateRow(int previousExpansionFileIndex) {
166
                invalidRows.set(previousExpansionFileIndex, false);
167
        }
168

169
        public BitSet getInvalidRows() {
170
                return invalidRows;
171
        }*/
172
}