Statistics
| Revision:

root / trunk / libraries / libDataSource / src / org / gvsig / data / vectorial / expansionadapter / MemoryExpansionAdapter.java @ 19399

History | View | Annotate | Download (3.19 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 org.gvsig.data.vectorial.expansionadapter;
42

    
43
import java.util.ArrayList;
44
import java.util.HashMap;
45

    
46

    
47
/**
48
 * Implementaci?n en memoria de ExpansionAdapter.
49
 *
50
 * @author Vicente Caballero Navarro
51
 */
52
public class MemoryExpansionAdapter implements IExpansionAdapter {
53
        private ArrayList objects = new ArrayList();
54

    
55
        public MemoryExpansionAdapter(){
56
        }
57

    
58
        /* (non-Javadoc)
59
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#addFeature(org.gvsig.data.vectorial.IFeature)
60
         */
61
        public int addObject(Object obj) {
62
//                IFeature feature=(IFeature)obj;
63
                int newIndex = objects.size();
64
                objects.add(obj);
65
                return newIndex;
66
        }
67

    
68
        /* (non-Javadoc)
69
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#modifyFeature(int, org.gvsig.data.vectorial.IFeature)
70
         */
71
        public int updateObject(Object obj) {
72
//                IFeature feature=(IFeature)obj;
73
                objects.add(obj);
74
                return objects.size() - 1;
75
        }
76

    
77
        /* (non-Javadoc)
78
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#getFeature(int)
79
         */
80
        public Object getObject(int index){
81
                return objects.get(index);
82
        }
83

    
84
        /* (non-Javadoc)
85
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#compact(java.util.HashMap)
86
         */
87
        public void compact(HashMap relations) {
88

    
89
        }
90

    
91
        /* (non-Javadoc)
92
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#deleteLastFeature()
93
         */
94
        public void deleteLastObject() {
95
                objects.remove(objects.size()-1);
96

    
97
        }
98

    
99
        /* (non-Javadoc)
100
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#open()
101
         */
102
        public void open() {
103
                // TODO Auto-generated method stub
104

    
105
        }
106

    
107
        /* (non-Javadoc)
108
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#close()
109
         */
110
        public void close() {
111
                objects.clear();
112
                System.gc();
113
        }
114

    
115
        /* (non-Javadoc)
116
         * @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#getSize()
117
         */
118
        public int getSize() {
119
                return objects.size();
120
        }
121
}