Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / DefaultFeatureStoreNotification.java @ 44871

History | View | Annotate | Download (6.33 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.feature.impl;
25

    
26
import java.util.Iterator;
27
import org.gvsig.fmap.dal.DataSet;
28
import org.gvsig.fmap.dal.DataStore;
29
import org.gvsig.fmap.dal.feature.EditableFeatureType;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.dal.feature.FeatureIndex;
32
import org.gvsig.fmap.dal.feature.FeatureReference;
33
import org.gvsig.fmap.dal.feature.FeatureStoreNotification;
34
import org.gvsig.fmap.dal.feature.FeatureType;
35
import org.gvsig.fmap.dal.feature.FeatureType.FeatureTypeChanged;
36
import org.gvsig.tools.observer.BaseNotification;
37
import org.gvsig.tools.undo.command.Command;
38

    
39
public class DefaultFeatureStoreNotification
40
        extends BaseNotification
41
        implements FeatureStoreNotification {
42

    
43
  private static final int VALUE_SOURCE = 0;
44
  private static final int VALUE_FEATURE = 1;
45
  private static final int VALUE_COLLECTION_RESULT = 2;
46
  private static final int VALUE_LOAD_COLLECTION_SUCCESSFULLY = 3;
47
  private static final int VALUE_EXCEPTION_LOADING = 4;
48
  private static final int VALUE_COMMAND = 5;
49
  private static final int VALUE_FEATURE_INDEX = 6;
50
  private static final int VALUE_FEATURETYPE = 7;
51
  private static final int VALUE_CHANGEDS_FEATURETYPES = 8;
52
  private static final int VALUE_UPDATEDS_FEATURES = 9;
53
  private static final int VALUE_INSERTEDS_FEATURES = 10;
54
  private static final int VALUE_DELETEDS_FEATURES = 11;
55
  private static final int VALUE_IS_SELECTION_COMPROMISED = 12;
56

    
57
  private static final int VALUES_COUNT = 13;
58

    
59
  public DefaultFeatureStoreNotification(String type) {
60
    super(type, VALUES_COUNT);
61
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
62
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, false);
63
  }
64

    
65
  public DefaultFeatureStoreNotification(DataStore source, String type) {
66
    this(type);
67
    this.setValue(VALUE_SOURCE, source);
68
  }
69

    
70
  public DefaultFeatureStoreNotification(DataStore source, String type, Feature feature) {
71
    this(source, type);
72
    this.setValue(VALUE_FEATURE, feature);
73
  }
74

    
75
  public DefaultFeatureStoreNotification(DataStore source, String type, Command command) {
76
    this(source, type);
77
    this.setValue(VALUE_SOURCE, source);
78
    this.setValue(VALUE_COMMAND, command);
79
  }
80

    
81
  public DefaultFeatureStoreNotification(DataStore source, String type, Exception exception) {
82
    this(source, type);
83
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, false);
84
    this.setValue(VALUE_EXCEPTION_LOADING, exception);
85
  }
86

    
87
  public DefaultFeatureStoreNotification(DataStore source, String type, DataSet collection) {
88
    this(source, type);
89
    this.setValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY, true);
90
    this.setValue(VALUE_COLLECTION_RESULT, collection);
91
  }
92

    
93
  public DefaultFeatureStoreNotification(DataStore source, String type,
94
          EditableFeatureType featureType) {
95
    this(source, type);
96
    this.setValue(VALUE_FEATURETYPE, featureType);
97
  }
98

    
99
  public DefaultFeatureStoreNotification(DataStore source, String type, FeatureIndex index) {
100
    this(source, type);
101
    this.setValue(VALUE_FEATURE_INDEX, index);
102
  }
103

    
104
  DefaultFeatureStoreNotification(DataStore source, String type, 
105
      Iterator<FeatureReference> deleteds, 
106
      Iterator<Feature> inserteds, 
107
      Iterator<Feature> updateds, 
108
      Iterator<FeatureType.FeatureTypeChanged> featureTypesChanged, 
109
      boolean isSelectionCompromised)
110
    {
111
    this(source, type);
112
    this.setValue(VALUE_DELETEDS_FEATURES, deleteds);
113
    this.setValue(VALUE_INSERTEDS_FEATURES, inserteds);
114
    this.setValue(VALUE_UPDATEDS_FEATURES, updateds);
115
    this.setValue(VALUE_CHANGEDS_FEATURETYPES, featureTypesChanged);
116
    this.setValue(VALUE_IS_SELECTION_COMPROMISED, isSelectionCompromised);
117
  }
118

    
119
  @Override
120
  public Feature getFeature() {
121
    return (Feature) this.getValue(VALUE_FEATURE);
122
  }
123

    
124
  @Override
125
  public EditableFeatureType getFeatureType() {
126
    return (EditableFeatureType) this.getValue(VALUE_FEATURETYPE);
127
  }
128

    
129
  @Override
130
  public DataSet getCollectionResult() {
131
    return (DataSet) this.getValue(VALUE_COLLECTION_RESULT);
132
  }
133

    
134
  @Override
135
  public Exception getExceptionLoading() {
136
    return (Exception) this.getValue(VALUE_EXCEPTION_LOADING);
137
  }
138

    
139
  @Override
140
  public boolean loadSucefully() {
141
    return (boolean) this.getValue(VALUE_LOAD_COLLECTION_SUCCESSFULLY);
142
  }
143

    
144
  @Override
145
  public Command getCommand() {
146
    return (Command) this.getValue(VALUE_COMMAND);
147
  }
148

    
149
  @Override
150
  public DataStore getSource() {
151
    return (DataStore) this.getValue(VALUE_SOURCE);
152
  }
153

    
154
  public FeatureIndex getIndex() {
155
    return (FeatureIndex) this.getValue(VALUE_FEATURE_INDEX);
156
  }
157
  
158
  @Override
159
  public boolean isSelectionCompromised() {
160
    return (boolean) this.getValue(VALUE_IS_SELECTION_COMPROMISED);
161
  }
162

    
163
  @Override
164
  public Iterator<FeatureReference> getDeletedsFeatures() {
165
    return (Iterator<FeatureReference>) this.getValue(VALUE_DELETEDS_FEATURES);
166
  }
167
  
168
  @Override
169
  public Iterator<Feature> getInsertedsFeatures() {
170
    return (Iterator<Feature>) this.getValue(VALUE_INSERTEDS_FEATURES);
171
  }
172
  
173
  @Override
174
  public Iterator<Feature> getUpdatedsFeatures() {
175
    return (Iterator<Feature>) this.getValue(VALUE_UPDATEDS_FEATURES);
176
  }
177
  
178
  @Override
179
  public Iterator<FeatureTypeChanged> getChangedsFeatureTypes() {
180
    return (Iterator<FeatureTypeChanged>) this.getValue(VALUE_CHANGEDS_FEATURETYPES);
181
  }
182
  
183
  
184
}