Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/eventbus/client/ParamMap.java

Diff revisions: vs.
  @@ -1,1051 +1,1051 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.eventbus.client;
3 -
4 - import java.io.*;
5 - import java.util.*;
6 -
7 - public class ParamMap implements Serializable {
8 - public static final ParamMap LOCKED_EMPTY = new ImmutableParamMap();
9 -
10 - public static ParamMap immutableCopy( ParamMap paramMap ) {
11 - return (paramMap != null) ? paramMap.immutableCopy() : null;
12 - }
13 -
14 - public ParamMap immutableCopy() {
15 - return new ImmutableParamMap( this );
16 - }
17 -
18 - // Native boolean
19 - public ParamMap add( String key, boolean value ) {
20 - return privatePut( key, Boolean.valueOf( value ) );
21 - }
22 -
23 - public ParamMap add( String key, boolean[] value ) {
24 - return privatePut( key, value );
25 - }
26 -
27 - public boolean get_boolean( String pKey, boolean pDefault ) {
28 - return get_booleanFrom( this, pKey, pDefault );
29 - }
30 -
31 - public static boolean get_booleanFrom( ParamMap pMap, String pKey, boolean pDefault ) {
32 - Boolean value = getBooleanFrom( pMap, pKey );
33 - //noinspection UnnecessaryUnboxing
34 - return value != null ? value.booleanValue() : pDefault;
35 - }
36 -
37 - public boolean[] get_booleanArray( String pKey ) {
38 - return get_booleanArrayFrom( this, pKey );
39 - }
40 -
41 - public boolean[] get_booleanArray( String pKey, boolean[] pDefault ) {
42 - return get_booleanArrayFrom( this, pKey, pDefault );
43 - }
44 -
45 - public static boolean[] get_booleanArrayFrom( ParamMap pMap, String pKey, boolean[] pDefault ) {
46 - boolean[] value = get_booleanArrayFrom( pMap, pKey );
47 - //noinspection UnnecessaryUnboxing
48 - return value != null ? value : pDefault;
49 - }
50 -
51 - public static boolean[] get_booleanArrayFrom( ParamMap pMap, String pKey ) {
52 - return (boolean[]) getFrom( pMap, pKey );
53 - }
54 -
55 - // Boolean
56 - public ParamMap add( String key, Boolean value ) {
57 - return privatePut( key, value );
58 - }
59 -
60 - public ParamMap add( String key, Boolean[] value ) {
61 - return privatePut( key, value );
62 - }
63 -
64 - public Boolean getBoolean( String pKey ) {
65 - return getBoolean( pKey, null );
66 - }
67 -
68 - public Boolean getBoolean( String pKey, Boolean pDefault ) {
69 - return getBooleanFrom( this, pKey, pDefault );
70 - }
71 -
72 - public static Boolean getBooleanFrom( ParamMap pMap, String pKey, Boolean pDefault ) {
73 - Boolean value = getBooleanFrom( pMap, pKey );
74 - return (value != null) ? value : pDefault;
75 - }
76 -
77 - public static Boolean getBooleanFrom( ParamMap pMap, String pKey ) {
78 - Object value = getFrom( pMap, pKey );
79 - if ( value == null ) {
80 - return null;
81 - }
82 - if ( value instanceof Boolean ) {
83 - return (Boolean) value;
84 - }
85 - return Boolean.valueOf( value.toString() );
86 - }
87 -
88 - public Boolean[] getBooleanArray( String pKey ) {
89 - return getBooleanArrayFrom( this, pKey );
90 - }
91 -
92 - public Boolean[] getBooleanArray( String pKey, Boolean[] pDefault ) {
93 - return getBooleanArrayFrom( this, pKey, pDefault );
94 - }
95 -
96 - public static Boolean[] getBooleanArrayFrom( ParamMap pMap, String pKey, Boolean[] pDefault ) {
97 - Boolean[] value = getBooleanArrayFrom( pMap, pKey );
98 - return (value != null) ? value : pDefault;
99 - }
100 -
101 - public static Boolean[] getBooleanArrayFrom( ParamMap pMap, String pKey ) {
102 - return (Boolean[]) getFrom( pMap, pKey );
103 - }
104 -
105 - // Date
106 - public ParamMap add( String key, Date value ) {
107 - return privatePut( key, value );
108 - }
109 -
110 - public ParamMap add( String key, Date[] value ) {
111 - return privatePut( key, value );
112 - }
113 -
114 - public Date getDate( String pKey ) {
115 - return getDate( pKey, null );
116 - }
117 -
118 - public Date getDate( String pKey, Date pDefault ) {
119 - return getDateFrom( this, pKey, pDefault );
120 - }
121 -
122 - public static Date getDateFrom( ParamMap pMap, String pKey ) {
123 - return (Date) getFrom( pMap, pKey );
124 - }
125 -
126 - public static Date getDateFrom( ParamMap pMap, String pKey, Date pDefault ) {
127 - Date value = getDateFrom( pMap, pKey );
128 - return (value != null) ? value : pDefault;
129 - }
130 -
131 - public Date[] getDateArray( String pKey ) {
132 - return getDateArrayFrom( this, pKey );
133 - }
134 -
135 - public Date[] getDateArray( String pKey, Date[] pDefault ) {
136 - return getDateArrayFrom( this, pKey, pDefault );
137 - }
138 -
139 - public static Date[] getDateArrayFrom( ParamMap pMap, String pKey, Date[] pDefault ) {
140 - Date[] value = getDateArrayFrom( pMap, pKey );
141 - return (value != null) ? value : pDefault;
142 - }
143 -
144 - public static Date[] getDateArrayFrom( ParamMap pMap, String pKey ) {
145 - return (Date[]) getFrom( pMap, pKey );
146 - }
147 -
148 - // Native double
149 - public ParamMap add( String key, double value ) {
150 - return privatePut( key, new Double( value ) );
151 - }
152 -
153 - public ParamMap add( String key, double[] value ) {
154 - return privatePut( key, value );
155 - }
156 -
157 - public double get_double( String pKey, double pDefault ) {
158 - return get_doubleFrom( this, pKey, pDefault );
159 - }
160 -
161 - public static double get_doubleFrom( ParamMap pMap, String pKey, double pDefault ) {
162 - Double value = getDoubleFrom( pMap, pKey );
163 - //noinspection UnnecessaryUnboxing
164 - return value != null ? value.doubleValue() : pDefault;
165 - }
166 -
167 - public double[] get_doubleArray( String pKey ) {
168 - return get_doubleArrayFrom( this, pKey );
169 - }
170 -
171 - public double[] get_doubleArray( String pKey, double[] pDefault ) {
172 - return get_doubleArrayFrom( this, pKey, pDefault );
173 - }
174 -
175 - public static double[] get_doubleArrayFrom( ParamMap pMap, String pKey, double[] pDefault ) {
176 - double[] value = get_doubleArrayFrom( pMap, pKey );
177 - return value != null ? value : pDefault;
178 - }
179 -
180 - public static double[] get_doubleArrayFrom( ParamMap pMap, String pKey ) {
181 - return (double[]) getFrom( pMap, pKey );
182 - }
183 -
184 - // Double
185 - public ParamMap add( String key, Double value ) {
186 - return privatePut( key, value );
187 - }
188 -
189 - public ParamMap add( String key, Double[] value ) {
190 - return privatePut( key, value );
191 - }
192 -
193 - public Double getDouble( String pKey ) {
194 - return getDouble( pKey, null );
195 - }
196 -
197 - public Double getDouble( String pKey, Double pDefault ) {
198 - return getDoubleFrom( this, pKey, pDefault );
199 - }
200 -
201 - public static Double getDoubleFrom( ParamMap pMap, String pKey, Double pDefault ) {
202 - Double value = getDoubleFrom( pMap, pKey );
203 - return (value != null) ? value : pDefault;
204 - }
205 -
206 - public static Double getDoubleFrom( ParamMap pMap, String pKey ) {
207 - Object value = getFrom( pMap, pKey );
208 - if ( value == null ) {
209 - return null;
210 - }
211 - if ( value instanceof Double ) {
212 - return (Double) value;
213 - }
214 - if ( value instanceof Number ) {
215 - //noinspection UnnecessaryBoxing
216 - return new Double( ((Number) value).doubleValue() );
217 - }
218 - return new Double( value.toString() );
219 - }
220 -
221 - public Double[] getDoubleArray( String pKey ) {
222 - return getDoubleArrayFrom( this, pKey );
223 - }
224 -
225 - public Double[] getDoubleArray( String pKey, Double[] pDefault ) {
226 - return getDoubleArrayFrom( this, pKey, pDefault );
227 - }
228 -
229 - public static Double[] getDoubleArrayFrom( ParamMap pMap, String pKey, Double[] pDefault ) {
230 - Double[] value = getDoubleArrayFrom( pMap, pKey );
231 - return (value != null) ? value : pDefault;
232 - }
233 -
234 - public static Double[] getDoubleArrayFrom( ParamMap pMap, String pKey ) {
235 - return (Double[]) getFrom( pMap, pKey );
236 - }
237 -
238 - // Native float
239 - public ParamMap add( String key, float value ) {
240 - return privatePut( key, new Float( value ) );
241 - }
242 -
243 - public ParamMap add( String key, float[] value ) {
244 - return privatePut( key, value );
245 - }
246 -
247 - public float get_float( String pKey, float pDefault ) {
248 - return get_floatFrom( this, pKey, pDefault );
249 - }
250 -
251 - public static float get_floatFrom( ParamMap pMap, String pKey, float pDefault ) {
252 - Float value = getFloatFrom( pMap, pKey );
253 - //noinspection UnnecessaryUnboxing
254 - return value != null ? value.floatValue() : pDefault;
255 - }
256 -
257 - public float[] get_floatArray( String pKey ) {
258 - return get_floatArrayFrom( this, pKey );
259 - }
260 -
261 - public float[] get_floatArray( String pKey, float[] pDefault ) {
262 - return get_floatArrayFrom( this, pKey, pDefault );
263 - }
264 -
265 - public static float[] get_floatArrayFrom( ParamMap pMap, String pKey, float[] pDefault ) {
266 - float[] value = get_floatArrayFrom( pMap, pKey );
267 - return value != null ? value : pDefault;
268 - }
269 -
270 - public static float[] get_floatArrayFrom( ParamMap pMap, String pKey ) {
271 - return (float[]) getFrom( pMap, pKey );
272 - }
273 -
274 - // Float
275 - public ParamMap add( String key, Float value ) {
276 - return privatePut( key, value );
277 - }
278 -
279 - public ParamMap add( String key, Float[] value ) {
280 - return privatePut( key, value );
281 - }
282 -
283 - public Float getFloat( String pKey ) {
284 - return getFloat( pKey, null );
285 - }
286 -
287 - public Float getFloat( String pKey, Float pDefault ) {
288 - return getFloatFrom( this, pKey, pDefault );
289 - }
290 -
291 - public static Float getFloatFrom( ParamMap pMap, String pKey, Float pDefault ) {
292 - Float value = getFloatFrom( pMap, pKey );
293 - return (value != null) ? value : pDefault;
294 - }
295 -
296 - public static Float getFloatFrom( ParamMap pMap, String pKey ) {
297 - Object value = getFrom( pMap, pKey );
298 - if ( value == null ) {
299 - return null;
300 - }
301 - if ( value instanceof Float ) {
302 - return (Float) value;
303 - }
304 - if ( value instanceof Number ) {
305 - //noinspection UnnecessaryBoxing
306 - return new Float( ((Number) value).floatValue() );
307 - }
308 - return new Float( value.toString() );
309 - }
310 -
311 - public Float[] getFloatArray( String pKey ) {
312 - return getFloatArrayFrom( this, pKey );
313 - }
314 -
315 - public Float[] getFloatArray( String pKey, Float[] pDefault ) {
316 - return getFloatArrayFrom( this, pKey, pDefault );
317 - }
318 -
319 - public static Float[] getFloatArrayFrom( ParamMap pMap, String pKey, Float[] pDefault ) {
320 - Float[] value = getFloatArrayFrom( pMap, pKey );
321 - return (value != null) ? value : pDefault;
322 - }
323 -
324 - public static Float[] getFloatArrayFrom( ParamMap pMap, String pKey ) {
325 - return (Float[]) getFrom( pMap, pKey );
326 - }
327 -
328 - // Native int
329 - public ParamMap add( String key, int value ) {
330 - return privatePut( key, new Integer( value ) );
331 - }
332 -
333 - public ParamMap add( String key, int[] value ) {
334 - return privatePut( key, value );
335 - }
336 -
337 - public int get_int( String pKey, int pDefault ) {
338 - return get_intFrom( this, pKey, pDefault );
339 - }
340 -
341 - public static int get_intFrom( ParamMap pMap, String pKey, int pDefault ) {
342 - Integer value = getIntegerFrom( pMap, pKey );
343 - //noinspection UnnecessaryUnboxing
344 - return value != null ? value.intValue() : pDefault;
345 - }
346 -
347 - public int[] get_intArray( String pKey ) {
348 - return get_intArrayFrom( this, pKey );
349 - }
350 -
351 - public int[] get_intArray( String pKey, int[] pDefault ) {
352 - return get_intArrayFrom( this, pKey, pDefault );
353 - }
354 -
355 - public static int[] get_intArrayFrom( ParamMap pMap, String pKey, int[] pDefault ) {
356 - int[] value = get_intArrayFrom( pMap, pKey );
357 - return value != null ? value : pDefault;
358 - }
359 -
360 - public static int[] get_intArrayFrom( ParamMap pMap, String pKey ) {
361 - return (int[]) getFrom( pMap, pKey );
362 - }
363 -
364 - // Integer
365 - public ParamMap add( String key, Integer value ) {
366 - return privatePut( key, value );
367 - }
368 -
369 - public ParamMap add( String key, Integer[] value ) {
370 - return privatePut( key, value );
371 - }
372 -
373 - public Integer getInteger( String pKey ) {
374 - return getInteger( pKey, null );
375 - }
376 -
377 - public Integer getInteger( String pKey, Integer pDefault ) {
378 - return getIntegerFrom( this, pKey, pDefault );
379 - }
380 -
381 - public static Integer getIntegerFrom( ParamMap pMap, String pKey, Integer pDefault ) {
382 - Integer value = getIntegerFrom( pMap, pKey );
383 - return (value != null) ? value : pDefault;
384 - }
385 -
386 - public static Integer getIntegerFrom( ParamMap pMap, String pKey ) {
387 - Object value = getFrom( pMap, pKey );
388 - if ( value == null ) {
389 - return null;
390 - }
391 - if ( value instanceof Integer ) {
392 - return (Integer) value;
393 - }
394 - if ( value instanceof Number ) {
395 - //noinspection UnnecessaryBoxing
396 - return new Integer( ((Number) value).intValue() );
397 - }
398 - return new Integer( value.toString() );
399 - }
400 -
401 - public Integer[] getIntegerArray( String pKey ) {
402 - return getIntegerArrayFrom( this, pKey );
403 - }
404 -
405 - public Integer[] getIntegerArray( String pKey, Integer[] pDefault ) {
406 - return getIntegerArrayFrom( this, pKey, pDefault );
407 - }
408 -
409 - public static Integer[] getIntegerArrayFrom( ParamMap pMap, String pKey, Integer[] pDefault ) {
410 - Integer[] value = getIntegerArrayFrom( pMap, pKey );
411 - return (value != null) ? value : pDefault;
412 - }
413 -
414 - public static Integer[] getIntegerArrayFrom( ParamMap pMap, String pKey ) {
415 - return (Integer[]) getFrom( pMap, pKey );
416 - }
417 -
418 - // Native long
419 - public ParamMap add( String key, long value ) {
420 - return privatePut( key, new Long( value ) );
421 - }
422 -
423 - public ParamMap add( String key, long[] value ) {
424 - return privatePut( key, value );
425 - }
426 -
427 - public long get_long( String pKey, long pDefault ) {
428 - return get_longFrom( this, pKey, pDefault );
429 - }
430 -
431 - public static long get_longFrom( ParamMap pMap, String pKey, long pDefault ) {
432 - Long value = getLongFrom( pMap, pKey );
433 - //noinspection UnnecessaryUnboxing
434 - return value != null ? value.longValue() : pDefault;
435 - }
436 -
437 - public long[] get_longArray( String pKey, long[] pDefault ) {
438 - return get_longArrayFrom( this, pKey, pDefault );
439 - }
440 -
441 - public static long[] get_longArrayFrom( ParamMap pMap, String pKey, long[] pDefault ) {
442 - long[] value = get_longArrayFrom( pMap, pKey );
443 - return value != null ? value : pDefault;
444 - }
445 -
446 - public static long[] get_longArrayFrom( ParamMap pMap, String pKey ) {
447 - return (long[]) getFrom( pMap, pKey );
448 - }
449 -
450 - // Long
451 - public ParamMap add( String key, Long value ) {
452 - return privatePut( key, value );
453 - }
454 -
455 - public ParamMap add( String key, Long[] value ) {
456 - return privatePut( key, value );
457 - }
458 -
459 - public Long getLong( String pKey ) {
460 - return getLong( pKey, null );
461 - }
462 -
463 - public Long getLong( String pKey, Long pDefault ) {
464 - return getLongFrom( this, pKey, pDefault );
465 - }
466 -
467 - public static Long getLongFrom( ParamMap pMap, String pKey, Long pDefault ) {
468 - Long value = getLongFrom( pMap, pKey );
469 - return (value != null) ? value : pDefault;
470 - }
471 -
472 - public static Long getLongFrom( ParamMap pMap, String pKey ) {
473 - Object value = getFrom( pMap, pKey );
474 - if ( value == null ) {
475 - return null;
476 - }
477 - if ( value instanceof Long ) {
478 - return (Long) value;
479 - }
480 - if ( value instanceof Number ) {
481 - //noinspection UnnecessaryBoxing
482 - return new Long( ((Number) value).longValue() );
483 - }
484 - return new Long( value.toString() );
485 - }
486 -
487 - public Long[] getLongArray( String pKey ) {
488 - return getLongArrayFrom( this, pKey );
489 - }
490 -
491 - public Long[] getLongArray( String pKey, Long[] pDefault ) {
492 - return getLongArrayFrom( this, pKey, pDefault );
493 - }
494 -
495 - public static Long[] getLongArrayFrom( ParamMap pMap, String pKey, Long[] pDefault ) {
496 - Long[] value = getLongArrayFrom( pMap, pKey );
497 - return (value != null) ? value : pDefault;
498 - }
499 -
500 - public static Long[] getLongArrayFrom( ParamMap pMap, String pKey ) {
501 - return (Long[]) getFrom( pMap, pKey );
502 - }
503 -
504 - // Native short
505 - public ParamMap add( String key, short value ) {
506 - return privatePut( key, new Short( value ) );
507 - }
508 -
509 - public ParamMap add( String key, Short[] value ) {
510 - return privatePut( key, value );
511 - }
512 -
513 - public short get_short( String pKey, short pDefault ) {
514 - return get_shortFrom( this, pKey, pDefault );
515 - }
516 -
517 - public static short get_shortFrom( ParamMap pMap, String pKey, short pDefault ) {
518 - Short value = getShortFrom( pMap, pKey );
519 - //noinspection UnnecessaryUnboxing
520 - return value != null ? value.shortValue() : pDefault;
521 - }
522 -
523 - public short[] get_shortArray( String pKey ) {
524 - return get_shortArrayFrom( this, pKey );
525 - }
526 -
527 - public short[] get_shortArray( String pKey, short[] pDefault ) {
528 - return get_shortArrayFrom( this, pKey, pDefault );
529 - }
530 -
531 - public static short[] get_shortArrayFrom( ParamMap pMap, String pKey, short[] pDefault ) {
532 - short[] value = get_shortArrayFrom( pMap, pKey );
533 - return value != null ? value : pDefault;
534 - }
535 -
536 - public static short[] get_shortArrayFrom( ParamMap pMap, String pKey ) {
537 - return (short[]) getFrom( pMap, pKey );
538 - }
539 -
540 - // Short
541 - public ParamMap add( String key, Short value ) {
542 - return privatePut( key, value );
543 - }
544 -
545 - public ParamMap add( String key, short[] value ) {
546 - return privatePut( key, value );
547 - }
548 -
549 - public Short getShort( String pKey ) {
550 - return getShort( pKey, null );
551 - }
552 -
553 - public Short getShort( String pKey, Short pDefault ) {
554 - return getShortFrom( this, pKey, pDefault );
555 - }
556 -
557 - public static Short getShortFrom( ParamMap pMap, String pKey, Short pDefault ) {
558 - Short value = getShortFrom( pMap, pKey );
559 - return (value != null) ? value : pDefault;
560 - }
561 -
562 - public static Short getShortFrom( ParamMap pMap, String pKey ) {
563 - Object value = getFrom( pMap, pKey );
564 - if ( value == null ) {
565 - return null;
566 - }
567 - if ( value instanceof Short ) {
568 - return (Short) value;
569 - }
570 - if ( value instanceof Number ) {
571 - //noinspection UnnecessaryBoxing
572 - return new Short( ((Number) value).shortValue() );
573 - }
574 - return new Short( value.toString() );
575 - }
576 -
577 - public Short[] getShortArray( String pKey ) {
578 - return getShortArrayFrom( this, pKey );
579 - }
580 -
581 - public Short[] getShortArray( String pKey, Short[] pDefault ) {
582 - return getShortArrayFrom( this, pKey, pDefault );
583 - }
584 -
585 - public static Short[] getShortArrayFrom( ParamMap pMap, String pKey, Short[] pDefault ) {
586 - Short[] value = getShortArrayFrom( pMap, pKey );
587 - return (value != null) ? value : pDefault;
588 - }
589 -
590 - public static Short[] getShortArrayFrom( ParamMap pMap, String pKey ) {
591 - return (Short[]) getFrom( pMap, pKey );
592 - }
593 -
594 - // String
595 - public ParamMap add( String key, String value ) {
596 - return privatePut( key, value );
597 - }
598 -
599 - public ParamMap add( String key, String[] value ) {
600 - return privatePut( key, value );
601 - }
602 -
603 - public String getString( String pKey ) {
604 - return getString( pKey, null );
605 - }
606 -
607 - public String getString( String pKey, String pDefault ) {
608 - return getStringFrom( this, pKey, pDefault );
609 - }
610 -
611 - public static String getStringFrom( ParamMap pMap, String pKey ) {
612 - Object value = getFrom( pMap, pKey );
613 - return (value == null) ? null : (String) value;
614 - }
615 -
616 - public static String getStringFrom( ParamMap pMap, String pKey, String pDefault ) {
617 - String value = getStringFrom( pMap, pKey );
618 - return (value != null) ? value : pDefault;
619 - }
620 -
621 - public String[] getStringArray( String pKey ) {
622 - return getStringArrayFrom( this, pKey );
623 - }
624 -
625 - public String[] getStringArray( String pKey, String[] pDefault ) {
626 - return getStringArrayFrom( this, pKey, pDefault );
627 - }
628 -
629 - public static String[] getStringArrayFrom( ParamMap pMap, String pKey, String[] pDefault ) {
630 - String[] value = getStringArrayFrom( pMap, pKey );
631 - return (value != null) ? value : pDefault;
632 - }
633 -
634 - public static String[] getStringArrayFrom( ParamMap pMap, String pKey ) {
635 - return (String[]) getFrom( pMap, pKey );
636 - }
637 -
638 - // ParamMap
639 - public ParamMap add( String key, ParamMap value ) {
640 - return privatePut( key, value );
641 - }
642 -
643 - public ParamMap add( String key, ParamMap[] value ) {
644 - return privatePut( key, value );
645 - }
646 -
647 - public ParamMap getParamMap( String pKey ) {
648 - return getParamMap( pKey, null );
649 - }
650 -
651 - public ParamMap getParamMap( String pKey, ParamMap pDefault ) {
652 - return getParamMapFrom( this, pKey, pDefault );
653 - }
654 -
655 - public static ParamMap getParamMapFrom( ParamMap pMap, String pKey ) {
656 - Object value = getFrom( pMap, pKey );
657 - return (value == null) ? null : (ParamMap) value;
658 - }
659 -
660 - public static ParamMap getParamMapFrom( ParamMap pMap, String pKey, ParamMap pDefault ) {
661 - ParamMap value = getParamMapFrom( pMap, pKey );
662 - return (value != null) ? value : pDefault;
663 - }
664 -
665 - public ParamMap[] getParamMapArray( String pKey ) {
666 - return getParamMapArrayFrom( this, pKey );
667 - }
668 -
669 - public ParamMap[] getParamMapArray( String pKey, ParamMap[] pDefault ) {
670 - return getParamMapArrayFrom( this, pKey, pDefault );
671 - }
672 -
673 - public static ParamMap[] getParamMapArrayFrom( ParamMap pMap, String pKey, ParamMap[] pDefault ) {
674 - ParamMap[] value = getParamMapArrayFrom( pMap, pKey );
675 - return (value != null) ? value : pDefault;
676 - }
677 -
678 - public static ParamMap[] getParamMapArrayFrom( ParamMap pMap, String pKey ) {
679 - return (ParamMap[]) getFrom( pMap, pKey );
680 - }
681 -
682 - // Serializable
683 - public ParamMap add( String key, Serializable value ) {
684 - return privatePut( key, value );
685 - }
686 -
687 - public ParamMap add( String key, Serializable[] value ) {
688 - return privatePut( key, value );
689 - }
690 -
691 - public Serializable getSerializable( String pKey ) {
692 - return getSerializable( pKey, null );
693 - }
694 -
695 - public Serializable getSerializable( String pKey, Serializable pDefault ) {
696 - return getSerializableFrom( this, pKey, pDefault );
697 - }
698 -
699 - public static Serializable getSerializableFrom( ParamMap pMap, String pKey, Serializable pDefault ) {
700 - Serializable value = getSerializableFrom( pMap, pKey );
701 - return (value != null) ? value : pDefault;
702 - }
703 -
704 - public static Serializable getSerializableFrom( ParamMap pMap, String pKey ) {
705 - Object value = getFrom( pMap, pKey );
706 - if ( value == null ) {
707 - return null;
708 - }
709 - return (Serializable) value;
710 - }
711 -
712 - public Serializable[] getSerializableArray( String pKey ) {
713 - return getSerializableArrayFrom( this, pKey );
714 - }
715 -
716 - public Serializable[] getSerializableArray( String pKey, Serializable[] pDefault ) {
717 - return getSerializableArrayFrom( this, pKey, pDefault );
718 - }
719 -
720 - public static Serializable[] getSerializableArrayFrom( ParamMap pMap, String pKey, Serializable[] pDefault ) {
721 - Serializable[] value = getSerializableArrayFrom( pMap, pKey );
722 - return (value != null) ? value : pDefault;
723 - }
724 -
725 - public static Serializable[] getSerializableArrayFrom( ParamMap pMap, String pKey ) {
726 - return (Serializable[]) getFrom( pMap, pKey );
727 - }
728 -
729 - // Object
730 - private static Object getFrom( ParamMap pMap, String pKey ) {
731 - return (pMap == null) ? null : pMap.mProxiedMap.get( pKey );
732 - }
733 -
734 - public ParamMap() {
735 - }
736 -
737 - public ParamMap( ParamMap pMap ) {
738 - LLputAll( pMap );
739 - }
740 -
741 - public ParamMap( String[] pNameValuePairs ) {
742 - if ( pNameValuePairs != null ) {
743 - if ( (pNameValuePairs.length & 1) == 1 ) {
744 - throw new IllegalArgumentException( "NameValuePairs not paired" );
745 - }
746 - for ( int i = 0; i < pNameValuePairs.length; ) {
747 - String name = pNameValuePairs[i++];
748 - String value = pNameValuePairs[i++];
749 - add( name, value );
750 - }
751 - }
752 - }
753 -
754 - private void LLputAll( ParamMap t ) {
755 - if ( t != null ) {
756 - invalidateCache();
757 - mProxiedMap.putAll( t.mProxiedMap );
758 - }
759 - }
760 -
761 - /**
762 - * Returns the number of key-value mappings in this map. If the
763 - * map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
764 - * <tt>Integer.MAX_VALUE</tt>.
765 - *
766 - * @return the number of key-value mappings in this map (or <tt>Integer.MAX_VALUE</tt>).
767 - */
768 - public int size() {
769 - return mProxiedMap.size();
770 - }
771 -
772 - /**
773 - * Returns <tt>true</tt> if this map contains no key-value mappings.
774 - *
775 - * @return <tt>true</tt> if this map contains no key-value mappings.
776 - */
777 - public boolean isEmpty() {
778 - return mProxiedMap.isEmpty();
779 - }
780 -
781 - /**
782 - * Returns <tt>true</tt> if this map contains a mapping for the specified
783 - * key. More formally, returns <tt>true</tt> if and only if
784 - * this map contains a mapping for a key <tt>k</tt> such that
785 - * <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
786 - * at most one such mapping.)
787 - *
788 - * @param key key whose presence in this map is to be tested.
789 - *
790 - * @return <tt>true</tt> if this map contains a mapping for the specified
791 - * key.
792 - *
793 - * @throws ClassCastException if the key is of an inappropriate type for
794 - * this map (optional).
795 - * @throws NullPointerException if the key is <tt>null</tt> and this map
796 - * does not permit <tt>null</tt> keys (optional).
797 - */
798 - public boolean containsKey( String key ) {
799 - return mProxiedMap.containsKey( key );
800 - }
801 -
802 - // todo: ==============================================================================================//
803 -
804 - // todo: Eliminate
805 - public <T> List<T> get_RawList_ThisMethodShouldNotEverEverBeUsed( String pKey ) {
806 - return (List<T>) getFrom( this, pKey );
807 - }
808 -
809 - // todo: Eliminate
810 - public <T> Set<T> get_RawSet_ThisMethodShouldNotEverEverBeUsed( String pKey ) {
811 - return (Set<T>) getFrom( this, pKey );
812 - }
813 -
814 - // todo: Eliminate
815 - public ParamMap add_RawMap_ThisMethodShouldNotEverEverBeUsed( String key, Map value ) {
816 - return privatePut( key, value );
817 - }
818 -
819 - // todo: Eliminate
820 - public ParamMap add_RawSet_ThisMethodShouldNotEverEverBeUsed( String key, Set value ) {
821 - return privatePut( key, value );
822 - }
823 -
824 - // todo: Eliminate
825 - public ParamMap add_RawList_ThisMethodShouldNotEverEverBeUsed( String key, List value ) {
826 - return privatePut( key, value );
827 - }
828 -
829 - // todo: Eliminate
830 - public void putAll_RawObjects_ThisMethodShouldNotEverEverBeUsed( Map<?, ?> t ) {
831 - if ( t != null ) {
832 - //noinspection ForLoopReplaceableByForEach
833 - for ( Iterator<?> it = t.keySet().iterator(); it.hasNext(); ) {
834 - Object key = it.next();
835 - if ( key instanceof String ) {
836 - privatePut( key.toString(), t.get( key ) );
837 - }
838 - }
839 - }
840 - }
841 -
842 - /**
843 - * Removes the mapping for this key from this map if it is present
844 - * (optional operation). More formally, if this map contains a mapping
845 - * from key <tt>k</tt> to value <tt>v</tt> such that
846 - * <code>(key==null ? k==null : key.equals(k))</code>, that mapping
847 - * is removed. (The map can contain at most one such mapping.)
848 - * <p/>
849 - * <p>Returns the value to which the map previously associated the key, or
850 - * <tt>null</tt> if the map contained no mapping for this key. (A
851 - * <tt>null</tt> return can also indicate that the map previously
852 - * associated <tt>null</tt> with the specified key if the implementation
853 - * supports <tt>null</tt> values.) The map will not contain a mapping for
854 - * the specified key once the call returns.
855 - *
856 - * @param key key whose mapping is to be removed from the map.
857 - *
858 - * @return previous value associated with specified key, or <tt>null</tt>
859 - * if there was no mapping for key.
860 - *
861 - * @throws ClassCastException if the key is of an inappropriate type for
862 - * this map (optional).
863 - * @throws NullPointerException if the key is <tt>null</tt> and this map
864 - * does not permit <tt>null</tt> keys (optional).
865 - * @throws UnsupportedOperationException if the <tt>remove</tt> method is
866 - * not supported by this map.
867 - */
868 - public Object remove( String key ) {
869 - return privatePut( key, null );
870 - }
871 -
872 - // Bulk Operations
873 -
874 - /**
875 - * Copies all of the mappings from the specified map to this map
876 - * (optional operation). The effect of this call is equivalent to that
877 - * of calling put(k, v) on this map once
878 - * for each mapping from key <tt>k</tt> to value <tt>v</tt> in the
879 - * specified map. The behavior of this operation is unspecified if the
880 - * specified map is modified while the operation is in progress.
881 - *
882 - * @param t Mappings to be stored in this map.
883 - *
884 - * @throws UnsupportedOperationException if the <tt>putAll</tt> method is
885 - * not supported by this map.
886 - * @throws ClassCastException if the class of a key or value in the
887 - * specified map prevents it from being stored in this map.
888 - * @throws IllegalArgumentException some aspect of a key or value in the
889 - * specified map prevents it from being stored in this map.
890 - * @throws NullPointerException if the specified map is <tt>null</tt>, or if
891 - * this map does not permit <tt>null</tt> keys or values, and the
892 - * specified map contains <tt>null</tt> keys or values.
893 - */
894 - public void putAll( ParamMap t ) {
895 - LLputAll( t );
896 - }
897 -
898 - /**
899 - * Removes all mappings from this map (optional operation).
900 - *
901 - * @throws UnsupportedOperationException clear is not supported by this
902 - * map.
903 - */
904 - public void clear() {
905 - invalidateCache();
906 - mProxiedMap.clear();
907 - }
908 -
909 - // Views
910 -
911 - /**
912 - * Returns a collection view of the values contained in this map. The
913 - * collection is NOT backed by the map.
914 - *
915 - * @return a collection view of the values contained in this map.
916 - */
917 - public Collection<Object> values() {
918 - //noinspection unchecked
919 - return new ArrayList<Object>( mProxiedMap.values() );
920 - }
921 -
922 - // Comparison and hashing
923 -
924 - /**
925 - * Compares the specified object with this map for equality. Returns
926 - * <tt>true</tt> if the given object is also a map and the two Maps
927 - * represent the same mappings. More formally, two maps <tt>t1</tt> and
928 - * <tt>t2</tt> represent the same mappings if
929 - * <tt>t1.entrySet().equals(t2.entrySet())</tt>. This ensures that the
930 - * <tt>equals</tt> method works properly across different implementations
931 - * of the <tt>Map</tt> interface.
932 - *
933 - * @param o object to be compared for equality with this map.
934 - *
935 - * @return <tt>true</tt> if the specified object is equal to this map.
936 - */
937 - public boolean equals( Object o ) {
938 - return (this == o) || mProxiedMap.equals( (o instanceof ParamMap) ? ((ParamMap) o).mProxiedMap : o );
939 - }
940 -
941 - /**
942 - * Returns the hash code value for this map. The hash code of a map
943 - * is defined to be the sum of the hashCodes of each entry in the map's
944 - * entrySet view. This ensures that <tt>t1.equals(t2)</tt> implies
945 - * that <tt>t1.hashCode()==t2.hashCode()</tt> for any two maps
946 - * <tt>t1</tt> and <tt>t2</tt>, as required by the general
947 - * contract of Object.hashCode.
948 - *
949 - * @return the hash code value for this map.
950 - *
951 - * @see Object#hashCode()
952 - * @see Object#equals(Object)
953 - * @see #equals(Object)
954 - */
955 - public int hashCode() {
956 - return mProxiedMap.hashCode();
957 - }
958 -
959 - public synchronized String[] keys() {
960 - if ( mKeysAsStringsUnsorted == null ) {
961 - String[] temp = new String[mProxiedMap.size()];
962 - mProxiedMap.keySet().toArray( temp );
963 - mKeysAsStringsUnsorted = temp; // atomic assignment (GWT?)
964 - }
965 - return mKeysAsStringsUnsorted;
966 - }
967 -
968 - public synchronized String[] sortedKeys() {
969 - if ( mKeysAsStringsSorted == null ) {
970 - String[] temp = new String[mProxiedMap.size()];
971 - mProxiedMap.keySet().toArray( temp );
972 - Arrays.sort( temp );
973 - mKeysAsStringsSorted = temp; // atomic assignment (GWT?)
974 - }
975 - return mKeysAsStringsSorted;
976 - }
977 -
978 - public String toString() {
979 - StringBuilder sb = new StringBuilder( "[" );
980 - if ( !isEmpty() ) {
981 - String[] keys = keys();
982 - String zKey = keys[0];
983 - sb.append( zKey ).append( '=' ).append( mProxiedMap.get( zKey ) );
984 - for ( int i = 1; i < keys.length; i++ ) {
985 - zKey = keys[i];
986 - sb.append( ", " ).append( zKey ).append( '=' ).append( mProxiedMap.get( zKey ) );
987 - }
988 - }
989 - return sb.append( ']' ).toString();
990 - }
991 -
992 - // below here for internal use!
993 -
994 - private ParamMap privatePut( String key, Object value ) {
995 - if ( key == null ) {
996 - return null;
997 - }
998 - invalidateCache();
999 - //noinspection unchecked
1000 - if ( (value == null) ) {
1001 - mProxiedMap.remove( key );
1002 - } else {
1003 - mProxiedMap.put( key, value );
1004 - }
1005 - return this;
1006 - }
1007 -
1008 - private void invalidateCache() {
1009 - mKeysAsStringsUnsorted = null;
1010 - mKeysAsStringsSorted = null;
1011 - }
1012 -
1013 - private HashMap<String, Object> mProxiedMap = new HashMap<String, Object>();
1014 -
1015 - private transient String[] mKeysAsStringsUnsorted = null;
1016 - private transient String[] mKeysAsStringsSorted = null;
1017 -
1018 - protected void finalize()
1019 - throws Throwable {
1020 - mProxiedMap.clear();
1021 - super.finalize();
1022 - }
1023 -
1024 - /**
1025 - * Copy all the entries from the ParamMap into the supplied Map (pMap).
1026 - *
1027 - * @param pMap
1028 - *
1029 - * @return pMap
1030 - */
1031 - public Map<Object, Object> putAllInto( Map<Object, Object> pMap ) {
1032 - if ( (pMap != null) && !isEmpty() ) {
1033 - for ( Iterator<String> it = mProxiedMap.keySet().iterator(); it.hasNext(); ) {
1034 - Object zKey = it.next();
1035 - pMap.put( zKey, mProxiedMap.get( zKey ) );
1036 - }
1037 - }
1038 - return pMap;
1039 - }
1040 -
1041 - // todo: Eliminate
1042 - private Object LLgetRawValue( String pKey ) {
1043 - return mProxiedMap.get( pKey );
1044 - }
1045 -
1046 - public static final class BackDoor {
1047 - public static Object getRawValue( ParamMap pParamMap, String pKey ) {
1048 - return pParamMap.LLgetRawValue( pKey );
1049 - }
1050 - }
1051 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.eventbus.client;
3 +
4 + import java.io.*;
5 + import java.util.*;
6 +
7 + public class ParamMap implements Serializable {
8 + public static final ParamMap LOCKED_EMPTY = new ImmutableParamMap();
9 +
10 + public static ParamMap immutableCopy( ParamMap paramMap ) {
11 + return (paramMap != null) ? paramMap.immutableCopy() : null;
12 + }
13 +
14 + public ParamMap immutableCopy() {
15 + return new ImmutableParamMap( this );
16 + }
17 +
18 + // Native boolean
19 + public ParamMap add( String key, boolean value ) {
20 + return privatePut( key, Boolean.valueOf( value ) );
21 + }
22 +
23 + public ParamMap add( String key, boolean[] value ) {
24 + return privatePut( key, value );
25 + }
26 +
27 + public boolean get_boolean( String pKey, boolean pDefault ) {
28 + return get_booleanFrom( this, pKey, pDefault );
29 + }
30 +
31 + public static boolean get_booleanFrom( ParamMap pMap, String pKey, boolean pDefault ) {
32 + Boolean value = getBooleanFrom( pMap, pKey );
33 + //noinspection UnnecessaryUnboxing
34 + return value != null ? value.booleanValue() : pDefault;
35 + }
36 +
37 + public boolean[] get_booleanArray( String pKey ) {
38 + return get_booleanArrayFrom( this, pKey );
39 + }
40 +
41 + public boolean[] get_booleanArray( String pKey, boolean[] pDefault ) {
42 + return get_booleanArrayFrom( this, pKey, pDefault );
43 + }
44 +
45 + public static boolean[] get_booleanArrayFrom( ParamMap pMap, String pKey, boolean[] pDefault ) {
46 + boolean[] value = get_booleanArrayFrom( pMap, pKey );
47 + //noinspection UnnecessaryUnboxing
48 + return value != null ? value : pDefault;
49 + }
50 +
51 + public static boolean[] get_booleanArrayFrom( ParamMap pMap, String pKey ) {
52 + return (boolean[]) getFrom( pMap, pKey );
53 + }
54 +
55 + // Boolean
56 + public ParamMap add( String key, Boolean value ) {
57 + return privatePut( key, value );
58 + }
59 +
60 + public ParamMap add( String key, Boolean[] value ) {
61 + return privatePut( key, value );
62 + }
63 +
64 + public Boolean getBoolean( String pKey ) {
65 + return getBoolean( pKey, null );
66 + }
67 +
68 + public Boolean getBoolean( String pKey, Boolean pDefault ) {
69 + return getBooleanFrom( this, pKey, pDefault );
70 + }
71 +
72 + public static Boolean getBooleanFrom( ParamMap pMap, String pKey, Boolean pDefault ) {
73 + Boolean value = getBooleanFrom( pMap, pKey );
74 + return (value != null) ? value : pDefault;
75 + }
76 +
77 + public static Boolean getBooleanFrom( ParamMap pMap, String pKey ) {
78 + Object value = getFrom( pMap, pKey );
79 + if ( value == null ) {
80 + return null;
81 + }
82 + if ( value instanceof Boolean ) {
83 + return (Boolean) value;
84 + }
85 + return Boolean.valueOf( value.toString() );
86 + }
87 +
88 + public Boolean[] getBooleanArray( String pKey ) {
89 + return getBooleanArrayFrom( this, pKey );
90 + }
91 +
92 + public Boolean[] getBooleanArray( String pKey, Boolean[] pDefault ) {
93 + return getBooleanArrayFrom( this, pKey, pDefault );
94 + }
95 +
96 + public static Boolean[] getBooleanArrayFrom( ParamMap pMap, String pKey, Boolean[] pDefault ) {
97 + Boolean[] value = getBooleanArrayFrom( pMap, pKey );
98 + return (value != null) ? value : pDefault;
99 + }
100 +
101 + public static Boolean[] getBooleanArrayFrom( ParamMap pMap, String pKey ) {
102 + return (Boolean[]) getFrom( pMap, pKey );
103 + }
104 +
105 + // Date
106 + public ParamMap add( String key, Date value ) {
107 + return privatePut( key, value );
108 + }
109 +
110 + public ParamMap add( String key, Date[] value ) {
111 + return privatePut( key, value );
112 + }
113 +
114 + public Date getDate( String pKey ) {
115 + return getDate( pKey, null );
116 + }
117 +
118 + public Date getDate( String pKey, Date pDefault ) {
119 + return getDateFrom( this, pKey, pDefault );
120 + }
121 +
122 + public static Date getDateFrom( ParamMap pMap, String pKey ) {
123 + return (Date) getFrom( pMap, pKey );
124 + }
125 +
126 + public static Date getDateFrom( ParamMap pMap, String pKey, Date pDefault ) {
127 + Date value = getDateFrom( pMap, pKey );
128 + return (value != null) ? value : pDefault;
129 + }
130 +
131 + public Date[] getDateArray( String pKey ) {
132 + return getDateArrayFrom( this, pKey );
133 + }
134 +
135 + public Date[] getDateArray( String pKey, Date[] pDefault ) {
136 + return getDateArrayFrom( this, pKey, pDefault );
137 + }
138 +
139 + public static Date[] getDateArrayFrom( ParamMap pMap, String pKey, Date[] pDefault ) {
140 + Date[] value = getDateArrayFrom( pMap, pKey );
141 + return (value != null) ? value : pDefault;
142 + }
143 +
144 + public static Date[] getDateArrayFrom( ParamMap pMap, String pKey ) {
145 + return (Date[]) getFrom( pMap, pKey );
146 + }
147 +
148 + // Native double
149 + public ParamMap add( String key, double value ) {
150 + return privatePut( key, new Double( value ) );
151 + }
152 +
153 + public ParamMap add( String key, double[] value ) {
154 + return privatePut( key, value );
155 + }
156 +
157 + public double get_double( String pKey, double pDefault ) {
158 + return get_doubleFrom( this, pKey, pDefault );
159 + }
160 +
161 + public static double get_doubleFrom( ParamMap pMap, String pKey, double pDefault ) {
162 + Double value = getDoubleFrom( pMap, pKey );
163 + //noinspection UnnecessaryUnboxing
164 + return value != null ? value.doubleValue() : pDefault;
165 + }
166 +
167 + public double[] get_doubleArray( String pKey ) {
168 + return get_doubleArrayFrom( this, pKey );
169 + }
170 +
171 + public double[] get_doubleArray( String pKey, double[] pDefault ) {
172 + return get_doubleArrayFrom( this, pKey, pDefault );
173 + }
174 +
175 + public static double[] get_doubleArrayFrom( ParamMap pMap, String pKey, double[] pDefault ) {
176 + double[] value = get_doubleArrayFrom( pMap, pKey );
177 + return value != null ? value : pDefault;
178 + }
179 +
180 + public static double[] get_doubleArrayFrom( ParamMap pMap, String pKey ) {
181 + return (double[]) getFrom( pMap, pKey );
182 + }
183 +
184 + // Double
185 + public ParamMap add( String key, Double value ) {
186 + return privatePut( key, value );
187 + }
188 +
189 + public ParamMap add( String key, Double[] value ) {
190 + return privatePut( key, value );
191 + }
192 +
193 + public Double getDouble( String pKey ) {
194 + return getDouble( pKey, null );
195 + }
196 +
197 + public Double getDouble( String pKey, Double pDefault ) {
198 + return getDoubleFrom( this, pKey, pDefault );
199 + }
200 +
201 + public static Double getDoubleFrom( ParamMap pMap, String pKey, Double pDefault ) {
202 + Double value = getDoubleFrom( pMap, pKey );
203 + return (value != null) ? value : pDefault;
204 + }
205 +
206 + public static Double getDoubleFrom( ParamMap pMap, String pKey ) {
207 + Object value = getFrom( pMap, pKey );
208 + if ( value == null ) {
209 + return null;
210 + }
211 + if ( value instanceof Double ) {
212 + return (Double) value;
213 + }
214 + if ( value instanceof Number ) {
215 + //noinspection UnnecessaryBoxing
216 + return new Double( ((Number) value).doubleValue() );
217 + }
218 + return new Double( value.toString() );
219 + }
220 +
221 + public Double[] getDoubleArray( String pKey ) {
222 + return getDoubleArrayFrom( this, pKey );
223 + }
224 +
225 + public Double[] getDoubleArray( String pKey, Double[] pDefault ) {
226 + return getDoubleArrayFrom( this, pKey, pDefault );
227 + }
228 +
229 + public static Double[] getDoubleArrayFrom( ParamMap pMap, String pKey, Double[] pDefault ) {
230 + Double[] value = getDoubleArrayFrom( pMap, pKey );
231 + return (value != null) ? value : pDefault;
232 + }
233 +
234 + public static Double[] getDoubleArrayFrom( ParamMap pMap, String pKey ) {
235 + return (Double[]) getFrom( pMap, pKey );
236 + }
237 +
238 + // Native float
239 + public ParamMap add( String key, float value ) {
240 + return privatePut( key, new Float( value ) );
241 + }
242 +
243 + public ParamMap add( String key, float[] value ) {
244 + return privatePut( key, value );
245 + }
246 +
247 + public float get_float( String pKey, float pDefault ) {
248 + return get_floatFrom( this, pKey, pDefault );
249 + }
250 +
251 + public static float get_floatFrom( ParamMap pMap, String pKey, float pDefault ) {
252 + Float value = getFloatFrom( pMap, pKey );
253 + //noinspection UnnecessaryUnboxing
254 + return value != null ? value.floatValue() : pDefault;
255 + }
256 +
257 + public float[] get_floatArray( String pKey ) {
258 + return get_floatArrayFrom( this, pKey );
259 + }
260 +
261 + public float[] get_floatArray( String pKey, float[] pDefault ) {
262 + return get_floatArrayFrom( this, pKey, pDefault );
263 + }
264 +
265 + public static float[] get_floatArrayFrom( ParamMap pMap, String pKey, float[] pDefault ) {
266 + float[] value = get_floatArrayFrom( pMap, pKey );
267 + return value != null ? value : pDefault;
268 + }
269 +
270 + public static float[] get_floatArrayFrom( ParamMap pMap, String pKey ) {
271 + return (float[]) getFrom( pMap, pKey );
272 + }
273 +
274 + // Float
275 + public ParamMap add( String key, Float value ) {
276 + return privatePut( key, value );
277 + }
278 +
279 + public ParamMap add( String key, Float[] value ) {
280 + return privatePut( key, value );
281 + }
282 +
283 + public Float getFloat( String pKey ) {
284 + return getFloat( pKey, null );
285 + }
286 +
287 + public Float getFloat( String pKey, Float pDefault ) {
288 + return getFloatFrom( this, pKey, pDefault );
289 + }
290 +
291 + public static Float getFloatFrom( ParamMap pMap, String pKey, Float pDefault ) {
292 + Float value = getFloatFrom( pMap, pKey );
293 + return (value != null) ? value : pDefault;
294 + }
295 +
296 + public static Float getFloatFrom( ParamMap pMap, String pKey ) {
297 + Object value = getFrom( pMap, pKey );
298 + if ( value == null ) {
299 + return null;
300 + }
301 + if ( value instanceof Float ) {
302 + return (Float) value;
303 + }
304 + if ( value instanceof Number ) {
305 + //noinspection UnnecessaryBoxing
306 + return new Float( ((Number) value).floatValue() );
307 + }
308 + return new Float( value.toString() );
309 + }
310 +
311 + public Float[] getFloatArray( String pKey ) {
312 + return getFloatArrayFrom( this, pKey );
313 + }
314 +
315 + public Float[] getFloatArray( String pKey, Float[] pDefault ) {
316 + return getFloatArrayFrom( this, pKey, pDefault );
317 + }
318 +
319 + public static Float[] getFloatArrayFrom( ParamMap pMap, String pKey, Float[] pDefault ) {
320 + Float[] value = getFloatArrayFrom( pMap, pKey );
321 + return (value != null) ? value : pDefault;
322 + }
323 +
324 + public static Float[] getFloatArrayFrom( ParamMap pMap, String pKey ) {
325 + return (Float[]) getFrom( pMap, pKey );
326 + }
327 +
328 + // Native int
329 + public ParamMap add( String key, int value ) {
330 + return privatePut( key, new Integer( value ) );
331 + }
332 +
333 + public ParamMap add( String key, int[] value ) {
334 + return privatePut( key, value );
335 + }
336 +
337 + public int get_int( String pKey, int pDefault ) {
338 + return get_intFrom( this, pKey, pDefault );
339 + }
340 +
341 + public static int get_intFrom( ParamMap pMap, String pKey, int pDefault ) {
342 + Integer value = getIntegerFrom( pMap, pKey );
343 + //noinspection UnnecessaryUnboxing
344 + return value != null ? value.intValue() : pDefault;
345 + }
346 +
347 + public int[] get_intArray( String pKey ) {
348 + return get_intArrayFrom( this, pKey );
349 + }
350 +
351 + public int[] get_intArray( String pKey, int[] pDefault ) {
352 + return get_intArrayFrom( this, pKey, pDefault );
353 + }
354 +
355 + public static int[] get_intArrayFrom( ParamMap pMap, String pKey, int[] pDefault ) {
356 + int[] value = get_intArrayFrom( pMap, pKey );
357 + return value != null ? value : pDefault;
358 + }
359 +
360 + public static int[] get_intArrayFrom( ParamMap pMap, String pKey ) {
361 + return (int[]) getFrom( pMap, pKey );
362 + }
363 +
364 + // Integer
365 + public ParamMap add( String key, Integer value ) {
366 + return privatePut( key, value );
367 + }
368 +
369 + public ParamMap add( String key, Integer[] value ) {
370 + return privatePut( key, value );
371 + }
372 +
373 + public Integer getInteger( String pKey ) {
374 + return getInteger( pKey, null );
375 + }
376 +
377 + public Integer getInteger( String pKey, Integer pDefault ) {
378 + return getIntegerFrom( this, pKey, pDefault );
379 + }
380 +
381 + public static Integer getIntegerFrom( ParamMap pMap, String pKey, Integer pDefault ) {
382 + Integer value = getIntegerFrom( pMap, pKey );
383 + return (value != null) ? value : pDefault;
384 + }
385 +
386 + public static Integer getIntegerFrom( ParamMap pMap, String pKey ) {
387 + Object value = getFrom( pMap, pKey );
388 + if ( value == null ) {
389 + return null;
390 + }
391 + if ( value instanceof Integer ) {
392 + return (Integer) value;
393 + }
394 + if ( value instanceof Number ) {
395 + //noinspection UnnecessaryBoxing
396 + return new Integer( ((Number) value).intValue() );
397 + }
398 + return new Integer( value.toString() );
399 + }
400 +
401 + public Integer[] getIntegerArray( String pKey ) {
402 + return getIntegerArrayFrom( this, pKey );
403 + }
404 +
405 + public Integer[] getIntegerArray( String pKey, Integer[] pDefault ) {
406 + return getIntegerArrayFrom( this, pKey, pDefault );
407 + }
408 +
409 + public static Integer[] getIntegerArrayFrom( ParamMap pMap, String pKey, Integer[] pDefault ) {
410 + Integer[] value = getIntegerArrayFrom( pMap, pKey );
411 + return (value != null) ? value : pDefault;
412 + }
413 +
414 + public static Integer[] getIntegerArrayFrom( ParamMap pMap, String pKey ) {
415 + return (Integer[]) getFrom( pMap, pKey );
416 + }
417 +
418 + // Native long
419 + public ParamMap add( String key, long value ) {
420 + return privatePut( key, new Long( value ) );
421 + }
422 +
423 + public ParamMap add( String key, long[] value ) {
424 + return privatePut( key, value );
425 + }
426 +
427 + public long get_long( String pKey, long pDefault ) {
428 + return get_longFrom( this, pKey, pDefault );
429 + }
430 +
431 + public static long get_longFrom( ParamMap pMap, String pKey, long pDefault ) {
432 + Long value = getLongFrom( pMap, pKey );
433 + //noinspection UnnecessaryUnboxing
434 + return value != null ? value.longValue() : pDefault;
435 + }
436 +
437 + public long[] get_longArray( String pKey, long[] pDefault ) {
438 + return get_longArrayFrom( this, pKey, pDefault );
439 + }
440 +
441 + public static long[] get_longArrayFrom( ParamMap pMap, String pKey, long[] pDefault ) {
442 + long[] value = get_longArrayFrom( pMap, pKey );
443 + return value != null ? value : pDefault;
444 + }
445 +
446 + public static long[] get_longArrayFrom( ParamMap pMap, String pKey ) {
447 + return (long[]) getFrom( pMap, pKey );
448 + }
449 +
450 + // Long
451 + public ParamMap add( String key, Long value ) {
452 + return privatePut( key, value );
453 + }
454 +
455 + public ParamMap add( String key, Long[] value ) {
456 + return privatePut( key, value );
457 + }
458 +
459 + public Long getLong( String pKey ) {
460 + return getLong( pKey, null );
461 + }
462 +
463 + public Long getLong( String pKey, Long pDefault ) {
464 + return getLongFrom( this, pKey, pDefault );
465 + }
466 +
467 + public static Long getLongFrom( ParamMap pMap, String pKey, Long pDefault ) {
468 + Long value = getLongFrom( pMap, pKey );
469 + return (value != null) ? value : pDefault;
470 + }
471 +
472 + public static Long getLongFrom( ParamMap pMap, String pKey ) {
473 + Object value = getFrom( pMap, pKey );
474 + if ( value == null ) {
475 + return null;
476 + }
477 + if ( value instanceof Long ) {
478 + return (Long) value;
479 + }
480 + if ( value instanceof Number ) {
481 + //noinspection UnnecessaryBoxing
482 + return new Long( ((Number) value).longValue() );
483 + }
484 + return new Long( value.toString() );
485 + }
486 +
487 + public Long[] getLongArray( String pKey ) {
488 + return getLongArrayFrom( this, pKey );
489 + }
490 +
491 + public Long[] getLongArray( String pKey, Long[] pDefault ) {
492 + return getLongArrayFrom( this, pKey, pDefault );
493 + }
494 +
495 + public static Long[] getLongArrayFrom( ParamMap pMap, String pKey, Long[] pDefault ) {
496 + Long[] value = getLongArrayFrom( pMap, pKey );
497 + return (value != null) ? value : pDefault;
498 + }
499 +
500 + public static Long[] getLongArrayFrom( ParamMap pMap, String pKey ) {
501 + return (Long[]) getFrom( pMap, pKey );
502 + }
503 +
504 + // Native short
505 + public ParamMap add( String key, short value ) {
506 + return privatePut( key, new Short( value ) );
507 + }
508 +
509 + public ParamMap add( String key, Short[] value ) {
510 + return privatePut( key, value );
511 + }
512 +
513 + public short get_short( String pKey, short pDefault ) {
514 + return get_shortFrom( this, pKey, pDefault );
515 + }
516 +
517 + public static short get_shortFrom( ParamMap pMap, String pKey, short pDefault ) {
518 + Short value = getShortFrom( pMap, pKey );
519 + //noinspection UnnecessaryUnboxing
520 + return value != null ? value.shortValue() : pDefault;
521 + }
522 +
523 + public short[] get_shortArray( String pKey ) {
524 + return get_shortArrayFrom( this, pKey );
525 + }
526 +
527 + public short[] get_shortArray( String pKey, short[] pDefault ) {
528 + return get_shortArrayFrom( this, pKey, pDefault );
529 + }
530 +
531 + public static short[] get_shortArrayFrom( ParamMap pMap, String pKey, short[] pDefault ) {
532 + short[] value = get_shortArrayFrom( pMap, pKey );
533 + return value != null ? value : pDefault;
534 + }
535 +
536 + public static short[] get_shortArrayFrom( ParamMap pMap, String pKey ) {
537 + return (short[]) getFrom( pMap, pKey );
538 + }
539 +
540 + // Short
541 + public ParamMap add( String key, Short value ) {
542 + return privatePut( key, value );
543 + }
544 +
545 + public ParamMap add( String key, short[] value ) {
546 + return privatePut( key, value );
547 + }
548 +
549 + public Short getShort( String pKey ) {
550 + return getShort( pKey, null );
551 + }
552 +
553 + public Short getShort( String pKey, Short pDefault ) {
554 + return getShortFrom( this, pKey, pDefault );
555 + }
556 +
557 + public static Short getShortFrom( ParamMap pMap, String pKey, Short pDefault ) {
558 + Short value = getShortFrom( pMap, pKey );
559 + return (value != null) ? value : pDefault;
560 + }
561 +
562 + public static Short getShortFrom( ParamMap pMap, String pKey ) {
563 + Object value = getFrom( pMap, pKey );
564 + if ( value == null ) {
565 + return null;
566 + }
567 + if ( value instanceof Short ) {
568 + return (Short) value;
569 + }
570 + if ( value instanceof Number ) {
571 + //noinspection UnnecessaryBoxing
572 + return new Short( ((Number) value).shortValue() );
573 + }
574 + return new Short( value.toString() );
575 + }
576 +
577 + public Short[] getShortArray( String pKey ) {
578 + return getShortArrayFrom( this, pKey );
579 + }
580 +
581 + public Short[] getShortArray( String pKey, Short[] pDefault ) {
582 + return getShortArrayFrom( this, pKey, pDefault );
583 + }
584 +
585 + public static Short[] getShortArrayFrom( ParamMap pMap, String pKey, Short[] pDefault ) {
586 + Short[] value = getShortArrayFrom( pMap, pKey );
587 + return (value != null) ? value : pDefault;
588 + }
589 +
590 + public static Short[] getShortArrayFrom( ParamMap pMap, String pKey ) {
591 + return (Short[]) getFrom( pMap, pKey );
592 + }
593 +
594 + // String
595 + public ParamMap add( String key, String value ) {
596 + return privatePut( key, value );
597 + }
598 +
599 + public ParamMap add( String key, String[] value ) {
600 + return privatePut( key, value );
601 + }
602 +
603 + public String getString( String pKey ) {
604 + return getString( pKey, null );
605 + }
606 +
607 + public String getString( String pKey, String pDefault ) {
608 + return getStringFrom( this, pKey, pDefault );
609 + }
610 +
611 + public static String getStringFrom( ParamMap pMap, String pKey ) {
612 + Object value = getFrom( pMap, pKey );
613 + return (value == null) ? null : (String) value;
614 + }
615 +
616 + public static String getStringFrom( ParamMap pMap, String pKey, String pDefault ) {
617 + String value = getStringFrom( pMap, pKey );
618 + return (value != null) ? value : pDefault;
619 + }
620 +
621 + public String[] getStringArray( String pKey ) {
622 + return getStringArrayFrom( this, pKey );
623 + }
624 +
625 + public String[] getStringArray( String pKey, String[] pDefault ) {
626 + return getStringArrayFrom( this, pKey, pDefault );
627 + }
628 +
629 + public static String[] getStringArrayFrom( ParamMap pMap, String pKey, String[] pDefault ) {
630 + String[] value = getStringArrayFrom( pMap, pKey );
631 + return (value != null) ? value : pDefault;
632 + }
633 +
634 + public static String[] getStringArrayFrom( ParamMap pMap, String pKey ) {
635 + return (String[]) getFrom( pMap, pKey );
636 + }
637 +
638 + // ParamMap
639 + public ParamMap add( String key, ParamMap value ) {
640 + return privatePut( key, value );
641 + }
642 +
643 + public ParamMap add( String key, ParamMap[] value ) {
644 + return privatePut( key, value );
645 + }
646 +
647 + public ParamMap getParamMap( String pKey ) {
648 + return getParamMap( pKey, null );
649 + }
650 +
651 + public ParamMap getParamMap( String pKey, ParamMap pDefault ) {
652 + return getParamMapFrom( this, pKey, pDefault );
653 + }
654 +
655 + public static ParamMap getParamMapFrom( ParamMap pMap, String pKey ) {
656 + Object value = getFrom( pMap, pKey );
657 + return (value == null) ? null : (ParamMap) value;
658 + }
659 +
660 + public static ParamMap getParamMapFrom( ParamMap pMap, String pKey, ParamMap pDefault ) {
661 + ParamMap value = getParamMapFrom( pMap, pKey );
662 + return (value != null) ? value : pDefault;
663 + }
664 +
665 + public ParamMap[] getParamMapArray( String pKey ) {
666 + return getParamMapArrayFrom( this, pKey );
667 + }
668 +
669 + public ParamMap[] getParamMapArray( String pKey, ParamMap[] pDefault ) {
670 + return getParamMapArrayFrom( this, pKey, pDefault );
671 + }
672 +
673 + public static ParamMap[] getParamMapArrayFrom( ParamMap pMap, String pKey, ParamMap[] pDefault ) {
674 + ParamMap[] value = getParamMapArrayFrom( pMap, pKey );
675 + return (value != null) ? value : pDefault;
676 + }
677 +
678 + public static ParamMap[] getParamMapArrayFrom( ParamMap pMap, String pKey ) {
679 + return (ParamMap[]) getFrom( pMap, pKey );
680 + }
681 +
682 + // Serializable
683 + public ParamMap add( String key, Serializable value ) {
684 + return privatePut( key, value );
685 + }
686 +
687 + public ParamMap add( String key, Serializable[] value ) {
688 + return privatePut( key, value );
689 + }
690 +
691 + public Serializable getSerializable( String pKey ) {
692 + return getSerializable( pKey, null );
693 + }
694 +
695 + public Serializable getSerializable( String pKey, Serializable pDefault ) {
696 + return getSerializableFrom( this, pKey, pDefault );
697 + }
698 +
699 + public static Serializable getSerializableFrom( ParamMap pMap, String pKey, Serializable pDefault ) {
700 + Serializable value = getSerializableFrom( pMap, pKey );
701 + return (value != null) ? value : pDefault;
702 + }
703 +
704 + public static Serializable getSerializableFrom( ParamMap pMap, String pKey ) {
705 + Object value = getFrom( pMap, pKey );
706 + if ( value == null ) {
707 + return null;
708 + }
709 + return (Serializable) value;
710 + }
711 +
712 + public Serializable[] getSerializableArray( String pKey ) {
713 + return getSerializableArrayFrom( this, pKey );
714 + }
715 +
716 + public Serializable[] getSerializableArray( String pKey, Serializable[] pDefault ) {
717 + return getSerializableArrayFrom( this, pKey, pDefault );
718 + }
719 +
720 + public static Serializable[] getSerializableArrayFrom( ParamMap pMap, String pKey, Serializable[] pDefault ) {
721 + Serializable[] value = getSerializableArrayFrom( pMap, pKey );
722 + return (value != null) ? value : pDefault;
723 + }
724 +
725 + public static Serializable[] getSerializableArrayFrom( ParamMap pMap, String pKey ) {
726 + return (Serializable[]) getFrom( pMap, pKey );
727 + }
728 +
729 + // Object
730 + private static Object getFrom( ParamMap pMap, String pKey ) {
731 + return (pMap == null) ? null : pMap.mProxiedMap.get( pKey );
732 + }
733 +
734 + public ParamMap() {
735 + }
736 +
737 + public ParamMap( ParamMap pMap ) {
738 + LLputAll( pMap );
739 + }
740 +
741 + public ParamMap( String[] pNameValuePairs ) {
742 + if ( pNameValuePairs != null ) {
743 + if ( (pNameValuePairs.length & 1) == 1 ) {
744 + throw new IllegalArgumentException( "NameValuePairs not paired" );
745 + }
746 + for ( int i = 0; i < pNameValuePairs.length; ) {
747 + String name = pNameValuePairs[i++];
748 + String value = pNameValuePairs[i++];
749 + add( name, value );
750 + }
751 + }
752 + }
753 +
754 + private void LLputAll( ParamMap t ) {
755 + if ( t != null ) {
756 + invalidateCache();
757 + mProxiedMap.putAll( t.mProxiedMap );
758 + }
759 + }
760 +
761 + /**
762 + * Returns the number of key-value mappings in this map. If the
763 + * map contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
764 + * <tt>Integer.MAX_VALUE</tt>.
765 + *
766 + * @return the number of key-value mappings in this map (or <tt>Integer.MAX_VALUE</tt>).
767 + */
768 + public int size() {
769 + return mProxiedMap.size();
770 + }
771 +
772 + /**
773 + * Returns <tt>true</tt> if this map contains no key-value mappings.
774 + *
775 + * @return <tt>true</tt> if this map contains no key-value mappings.
776 + */
777 + public boolean isEmpty() {
778 + return mProxiedMap.isEmpty();
779 + }
780 +
781 + /**
782 + * Returns <tt>true</tt> if this map contains a mapping for the specified
783 + * key. More formally, returns <tt>true</tt> if and only if
784 + * this map contains a mapping for a key <tt>k</tt> such that
785 + * <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
786 + * at most one such mapping.)
787 + *
788 + * @param key key whose presence in this map is to be tested.
789 + *
790 + * @return <tt>true</tt> if this map contains a mapping for the specified
791 + * key.
792 + *
793 + * @throws ClassCastException if the key is of an inappropriate type for
794 + * this map (optional).
795 + * @throws NullPointerException if the key is <tt>null</tt> and this map
796 + * does not permit <tt>null</tt> keys (optional).
797 + */
798 + public boolean containsKey( String key ) {
799 + return mProxiedMap.containsKey( key );
800 + }
801 +
802 + // todo: ==============================================================================================//
803 +
804 + // todo: Eliminate
805 + public <T> List<T> get_RawList_ThisMethodShouldNotEverEverBeUsed( String pKey ) {
806 + return (List<T>) getFrom( this, pKey );
807 + }
808 +
809 + // todo: Eliminate
810 + public <T> Set<T> get_RawSet_ThisMethodShouldNotEverEverBeUsed( String pKey ) {
811 + return (Set<T>) getFrom( this, pKey );
812 + }
813 +
814 + // todo: Eliminate
815 + public ParamMap add_RawMap_ThisMethodShouldNotEverEverBeUsed( String key, Map value ) {
816 + return privatePut( key, value );
817 + }
818 +
819 + // todo: Eliminate
820 + public ParamMap add_RawSet_ThisMethodShouldNotEverEverBeUsed( String key, Set value ) {
821 + return privatePut( key, value );
822 + }
823 +
824 + // todo: Eliminate
825 + public ParamMap add_RawList_ThisMethodShouldNotEverEverBeUsed( String key, List value ) {
826 + return privatePut( key, value );
827 + }
828 +
829 + // todo: Eliminate
830 + public void putAll_RawObjects_ThisMethodShouldNotEverEverBeUsed( Map<?, ?> t ) {
831 + if ( t != null ) {
832 + //noinspection ForLoopReplaceableByForEach
833 + for ( Iterator<?> it = t.keySet().iterator(); it.hasNext(); ) {
834 + Object key = it.next();
835 + if ( key instanceof String ) {
836 + privatePut( key.toString(), t.get( key ) );
837 + }
838 + }
839 + }
840 + }
841 +
842 + /**
843 + * Removes the mapping for this key from this map if it is present
844 + * (optional operation). More formally, if this map contains a mapping
845 + * from key <tt>k</tt> to value <tt>v</tt> such that
846 + * <code>(key==null ? k==null : key.equals(k))</code>, that mapping
847 + * is removed. (The map can contain at most one such mapping.)
848 + * <p/>
849 + * <p>Returns the value to which the map previously associated the key, or
850 + * <tt>null</tt> if the map contained no mapping for this key. (A
851 + * <tt>null</tt> return can also indicate that the map previously
852 + * associated <tt>null</tt> with the specified key if the implementation
853 + * supports <tt>null</tt> values.) The map will not contain a mapping for
854 + * the specified key once the call returns.
855 + *
856 + * @param key key whose mapping is to be removed from the map.
857 + *
858 + * @return previous value associated with specified key, or <tt>null</tt>
859 + * if there was no mapping for key.
860 + *
861 + * @throws ClassCastException if the key is of an inappropriate type for
862 + * this map (optional).
863 + * @throws NullPointerException if the key is <tt>null</tt> and this map
864 + * does not permit <tt>null</tt> keys (optional).
865 + * @throws UnsupportedOperationException if the <tt>remove</tt> method is
866 + * not supported by this map.
867 + */
868 + public Object remove( String key ) {
869 + return privatePut( key, null );
870 + }
871 +
872 + // Bulk Operations
873 +
874 + /**
875 + * Copies all of the mappings from the specified map to this map
876 + * (optional operation). The effect of this call is equivalent to that
877 + * of calling put(k, v) on this map once
878 + * for each mapping from key <tt>k</tt> to value <tt>v</tt> in the
879 + * specified map. The behavior of this operation is unspecified if the
880 + * specified map is modified while the operation is in progress.
881 + *
882 + * @param t Mappings to be stored in this map.
883 + *
884 + * @throws UnsupportedOperationException if the <tt>putAll</tt> method is
885 + * not supported by this map.
886 + * @throws ClassCastException if the class of a key or value in the
887 + * specified map prevents it from being stored in this map.
888 + * @throws IllegalArgumentException some aspect of a key or value in the
889 + * specified map prevents it from being stored in this map.
890 + * @throws NullPointerException if the specified map is <tt>null</tt>, or if
891 + * this map does not permit <tt>null</tt> keys or values, and the
892 + * specified map contains <tt>null</tt> keys or values.
893 + */
894 + public void putAll( ParamMap t ) {
895 + LLputAll( t );
896 + }
897 +
898 + /**
899 + * Removes all mappings from this map (optional operation).
900 + *
901 + * @throws UnsupportedOperationException clear is not supported by this
902 + * map.
903 + */
904 + public void clear() {
905 + invalidateCache();
906 + mProxiedMap.clear();
907 + }
908 +
909 + // Views
910 +
911 + /**
912 + * Returns a collection view of the values contained in this map. The
913 + * collection is NOT backed by the map.
914 + *
915 + * @return a collection view of the values contained in this map.
916 + */
917 + public Collection<Object> values() {
918 + //noinspection unchecked
919 + return new ArrayList<Object>( mProxiedMap.values() );
920 + }
921 +
922 + // Comparison and hashing
923 +
924 + /**
925 + * Compares the specified object with this map for equality. Returns
926 + * <tt>true</tt> if the given object is also a map and the two Maps
927 + * represent the same mappings. More formally, two maps <tt>t1</tt> and
928 + * <tt>t2</tt> represent the same mappings if
929 + * <tt>t1.entrySet().equals(t2.entrySet())</tt>. This ensures that the
930 + * <tt>equals</tt> method works properly across different implementations
931 + * of the <tt>Map</tt> interface.
932 + *
933 + * @param o object to be compared for equality with this map.
934 + *
935 + * @return <tt>true</tt> if the specified object is equal to this map.
936 + */
937 + public boolean equals( Object o ) {
938 + return (this == o) || mProxiedMap.equals( (o instanceof ParamMap) ? ((ParamMap) o).mProxiedMap : o );
939 + }
940 +
941 + /**
942 + * Returns the hash code value for this map. The hash code of a map
943 + * is defined to be the sum of the hashCodes of each entry in the map's
944 + * entrySet view. This ensures that <tt>t1.equals(t2)</tt> implies
945 + * that <tt>t1.hashCode()==t2.hashCode()</tt> for any two maps
946 + * <tt>t1</tt> and <tt>t2</tt>, as required by the general
947 + * contract of Object.hashCode.
948 + *
949 + * @return the hash code value for this map.
950 + *
951 + * @see Object#hashCode()
952 + * @see Object#equals(Object)
953 + * @see #equals(Object)
954 + */
955 + public int hashCode() {
956 + return mProxiedMap.hashCode();
957 + }
958 +
959 + public synchronized String[] keys() {
960 + if ( mKeysAsStringsUnsorted == null ) {
961 + String[] temp = new String[mProxiedMap.size()];
962 + mProxiedMap.keySet().toArray( temp );
963 + mKeysAsStringsUnsorted = temp; // atomic assignment (GWT?)
964 + }
965 + return mKeysAsStringsUnsorted;
966 + }
967 +
968 + public synchronized String[] sortedKeys() {
969 + if ( mKeysAsStringsSorted == null ) {
970 + String[] temp = new String[mProxiedMap.size()];
971 + mProxiedMap.keySet().toArray( temp );
972 + Arrays.sort( temp );
973 + mKeysAsStringsSorted = temp; // atomic assignment (GWT?)
974 + }
975 + return mKeysAsStringsSorted;
976 + }
977 +
978 + public String toString() {
979 + StringBuilder sb = new StringBuilder( "[" );
980 + if ( !isEmpty() ) {
981 + String[] keys = keys();
982 + String zKey = keys[0];
983 + sb.append( zKey ).append( '=' ).append( mProxiedMap.get( zKey ) );
984 + for ( int i = 1; i < keys.length; i++ ) {
985 + zKey = keys[i];
986 + sb.append( ", " ).append( zKey ).append( '=' ).append( mProxiedMap.get( zKey ) );
987 + }
988 + }
989 + return sb.append( ']' ).toString();
990 + }
991 +
992 + // below here for internal use!
993 +
994 + private ParamMap privatePut( String key, Object value ) {
995 + if ( key == null ) {
996 + return null;
997 + }
998 + invalidateCache();
999 + //noinspection unchecked
1000 + if ( (value == null) ) {
1001 + mProxiedMap.remove( key );
1002 + } else {
1003 + mProxiedMap.put( key, value );
1004 + }
1005 + return this;
1006 + }
1007 +
1008 + private void invalidateCache() {
1009 + mKeysAsStringsUnsorted = null;
1010 + mKeysAsStringsSorted = null;
1011 + }
1012 +
1013 + private HashMap<String, Object> mProxiedMap = new HashMap<String, Object>();
1014 +
1015 + private transient String[] mKeysAsStringsUnsorted = null;
1016 + private transient String[] mKeysAsStringsSorted = null;
1017 +
1018 + protected void finalize()
1019 + throws Throwable {
1020 + mProxiedMap.clear();
1021 + super.finalize();
1022 + }
1023 +
1024 + /**
1025 + * Copy all the entries from the ParamMap into the supplied Map (pMap).
1026 + *
1027 + * @param pMap
1028 + *
1029 + * @return pMap
1030 + */
1031 + public Map<Object, Object> putAllInto( Map<Object, Object> pMap ) {
1032 + if ( (pMap != null) && !isEmpty() ) {
1033 + for ( Iterator<String> it = mProxiedMap.keySet().iterator(); it.hasNext(); ) {
1034 + Object zKey = it.next();
1035 + pMap.put( zKey, mProxiedMap.get( zKey ) );
1036 + }
1037 + }
1038 + return pMap;
1039 + }
1040 +
1041 + // todo: Eliminate
1042 + private Object LLgetRawValue( String pKey ) {
1043 + return mProxiedMap.get( pKey );
1044 + }
1045 +
1046 + public static final class BackDoor {
1047 + public static Object getRawValue( ParamMap pParamMap, String pKey ) {
1048 + return pParamMap.LLgetRawValue( pKey );
1049 + }
1050 + }
1051 + }