Newer
Older
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/**
* This module represents an AttributeType.
* AttributeTypes defines name, type (string, double,...) an associated parameter of an attribute.
*
* @module AttributeType
* @fileOverview
*/
define(['easejs',
'parameterList'],
function(easejs,
ParameterList){
/**
* @class Attribute
* @classdesc AttributeValue extends AttributeTypes and adds the associated
* value.
* @requires easejs
* @requires ParameterList
*/
var Class = easejs.Class;
var Attribute = Class('Attribute',{
/**
* @alias name
* @protected
* @type {string}
* @memberof AttributeType#
* @desc Name of the Attribute
*/
'protected name' : '',
/**
* @alias type
* @protected
* @type {string}
* @memberof AttributeType#
* @desc Defines the type of the Attribute (i.e String, Double,...)
*/
'protected type' : '',
/**
* @alias parameterList
* @protected
* @type {ParameterList}
* @memberof AttributeType#
* @desc Name of the Attribute
*/
'protected parameterList' : [],
/**
* @alias value
* @protected
* @type {string}
* @memberof AttributeValue#
*/
'protected value' : 'NO_VALUE',
/**
* @alias timestamp
* @protected
* @type {Date}
* @memberof AttributeValue#
* @desc Time when the value was set.
*/
'protected timestamp' : '',
/**
* Constructor: Initializes the ParameterList.
*
* @class AttributeType
* @classdesc AttributeTypes defines name, type (string, double,...) an associated parameter of an attribute.
* @requires easejs
* @requires ParameterList
* @constructs AttributeType
*/
'public __construct' : function(){
this.parameterList = new ParameterList();
},
/**
* Builder for name.
*
* @public
* @alias withName
* @memberof AttributeType#
* @param {String} _name Name
* @returns {AttributeType}
*/
'public withName' : function(_name){
this.setName(_name);
return this;
},
/**
* Builder for type.
*
* @public
* @alias withType
* @memberof AttributeType#
* @param {String} _type Type
* @returns {AttributeType}
*/
'public withType' : function(_type){
this.setType(_type);
return this;
},
/**
* Builder for one parameter.
*
* @public
* @alias withParameters
* @memberof AttributeType#
* @param {Parameter} _parameter Parameter
* @returns {AttributeType}
*/
'public withParameter' : function(_parameter){
this.addParameter(_parameter);
return this;
},
/**
* Builder for parameterList.
*
* @public
* @alias withParameters
* @memberof AttributeType#
* @param {(ParameterList|Array)} _parameterList ParameterList
* @returns {AttributeType}
*/
'public withParameters' : function(_parameterList){
this.setParameters(_parameterList);
return this;
},
/**
* Builder for value.
*
* @public
* @alias withValue
* @memberof AttributeValue#
* @param {String} _value value
* @returns {AttributeValue}
*/
'public withValue' : function(_value) {
this.setValue(_value);
this.setTimestamp(Date.now());
return this;
},
/**
* Builder for timestamp.
*
* @public
* @alias withTimestamp
* @memberof AttributeValue#
* @param {Date} _timestamp timestamp
* @returns {AttributeValue}
*/
'public withTimestamp' : function(_timestamp) {
this.setTimestamp(_timestamp);
return this;
},
/**
* Returns the name.
*
* @public
* @alias getName
* @memberof AttributeType#
* @returns {string}
*/
'public getName' : function(){
return this.name;
},
/**
* Returns the type.
*
* @public
* @alias getType
* @memberof AttributeType#
* @returns {string}
*/
'public getType' : function(){
return this.type;
},
/**
* Returns the parameters.
*
* @public
* @alias getParameters
* @memberof AttributeType#
* @returns {ParameterList}
*/
'public getParameters' : function(){
return this.parameterList;
},
/**
* Sets the name.
*
* @public
* @alias setName
* @memberof AttributeType#
* @param {string} _name Name
*/
'public setName' : function(_name){
if(typeof _name === 'string'){
this.name = _name;
}
},
/**
* Sets the type.
*
* @public
* @alias setType
* @memberof AttributeType#
* @param {string} _type Type
*/
'public setType' : function(_type){
if(typeof _type === 'string'){
this.type = _type;
}
},
/**
* Adds a parameter.
*
* @public
* @alias addParameter
* @memberof AttributeType#
* @param {Parameter} _parameter Parameter
*/
'public addParameter' : function(_parameter){
this.parameterList.put(_parameter);
},
/**
* Adds a list of Parameter.
*
* @public
* @alias setParameters
* @memberof AttributeType#
* @param {ParameterList} _parameters ParameterList
*/
'public setParameters' : function(_parameters){
this.parameterList.putAll(_parameters);
},
/**
* Returns true if the attribute is parameterized.
*
* @public
* @alias hasParameters
* @memberof Attribute#
* @returns {boolean}
*/
'public hasParameters' : function() {
return this.parameterList.size() > 0;
},
/**
* Sets the value.
*
* @public
* @alias setValue
* @memberof AttributeValue#
* @param {string} _value value
*/
'public setValue' : function(_value) {
this.value = _value;
},
/**
* Returns the value.
*
* @public
* @alias getValue
* @memberof AttributeValue#
* @returns {string}
*/
'public getValue' : function() {
return this.value;
},
/**
* Sets the timestamp.
*
* @public
* @alias setTimestamp
* @memberof AttributeValue#
* @param {Date} _timestamp timestamp
*/
'public setTimestamp' : function(_time) {
this.timestamp = _time;
},
/**
* Returns the timestamp.
*
* @public
* @alias getTimestamp
* @memberof AttributeValue#
* @returns {string}
*/
'public getTimestamp' : function() {
return this.timestamp;
},
/**
*
* @public
* @alias hasInputParameter
* @memberof Attribute#
* @returns {boolean}
*/
'public hasInputParameter': function() {
return this.hasParameters() && this.parameterList.hasInputParameter();
},
/**
* Compares this instance with the given one.
*
* @public
* @alias equalsTypeOf
* @memberof Attribute#
* @param {Attribute} _attribute Attribute that should be compared.
* @returns {boolean}
*/
'public equalsTypeOf' : function(_attribute) {
if (Class.isA(Attribute, _attribute)) {
if (this.getName() == _attribute.getName() && this.getType() == _attribute.getType() && this.getParameters().equals(_attribute.getParameters())) {
return true;
}
}
return false;
},
/**
*
*
* @public
* @alias equalsValueOf
* @memberof Attribute#
* @param _attribute
* @returns {boolean}
*/
'public equalsValueOf' : function(_attribute) {
if (Class.isA(Attribute, _attribute)) {
if (this.equalsTypeOf(_attribute) && this.getValue() == _attribute.getValue()) {
return true;
}
}
return false;
},
/**
* Returns an identifier that uniquely describes the attribute type and its parameters.
* The identifier can be used to compare two attribute types. <br/>
* Format: (AttributeName:AttributeType)#[FirstParameterName:FirstParameterValue]…
*
* @public
* @alias toString
* @memberof AttributeType#
* @returns {String}
* @example (CI_USER_LOCATION_DISTANCE:FLOAT)#[CP_TARGET_LATITUDE:52][CP_TARGET_LONGITUDE:13][CP_UNIT:KILOMETERS]
*/
'public toString': function(_typeOnly) {
var identifier = "("+this.name+":"+this.type+")";
if (this.hasParameters()) {
identifier += "#";
for (var index in this.parameterList.getItems()) {
var theParameter = this.parameterList.getItems()[index];
identifier += theParameter.toString();
}
}
if (!_typeOnly) identifier += ":"+this.getValue();
return identifier;
}
});
return Attribute;
});