Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / impl / DefaultFeatureAttributeDescriptor.java @ 24496

History | View | Annotate | Download (3.5 KB)

1
package org.gvsig.fmap.dal.feature.impl;
2

    
3
import java.text.DateFormat;
4
import java.util.Date;
5

    
6
import org.gvsig.fmap.dal.DataTypes;
7
import org.gvsig.fmap.dal.feature.Feature;
8
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
9
import org.gvsig.fmap.geom.Geometry;
10
import org.gvsig.tools.evaluator.Evaluator;
11

    
12
public class DefaultFeatureAttributeDescriptor implements
13
                FeatureAttributeDescriptor {
14

    
15
        protected boolean allowNull;
16
        protected int dataType;
17
        protected DateFormat dataFormat;
18
        protected Object defaultValue;
19
        protected int index;
20
        protected int maximumOccurrences;
21
        protected int minimumOccurrences;
22
        protected int size;
23
        protected String name;
24
        protected Class objectClass;
25
        protected int precision;
26
        protected Evaluator evaluator;
27
        protected boolean primaryKey;
28
        protected boolean readOnly;
29
        protected String SRS;
30
        protected int geometryType;
31

    
32
    private static final Class TYPE_CLASS[] = new Class[] {
33
            null,
34
                        Byte.class, // keep for formatting
35
        Boolean.class,
36
        Integer.class,
37
        Long.class,
38
        Float.class,
39
        Double.class,
40
        String.class,
41
        Date.class,
42
        Date.class,
43
        Date.class,
44
        Geometry.class,
45
        Object.class, //
46
        Feature.class
47
    };
48

    
49
        protected DefaultFeatureAttributeDescriptor() {
50
                this.allowNull = false;
51
                this.dataType = DataTypes.UNKNOWN;
52
                this.dataFormat = null;
53
                this.defaultValue = null;
54
                this.index = -1;
55
                this.maximumOccurrences = 0;
56
                this.minimumOccurrences = 0;
57
                this.size = 0;
58
                this.name = null;
59
                this.objectClass = null;
60
                this.precision = 5;
61
                this.evaluator = null;
62
                this.primaryKey = false;
63
                this.readOnly = false;
64
                this.SRS = null;
65
                this.geometryType = Geometry.TYPES.NULL;
66
        }
67

    
68
        protected DefaultFeatureAttributeDescriptor(
69
                        DefaultFeatureAttributeDescriptor other) {
70
                this.allowNull = other.allowNull;
71
                this.dataType = other.dataType;
72
                this.dataFormat = other.dataFormat;
73
                this.defaultValue = other.defaultValue;
74
                this.index = other.index;
75
                this.maximumOccurrences = other.maximumOccurrences;
76
                this.minimumOccurrences = other.minimumOccurrences;
77
                this.size = other.size;
78
                this.name = other.name;
79
                this.objectClass = other.objectClass;
80
                this.precision = other.precision;
81
                this.evaluator = other.evaluator;
82
                this.primaryKey = other.primaryKey;
83
                this.readOnly = other.readOnly;
84
                this.SRS = other.SRS;
85
                this.geometryType = other.geometryType;
86
        }
87

    
88
        public String getDataTypeName() {
89
                return DataTypes.TYPE_NAMES[this.getDataType()];
90
        }
91

    
92
        public FeatureAttributeDescriptor getCopy() {
93
                return new DefaultFeatureAttributeDescriptor(this);
94
        }
95

    
96
        public boolean allowNull() {
97
                return allowNull;
98
        }
99

    
100
        public int getDataType() {
101
                return this.dataType;
102
        }
103

    
104
        public DateFormat getDateFormat() {
105
                return this.dataFormat;
106
        }
107

    
108
        public Object getDefaultValue() {
109
                return this.defaultValue;
110
        }
111

    
112
        public Evaluator getEvaluator() {
113
                return this.evaluator;
114
        }
115

    
116
        public int getGeometryType() {
117
                return this.geometryType;
118
        }
119

    
120
        public int getIndex() {
121
                return this.index;
122
        }
123

    
124
        public int getMaximumOccurrences() {
125
                return this.maximumOccurrences;
126
        }
127

    
128
        public int getMinimumOccurrences() {
129
                return this.minimumOccurrences;
130
        }
131

    
132
        public String getName() {
133
                return this.name;
134
        }
135

    
136
        public Class getObjectClass() {
137
                return TYPE_CLASS[this.dataType];
138
        }
139

    
140
        public int getPrecision() {
141
                return this.precision;
142
        }
143

    
144
        public String getSRS() {
145
                return this.SRS;
146
        }
147

    
148
        public int getSize() {
149
                return this.size;
150
        }
151

    
152
        public boolean isPrimaryKey() {
153
                return this.primaryKey;
154
        }
155

    
156
        public boolean isReadOnly() {
157
                return this.readOnly;
158
        }
159

    
160
}