-
Notifications
You must be signed in to change notification settings - Fork 5
/
CPAttributeDescription.j
128 lines (108 loc) · 2.92 KB
/
CPAttributeDescription.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// CPAttributeDescription.j
//
// Created by Raphael Bartolome on 15.10.09.
//
@import <Foundation/Foundation.j>
@import "CPPropertyDescription.j"
CPDUndefinedAttributeType = 0;
CPDIntegerAttributeType = 100;
CPDInteger16AttributeType = 200;
CPDInteger32AttributeType = 300;
CPDInteger64AttributeType = 400;
CPDDecimalAttributeType = 500;
CPDDoubleAttributeType = 600;
CPDFloatAttributeType = 700;
CPDStringAttributeType = 800;
CPDBooleanAttributeType = 900;
CPDDateAttributeType = 1000,
CPDBinaryDataAttributeType = 1100,
CPDTransformableAttributeType = 1200;
@implementation CPAttributeDescription : CPPropertyDescription
{
CPString _classValue;
int _typeValue @accessors(property=typeValue);
id _defaultValue @accessors(property=defaultValue);
CPString _valueTransformerName @accessors(property=valueTransformerName);
}
+ (CPString)typeNameForTypeValue:(CPUInteger)typeValue
{
var result;
switch(typeValue)
{
case 0:
result = "CPDUndefinedAttributeType";break;
case 100:
result = "CPDIntegerAttributeType";break;
case 200:
result = "CPDInteger16AttributeType";break;
case 300:
result = "CPDInteger32AttributeType";break;
case 400:
result = "CPDInteger64AttributeType";break;
case 500:
result = "CPDDecimalAttributeType";break;
case 600:
result = "CPDDoubleAttributeType";break;
case 700:
result = "CPDFloatAttributeType";break;
case 800:
result = "CPDStringAttributeType";break;
case 900:
result = "CPDBooleanAttributeType";break;
case 1000:
result = "CPDDateAttributeType";break;
case 1100:
result = "CPDBinaryDataAttributeType";break;
case 1200:
result = "CPDTransformableAttributeType";break;
default:
result = "CPDUndefinedAttributeType";
}
return result;
}
- (void)setClassValue:(CPString) aClassValue
{
_classValue = aClassValue;
}
- (Class)classValue
{
var result = [CPObject class];
var classType = CPClassFromString(_classValue);
if(classType != nil)
{
result = classType;
}
return result
}
- (CPString)classValueName
{
return _classValue
}
- (CPString)typeName
{
return [self.isa typeNameForTypeValue:_typeValue];
}
- (BOOL)acceptValue:(id) aValue
{
var result = NO;
if([aValue isKindOfClass:[self classValue]])
{
result = YES;
}
return result;
}
- (CPString)stringRepresentation
{
var result = "\n";
result = result + "\n";
result = result + "-CPAttributeDescription-";
result = result + "\n";
result = result + "name:" + [self name] + ";";
result = result + "\n";
result = result + "type:" + [self typeValue] + ";";
result = result + "\n";
result = result + "optional:" + [self isOptional] + ";";
return result;
}
@end