1 | import { TypeCode } from '../convert/TypeCode';
|
2 | import { ICloneable } from './ICloneable';
|
3 | import { AnyValue } from './AnyValue';
|
4 | import { AnyValueArray } from './AnyValueArray';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export declare class AnyValueMap implements ICloneable {
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | constructor(values?: any);
|
35 | /**
|
36 | * Gets a map element specified by its key.
|
37 | *
|
38 | * @param key a key of the element to get.
|
39 | * @returns the value of the map element.
|
40 | */
|
41 | get(key: string): any;
|
42 | /**
|
43 | * Gets keys of all elements stored in this map.
|
44 | *
|
45 | * @returns a list with all map keys.
|
46 | */
|
47 | getKeys(): string[];
|
48 | /**
|
49 | * Puts a new value into map element specified by its key.
|
50 | *
|
51 | * @param key a key of the element to put.
|
52 | * @param value a new value for map element.
|
53 | */
|
54 | put(key: string, value: any): any;
|
55 | /**
|
56 | * Removes a map element specified by its key
|
57 | *
|
58 | * @param key a key of the element to remove.
|
59 | */
|
60 | remove(key: string): void;
|
61 | /**
|
62 | * Appends new elements to this map.
|
63 | *
|
64 | * @param map a map with elements to be added.
|
65 | */
|
66 | append(map: any): void;
|
67 | /**
|
68 | * Clears this map by removing all its elements.
|
69 | */
|
70 | clear(): any;
|
71 | /**
|
72 | * Gets a number of elements stored in this map.
|
73 | *
|
74 | * @returns the number of elements in this map.
|
75 | */
|
76 | length(): number;
|
77 | /**
|
78 | * Gets the value stored in map element without any conversions.
|
79 | * When element key is not defined it returns the entire map value.
|
80 | *
|
81 | * @param key (optional) a key of the element to get
|
82 | * @returns the element value or value of the map when index is not defined.
|
83 | */
|
84 | getAsObject(key?: string): any;
|
85 | /**
|
86 | * Sets a new value to map element specified by its index.
|
87 | * When the index is not defined, it resets the entire map value.
|
88 | * This method has double purpose because method overrides are not supported in JavaScript.
|
89 | *
|
90 | * @param key (optional) a key of the element to set
|
91 | * @param value a new element or map value.
|
92 | *
|
93 | * @see [[MapConverter.toMap]]
|
94 | */
|
95 | setAsObject(key: any, value?: any): void;
|
96 | /**
|
97 | * Converts map element into a string or returns null if conversion is not possible.
|
98 | *
|
99 | * @param key a key of element to get.
|
100 | * @returns string value of the element or null if conversion is not supported.
|
101 | *
|
102 | * @see [[StringConverter.toNullableString]]
|
103 | */
|
104 | getAsNullableString(key: string): string;
|
105 | /**
|
106 | * Converts map element into a string or returns "" if conversion is not possible.
|
107 | *
|
108 | * @param key a key of element to get.
|
109 | * @returns string value of the element or "" if conversion is not supported.
|
110 | *
|
111 | * @see [[getAsStringWithDefault]]
|
112 | */
|
113 | getAsString(key: string): string;
|
114 | /**
|
115 | * Converts map element into a string or returns default value if conversion is not possible.
|
116 | *
|
117 | * @param key a key of element to get.
|
118 | * @param defaultValue the default value
|
119 | * @returns string value of the element or default value if conversion is not supported.
|
120 | *
|
121 | * @see [[StringConverter.toStringWithDefault]]
|
122 | */
|
123 | getAsStringWithDefault(key: string, defaultValue: string): string;
|
124 | /**
|
125 | * Converts map element into a boolean or returns null if conversion is not possible.
|
126 | *
|
127 | * @param key a key of element to get.
|
128 | * @returns boolean value of the element or null if conversion is not supported.
|
129 | *
|
130 | * @see [[BooleanConverter.toNullableBoolean]]
|
131 | */
|
132 | getAsNullableBoolean(key: string): boolean;
|
133 | /**
|
134 | * Converts map element into a boolean or returns false if conversion is not possible.
|
135 | *
|
136 | * @param key a key of element to get.
|
137 | * @returns boolean value of the element or false if conversion is not supported.
|
138 | *
|
139 | * @see [[getAsBooleanWithDefault]]
|
140 | */
|
141 | getAsBoolean(key: string): boolean;
|
142 | /**
|
143 | * Converts map element into a boolean or returns default value if conversion is not possible.
|
144 | *
|
145 | * @param key a key of element to get.
|
146 | * @param defaultValue the default value
|
147 | * @returns boolean value of the element or default value if conversion is not supported.
|
148 | *
|
149 | * @see [[BooleanConverter.toBooleanWithDefault]]
|
150 | */
|
151 | getAsBooleanWithDefault(key: string, defaultValue: boolean): boolean;
|
152 | /**
|
153 | * Converts map element into an integer or returns null if conversion is not possible.
|
154 | *
|
155 | * @param key a key of element to get.
|
156 | * @returns integer value of the element or null if conversion is not supported.
|
157 | *
|
158 | * @see [[IntegerConverter.toNullableInteger]]
|
159 | */
|
160 | getAsNullableInteger(key: string): number;
|
161 | /**
|
162 | * Converts map element into an integer or returns 0 if conversion is not possible.
|
163 | *
|
164 | * @param key a key of element to get.
|
165 | * @returns integer value of the element or 0 if conversion is not supported.
|
166 | *
|
167 | * @see [[getAsIntegerWithDefault]]
|
168 | */
|
169 | getAsInteger(key: string): number;
|
170 | /**
|
171 | * Converts map element into an integer or returns default value if conversion is not possible.
|
172 | *
|
173 | * @param key a key of element to get.
|
174 | * @param defaultValue the default value
|
175 | * @returns integer value of the element or default value if conversion is not supported.
|
176 | *
|
177 | * @see [[IntegerConverter.toIntegerWithDefault]]
|
178 | */
|
179 | getAsIntegerWithDefault(key: string, defaultValue: number): number;
|
180 | /**
|
181 | * Converts map element into a long or returns null if conversion is not possible.
|
182 | *
|
183 | * @param key a key of element to get.
|
184 | * @returns long value of the element or null if conversion is not supported.
|
185 | *
|
186 | * @see [[LongConverter.toNullableLong]]
|
187 | */
|
188 | getAsNullableLong(key: string): number;
|
189 | /**
|
190 | * Converts map element into a long or returns 0 if conversion is not possible.
|
191 | *
|
192 | * @param key a key of element to get.
|
193 | * @returns long value of the element or 0 if conversion is not supported.
|
194 | *
|
195 | * @see [[getAsLongWithDefault]]
|
196 | */
|
197 | getAsLong(key: string): number;
|
198 | /**
|
199 | * Converts map element into a long or returns default value if conversion is not possible.
|
200 | *
|
201 | * @param key a key of element to get.
|
202 | * @param defaultValue the default value
|
203 | * @returns long value of the element or default value if conversion is not supported.
|
204 | *
|
205 | * @see [[LongConverter.toLongWithDefault]]
|
206 | */
|
207 | getAsLongWithDefault(key: string, defaultValue: number): number;
|
208 | /**
|
209 | * Converts map element into a float or returns null if conversion is not possible.
|
210 | *
|
211 | * @param key a key of element to get.
|
212 | * @returns float value of the element or null if conversion is not supported.
|
213 | *
|
214 | * @see [[FloatConverter.toNullableFloat]]
|
215 | */
|
216 | getAsNullableFloat(key: string): number;
|
217 | /**
|
218 | * Converts map element into a float or returns 0 if conversion is not possible.
|
219 | *
|
220 | * @param key a key of element to get.
|
221 | * @returns float value of the element or 0 if conversion is not supported.
|
222 | *
|
223 | * @see [[getAsFloatWithDefault]]
|
224 | */
|
225 | getAsFloat(key: string): number;
|
226 | /**
|
227 | * Converts map element into a flot or returns default value if conversion is not possible.
|
228 | *
|
229 | * @param key a key of element to get.
|
230 | * @param defaultValue the default value
|
231 | * @returns flot value of the element or default value if conversion is not supported.
|
232 | *
|
233 | * @see [[FloatConverter.toFloatWithDefault]]
|
234 | */
|
235 | getAsFloatWithDefault(key: string, defaultValue: number): number;
|
236 | /**
|
237 | * Converts map element into a double or returns null if conversion is not possible.
|
238 | *
|
239 | * @param key a key of element to get.
|
240 | * @returns double value of the element or null if conversion is not supported.
|
241 | *
|
242 | * @see [[DoubleConverter.toNullableDouble]]
|
243 | */
|
244 | getAsNullableDouble(key: string): number;
|
245 | /**
|
246 | * Converts map element into a double or returns 0 if conversion is not possible.
|
247 | *
|
248 | * @param key a key of element to get.
|
249 | * @returns double value of the element or 0 if conversion is not supported.
|
250 | *
|
251 | * @see [[getAsDoubleWithDefault]]
|
252 | */
|
253 | getAsDouble(key: string): number;
|
254 | /**
|
255 | * Converts map element into a double or returns default value if conversion is not possible.
|
256 | *
|
257 | * @param key a key of element to get.
|
258 | * @param defaultValue the default value
|
259 | * @returns double value of the element or default value if conversion is not supported.
|
260 | *
|
261 | * @see [[DoubleConverter.toDoubleWithDefault]]
|
262 | */
|
263 | getAsDoubleWithDefault(key: string, defaultValue: number): number;
|
264 | /**
|
265 | * Converts map element into a Date or returns null if conversion is not possible.
|
266 | *
|
267 | * @param key a key of element to get.
|
268 | * @returns Date value of the element or null if conversion is not supported.
|
269 | *
|
270 | * @see [[DateTimeConverter.toNullableDateTime]]
|
271 | */
|
272 | getAsNullableDateTime(key: string): Date;
|
273 | /**
|
274 | * Converts map element into a Date or returns the current date if conversion is not possible.
|
275 | *
|
276 | * @param key a key of element to get.
|
277 | * @returns Date value of the element or the current date if conversion is not supported.
|
278 | *
|
279 | * @see [[getAsDateTimeWithDefault]]
|
280 | */
|
281 | getAsDateTime(key: string): Date;
|
282 | /**
|
283 | * Converts map element into a Date or returns default value if conversion is not possible.
|
284 | *
|
285 | * @param key a key of element to get.
|
286 | * @param defaultValue the default value
|
287 | * @returns Date value of the element or default value if conversion is not supported.
|
288 | *
|
289 | * @see [[DateTimeConverter.toDateTimeWithDefault]]
|
290 | */
|
291 | getAsDateTimeWithDefault(key: string, defaultValue: Date): Date;
|
292 | /**
|
293 | * Converts map element into a value defined by specied typecode.
|
294 | * If conversion is not possible it returns null.
|
295 | *
|
296 | * @param type the TypeCode that defined the type of the result
|
297 | * @param key a key of element to get.
|
298 | * @returns element value defined by the typecode or null if conversion is not supported.
|
299 | *
|
300 | * @see [[TypeConverter.toNullableType]]
|
301 | */
|
302 | getAsNullableType<T>(type: TypeCode, key: string): T;
|
303 | /**
|
304 | * Converts map element into a value defined by specied typecode.
|
305 | * If conversion is not possible it returns default value for the specified type.
|
306 | *
|
307 | * @param type the TypeCode that defined the type of the result
|
308 | * @param key a key of element to get.
|
309 | * @returns element value defined by the typecode or default if conversion is not supported.
|
310 | *
|
311 | * @see [[getAsTypeWithDefault]]
|
312 | */
|
313 | getAsType<T>(type: TypeCode, key: string): T;
|
314 | /**
|
315 | * Converts map element into a value defined by specied typecode.
|
316 | * If conversion is not possible it returns default value.
|
317 | *
|
318 | * @param type the TypeCode that defined the type of the result
|
319 | * @param key a key of element to get.
|
320 | * @param defaultValue the default value
|
321 | * @returns element value defined by the typecode or default value if conversion is not supported.
|
322 | *
|
323 | * @see [[TypeConverter.toTypeWithDefault]]
|
324 | */
|
325 | getAsTypeWithDefault<T>(type: TypeCode, key: string, defaultValue: T): T;
|
326 | /**
|
327 | * Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.
|
328 | *
|
329 | * @param key a key of element to get.
|
330 | * @returns AnyValue value of the element or empty AnyValue if conversion is not supported.
|
331 | *
|
332 | * @see [[AnyValue]]
|
333 | * @see [[AnyValue.constructor]]
|
334 | */
|
335 | getAsValue(key: string): AnyValue;
|
336 | /**
|
337 | * Converts map element into an AnyValueArray or returns null if conversion is not possible.
|
338 | *
|
339 | * @param key a key of element to get.
|
340 | * @returns AnyValueArray value of the element or null if conversion is not supported.
|
341 | *
|
342 | * @see [[AnyValueArray]]
|
343 | * @see [[AnyValueArray.fromValue]]
|
344 | */
|
345 | getAsNullableArray(key: string): AnyValueArray;
|
346 | /**
|
347 | * Converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.
|
348 | *
|
349 | * @param key a key of element to get.
|
350 | * @returns AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.
|
351 | *
|
352 | * @see [[AnyValueArray]]
|
353 | * @see [[AnyValueArray.fromValue]]
|
354 | */
|
355 | getAsArray(key: string): AnyValueArray;
|
356 | /**
|
357 | * Converts map element into an AnyValueArray or returns default value if conversion is not possible.
|
358 | *
|
359 | * @param key a key of element to get.
|
360 | * @param defaultValue the default value
|
361 | * @returns AnyValueArray value of the element or default value if conversion is not supported.
|
362 | *
|
363 | * @see [[AnyValueArray]]
|
364 | * @see [[getAsNullableArray]]
|
365 | */
|
366 | getAsArrayWithDefault(key: string, defaultValue: AnyValueArray): AnyValueArray;
|
367 | /**
|
368 | * Converts map element into an AnyValueMap or returns null if conversion is not possible.
|
369 | *
|
370 | * @param key a key of element to get.
|
371 | * @returns AnyValueMap value of the element or null if conversion is not supported.
|
372 | *
|
373 | * @see [[fromValue]]
|
374 | */
|
375 | getAsNullableMap(key: string): AnyValueMap;
|
376 | /**
|
377 | * Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
|
378 | *
|
379 | * @param key a key of element to get.
|
380 | * @returns AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.
|
381 | *
|
382 | * @see [[fromValue]]
|
383 | */
|
384 | getAsMap(key: string): AnyValueMap;
|
385 | /**
|
386 | * Converts map element into an AnyValueMap or returns default value if conversion is not possible.
|
387 | *
|
388 | * @param key a key of element to get.
|
389 | * @param defaultValue the default value
|
390 | * @returns AnyValueMap value of the element or default value if conversion is not supported.
|
391 | *
|
392 | * @see [[getAsNullableMap]]
|
393 | */
|
394 | getAsMapWithDefault(key: string, defaultValue: AnyValueMap): AnyValueMap;
|
395 | /**
|
396 | * Gets a string representation of the object.
|
397 | * The result is a semicolon-separated list of key-value pairs as
|
398 | * "key1=value1;key2=value2;key=value3"
|
399 | *
|
400 | * @returns a string representation of the object.
|
401 | */
|
402 | toString(): string;
|
403 | /**
|
404 | * Creates a binary clone of this object.
|
405 | *
|
406 | * @returns a clone of this object.
|
407 | */
|
408 | clone(): any;
|
409 | /**
|
410 | * Converts specified value into AnyValueMap.
|
411 | *
|
412 | * @param value value to be converted
|
413 | * @returns a newly created AnyValueMap.
|
414 | *
|
415 | * @see [[setAsObject]]
|
416 | */
|
417 | static fromValue(value: any): AnyValueMap;
|
418 | /**
|
419 | * Creates a new AnyValueMap from a list of key-value pairs called tuples.
|
420 | *
|
421 | * @param tuples a list of values where odd elements are keys and the following even elements are values
|
422 | * @returns a newly created AnyValueArray.
|
423 | *
|
424 | * @see [[fromTuplesArray]]
|
425 | */
|
426 | static fromTuples(...tuples: any[]): AnyValueMap;
|
427 | /**
|
428 | * Creates a new AnyValueMap from a list of key-value pairs called tuples.
|
429 | * The method is similar to [[fromTuples]] but tuples are passed as array instead of parameters.
|
430 | *
|
431 | * @param tuples a list of values where odd elements are keys and the following even elements are values
|
432 | * @returns a newly created AnyValueArray.
|
433 | */
|
434 | static fromTuplesArray(tuples: any[]): AnyValueMap;
|
435 | /**
|
436 | * Creates a new AnyValueMap by merging two or more maps.
|
437 | * Maps defined later in the list override values from previously defined maps.
|
438 | *
|
439 | * @param maps an array of maps to be merged
|
440 | * @returns a newly created AnyValueMap.
|
441 | */
|
442 | static fromMaps(...maps: any[]): AnyValueMap;
|
443 | }
|