]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/gnu/trove/SerializationProcedure.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / gnu / trove / SerializationProcedure.java
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 //
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 ///////////////////////////////////////////////////////////////////////////////
18
19 package gnu.trove;
20
21 import java.io.IOException;
22 import java.io.ObjectOutput;
23
24
25 /**
26  * Implementation of the variously typed procedure interfaces that supports
27  * writing the arguments to the procedure out on an ObjectOutputStream.
28  * In the case of two-argument procedures, the arguments are written out
29  * in the order received.
30  *
31  * <p>
32  * Any IOException is trapped here so that it can be rethrown in a writeObject
33  * method.
34  * </p>
35  *
36  * Created: Sun Jul  7 00:14:18 2002
37  *
38  * @author Eric D. Friedman
39  * @version $Id: SerializationProcedure.java,v 1.5 2006/11/10 23:27:54 robeden Exp $
40  */
41
42 @SuppressWarnings("rawtypes")
43 class SerializationProcedure implements
44 //    TDoubleDoubleProcedure,
45 //    TDoubleFloatProcedure,
46 //    TDoubleIntProcedure,
47 //    TDoubleLongProcedure,
48 //    TDoubleShortProcedure,
49 //    TDoubleByteProcedure,
50 //    TDoubleObjectProcedure,
51 //    TDoubleProcedure,
52 //    TFloatDoubleProcedure,
53 //    TFloatFloatProcedure,
54 //    TFloatIntProcedure,
55 //    TFloatLongProcedure,
56 //    TFloatShortProcedure,
57 //    TFloatByteProcedure,
58 //    TFloatObjectProcedure,
59 TFloatProcedure,
60 //    TIntDoubleProcedure,
61 //    TIntFloatProcedure,
62 //    TIntIntProcedure,
63 //    TIntLongProcedure,
64 //    TIntShortProcedure,
65 //    TIntByteProcedure,
66 TIntObjectProcedure,
67 TIntProcedure
68 //    TLongDoubleProcedure,
69 //    TLongFloatProcedure,
70 //    TLongIntProcedure,
71 //    TLongLongProcedure,
72 //    TLongShortProcedure,
73 //    TLongByteProcedure,
74 //    TLongObjectProcedure,
75 //    TLongProcedure,
76 //    TShortDoubleProcedure,
77 //    TShortFloatProcedure,
78 //    TShortIntProcedure,
79 //    TShortLongProcedure,
80 //    TShortShortProcedure,
81 //    TShortByteProcedure,
82 //    TShortObjectProcedure,
83 //    TShortProcedure,
84 //    TByteDoubleProcedure,
85 //    TByteFloatProcedure,
86 //    TByteIntProcedure,
87 //    TByteLongProcedure,
88 //    TByteShortProcedure,
89 //    TByteByteProcedure,
90 //    TByteObjectProcedure,
91 //    TByteProcedure,
92 //    TObjectDoubleProcedure,
93 //    TObjectFloatProcedure,
94 //    TObjectIntProcedure,
95 //    TObjectLongProcedure,
96 //    TObjectShortProcedure,
97 //    TObjectByteProcedure,
98 //    TObjectObjectProcedure,
99 //    TObjectProcedure
100 {
101
102     private final ObjectOutput stream;
103     IOException exception;
104
105     SerializationProcedure ( ObjectOutput stream) {
106         this.stream = stream;
107     }
108
109 //    public boolean execute(byte val) {
110 //        try {
111 //            stream.writeByte(val);
112 //        } catch (IOException e) {
113 //            this.exception = e;
114 //            return false;
115 //        }
116 //        return true;
117 //    }
118 //
119 //    public boolean execute(short val) {
120 //        try {
121 //            stream.writeShort(val);
122 //        } catch (IOException e) {
123 //            this.exception = e;
124 //            return false;
125 //        }
126 //        return true;
127 //    }
128
129     @Override
130     public boolean execute(int val) {
131         try {
132             stream.writeInt(val);
133         } catch (IOException e) {
134             this.exception = e;
135             return false;
136         }
137         return true;
138     }
139
140 //    public boolean execute(double val) {
141 //        try {
142 //            stream.writeDouble(val);
143 //        } catch (IOException e) {
144 //            this.exception = e;
145 //            return false;
146 //        }
147 //        return true;
148 //    }
149 //
150 //    public boolean execute(long val) {
151 //        try {
152 //            stream.writeLong(val);
153 //        } catch (IOException e) {
154 //            this.exception = e;
155 //            return false;
156 //        }
157 //        return true;
158 //    }
159
160     @Override
161     public boolean execute(float val) {
162         try {
163             stream.writeFloat(val);
164         } catch (IOException e) {
165             this.exception = e;
166             return false;
167         }
168         return true;
169     }
170
171 //    public boolean execute(Object val) {
172 //        try {
173 //            stream.writeObject(val);
174 //        } catch (IOException e) {
175 //            this.exception = e;
176 //            return false;
177 //        }
178 //        return true;
179 //    }
180 //
181 //    public boolean execute(Object key, Object val) {
182 //        try {
183 //            stream.writeObject(key);
184 //            stream.writeObject(val);
185 //        } catch (IOException e) {
186 //            this.exception = e;
187 //            return false;
188 //        }
189 //        return true;
190 //    }
191 //
192 //    public boolean execute(Object key, byte val) {
193 //        try {
194 //            stream.writeObject(key);
195 //            stream.writeByte(val);
196 //        } catch (IOException e) {
197 //            this.exception = e;
198 //            return false;
199 //        }
200 //        return true;
201 //    }
202 //
203 //    public boolean execute(Object key, short val) {
204 //        try {
205 //            stream.writeObject(key);
206 //            stream.writeShort(val);
207 //        } catch (IOException e) {
208 //            this.exception = e;
209 //            return false;
210 //        }
211 //        return true;
212 //    }
213 //
214 //    public boolean execute(Object key, int val) {
215 //        try {
216 //            stream.writeObject(key);
217 //            stream.writeInt(val);
218 //        } catch (IOException e) {
219 //            this.exception = e;
220 //            return false;
221 //        }
222 //        return true;
223 //    }
224 //
225 //    public boolean execute(Object key, long val) {
226 //        try {
227 //            stream.writeObject(key);
228 //            stream.writeLong(val);
229 //        } catch (IOException e) {
230 //            this.exception = e;
231 //            return false;
232 //        }
233 //        return true;
234 //    }
235 //
236 //    public boolean execute(Object key, double val) {
237 //        try {
238 //            stream.writeObject(key);
239 //            stream.writeDouble(val);
240 //        } catch (IOException e) {
241 //            this.exception = e;
242 //            return false;
243 //        }
244 //        return true;
245 //    }
246 //
247 //    public boolean execute(Object key, float val) {
248 //        try {
249 //            stream.writeObject(key);
250 //            stream.writeFloat(val);
251 //        } catch (IOException e) {
252 //            this.exception = e;
253 //            return false;
254 //        }
255 //        return true;
256 //    }
257 //
258 //    public boolean execute(int key, byte val) {
259 //        try {
260 //            stream.writeInt(key);
261 //            stream.writeByte(val);
262 //        } catch (IOException e) {
263 //            this.exception = e;
264 //            return false;
265 //        }
266 //        return true;
267 //    }
268 //
269 //    public boolean execute(int key, short val) {
270 //        try {
271 //            stream.writeInt(key);
272 //            stream.writeShort(val);
273 //        } catch (IOException e) {
274 //            this.exception = e;
275 //            return false;
276 //        }
277 //        return true;
278 //    }
279
280     @Override
281     public boolean execute(int key, Object val) {
282         try {
283             stream.writeInt(key);
284             stream.writeObject(val);
285         } catch (IOException e) {
286             this.exception = e;
287             return false;
288         }
289         return true;
290     }
291
292 //    public boolean execute(int key, int val) {
293 //        try {
294 //            stream.writeInt(key);
295 //            stream.writeInt(val);
296 //        } catch (IOException e) {
297 //            this.exception = e;
298 //            return false;
299 //        }
300 //        return true;
301 //    }
302 //
303 //    public boolean execute(int key, long val) {
304 //        try {
305 //            stream.writeInt(key);
306 //            stream.writeLong(val);
307 //        } catch (IOException e) {
308 //            this.exception = e;
309 //            return false;
310 //        }
311 //        return true;
312 //    }
313 //
314 //    public boolean execute(int key, double val) {
315 //        try {
316 //            stream.writeInt(key);
317 //            stream.writeDouble(val);
318 //        } catch (IOException e) {
319 //            this.exception = e;
320 //            return false;
321 //        }
322 //        return true;
323 //    }
324 //
325 //    public boolean execute(int key, float val) {
326 //        try {
327 //            stream.writeInt(key);
328 //            stream.writeFloat(val);
329 //        } catch (IOException e) {
330 //            this.exception = e;
331 //            return false;
332 //        }
333 //        return true;
334 //    }
335
336 //    public boolean execute(long key, Object val) {
337 //        try {
338 //            stream.writeLong(key);
339 //            stream.writeObject(val);
340 //        } catch (IOException e) {
341 //            this.exception = e;
342 //            return false;
343 //        }
344 //        return true;
345 //    }
346 //
347 //    public boolean execute(long key, byte val) {
348 //        try {
349 //            stream.writeLong(key);
350 //            stream.writeByte(val);
351 //        } catch (IOException e) {
352 //            this.exception = e;
353 //            return false;
354 //        }
355 //        return true;
356 //    }
357 //
358 //    public boolean execute(long key, short val) {
359 //        try {
360 //            stream.writeLong(key);
361 //            stream.writeShort(val);
362 //        } catch (IOException e) {
363 //            this.exception = e;
364 //            return false;
365 //        }
366 //        return true;
367 //    }
368 //
369 //    public boolean execute(long key, int val) {
370 //        try {
371 //            stream.writeLong(key);
372 //            stream.writeInt(val);
373 //        } catch (IOException e) {
374 //            this.exception = e;
375 //            return false;
376 //        }
377 //        return true;
378 //    }
379 //
380 //    public boolean execute(long key, long val) {
381 //        try {
382 //            stream.writeLong(key);
383 //            stream.writeLong(val);
384 //        } catch (IOException e) {
385 //            this.exception = e;
386 //            return false;
387 //        }
388 //        return true;
389 //    }
390 //
391 //    public boolean execute(long key, double val) {
392 //        try {
393 //            stream.writeLong(key);
394 //            stream.writeDouble(val);
395 //        } catch (IOException e) {
396 //            this.exception = e;
397 //            return false;
398 //        }
399 //        return true;
400 //    }
401 //
402 //    public boolean execute(long key, float val) {
403 //        try {
404 //            stream.writeLong(key);
405 //            stream.writeFloat(val);
406 //        } catch (IOException e) {
407 //            this.exception = e;
408 //            return false;
409 //        }
410 //        return true;
411 //    }
412 //
413 //    public boolean execute(double key, Object val) {
414 //        try {
415 //            stream.writeDouble(key);
416 //            stream.writeObject(val);
417 //        } catch (IOException e) {
418 //            this.exception = e;
419 //            return false;
420 //        }
421 //        return true;
422 //    }
423 //
424 //    public boolean execute(double key, byte val) {
425 //        try {
426 //            stream.writeDouble(key);
427 //            stream.writeByte(val);
428 //        } catch (IOException e) {
429 //            this.exception = e;
430 //            return false;
431 //        }
432 //        return true;
433 //    }
434 //
435 //    public boolean execute(double key, short val) {
436 //        try {
437 //            stream.writeDouble(key);
438 //            stream.writeShort(val);
439 //        } catch (IOException e) {
440 //            this.exception = e;
441 //            return false;
442 //        }
443 //        return true;
444 //    }
445 //
446 //    public boolean execute(double key, int val) {
447 //        try {
448 //            stream.writeDouble(key);
449 //            stream.writeInt(val);
450 //        } catch (IOException e) {
451 //            this.exception = e;
452 //            return false;
453 //        }
454 //        return true;
455 //    }
456 //
457 //    public boolean execute(double key, long val) {
458 //        try {
459 //            stream.writeDouble(key);
460 //            stream.writeLong(val);
461 //        } catch (IOException e) {
462 //            this.exception = e;
463 //            return false;
464 //        }
465 //        return true;
466 //    }
467 //
468 //    public boolean execute(double key, double val) {
469 //        try {
470 //            stream.writeDouble(key);
471 //            stream.writeDouble(val);
472 //        } catch (IOException e) {
473 //            this.exception = e;
474 //            return false;
475 //        }
476 //        return true;
477 //    }
478 //
479 //    public boolean execute(double key, float val) {
480 //        try {
481 //            stream.writeDouble(key);
482 //            stream.writeFloat(val);
483 //        } catch (IOException e) {
484 //            this.exception = e;
485 //            return false;
486 //        }
487 //        return true;
488 //    }
489 //
490 //    public boolean execute(float key, Object val) {
491 //        try {
492 //            stream.writeFloat(key);
493 //            stream.writeObject(val);
494 //        } catch (IOException e) {
495 //            this.exception = e;
496 //            return false;
497 //        }
498 //        return true;
499 //    }
500 //
501 //    public boolean execute(float key, byte val) {
502 //        try {
503 //            stream.writeFloat(key);
504 //            stream.writeByte(val);
505 //        } catch (IOException e) {
506 //            this.exception = e;
507 //            return false;
508 //        }
509 //        return true;
510 //    }
511 //
512 //    public boolean execute(float key, short val) {
513 //        try {
514 //            stream.writeFloat(key);
515 //            stream.writeShort(val);
516 //        } catch (IOException e) {
517 //            this.exception = e;
518 //            return false;
519 //        }
520 //        return true;
521 //    }
522 //
523 //    public boolean execute(float key, int val) {
524 //        try {
525 //            stream.writeFloat(key);
526 //            stream.writeInt(val);
527 //        } catch (IOException e) {
528 //            this.exception = e;
529 //            return false;
530 //        }
531 //        return true;
532 //    }
533 //
534 //    public boolean execute(float key, long val) {
535 //        try {
536 //            stream.writeFloat(key);
537 //            stream.writeLong(val);
538 //        } catch (IOException e) {
539 //            this.exception = e;
540 //            return false;
541 //        }
542 //        return true;
543 //    }
544 //
545 //    public boolean execute(float key, double val) {
546 //        try {
547 //            stream.writeFloat(key);
548 //            stream.writeDouble(val);
549 //        } catch (IOException e) {
550 //            this.exception = e;
551 //            return false;
552 //        }
553 //        return true;
554 //    }
555 //
556 //    public boolean execute(float key, float val) {
557 //        try {
558 //            stream.writeFloat(key);
559 //            stream.writeFloat(val);
560 //        } catch (IOException e) {
561 //            this.exception = e;
562 //            return false;
563 //        }
564 //        return true;
565 //    }
566 //
567 //    public boolean execute(byte key, Object val) {
568 //        try {
569 //            stream.writeByte(key);
570 //            stream.writeObject(val);
571 //        } catch (IOException e) {
572 //            this.exception = e;
573 //            return false;
574 //        }
575 //        return true;
576 //    }
577 //
578 //    public boolean execute(byte key, byte val) {
579 //        try {
580 //            stream.writeByte(key);
581 //            stream.writeByte(val);
582 //        } catch (IOException e) {
583 //            this.exception = e;
584 //            return false;
585 //        }
586 //        return true;
587 //    }
588 //
589 //    public boolean execute(byte key, short val) {
590 //        try {
591 //            stream.writeByte(key);
592 //            stream.writeShort(val);
593 //        } catch (IOException e) {
594 //            this.exception = e;
595 //            return false;
596 //        }
597 //        return true;
598 //    }
599 //
600 //    public boolean execute(byte key, int val) {
601 //        try {
602 //            stream.writeByte(key);
603 //            stream.writeInt(val);
604 //        } catch (IOException e) {
605 //            this.exception = e;
606 //            return false;
607 //        }
608 //        return true;
609 //    }
610 //
611 //    public boolean execute(byte key, long val) {
612 //        try {
613 //            stream.writeByte(key);
614 //            stream.writeLong(val);
615 //        } catch (IOException e) {
616 //            this.exception = e;
617 //            return false;
618 //        }
619 //        return true;
620 //    }
621 //
622 //    public boolean execute(byte key, double val) {
623 //        try {
624 //            stream.writeByte(key);
625 //            stream.writeDouble(val);
626 //        } catch (IOException e) {
627 //            this.exception = e;
628 //            return false;
629 //        }
630 //        return true;
631 //    }
632 //
633 //    public boolean execute(byte key, float val) {
634 //        try {
635 //            stream.writeByte(key);
636 //            stream.writeFloat(val);
637 //        } catch (IOException e) {
638 //            this.exception = e;
639 //            return false;
640 //        }
641 //        return true;
642 //    }
643 //
644 //    public boolean execute(short key, Object val) {
645 //        try {
646 //            stream.writeShort(key);
647 //            stream.writeObject(val);
648 //        } catch (IOException e) {
649 //            this.exception = e;
650 //            return false;
651 //        }
652 //        return true;
653 //    }
654 //
655 //    public boolean execute(short key, byte val) {
656 //        try {
657 //            stream.writeShort(key);
658 //            stream.writeByte(val);
659 //        } catch (IOException e) {
660 //            this.exception = e;
661 //            return false;
662 //        }
663 //        return true;
664 //    }
665 //
666 //    public boolean execute(short key, short val) {
667 //        try {
668 //            stream.writeShort(key);
669 //            stream.writeShort(val);
670 //        } catch (IOException e) {
671 //            this.exception = e;
672 //            return false;
673 //        }
674 //        return true;
675 //    }
676 //
677 //    public boolean execute(short key, int val) {
678 //        try {
679 //            stream.writeShort(key);
680 //            stream.writeInt(val);
681 //        } catch (IOException e) {
682 //            this.exception = e;
683 //            return false;
684 //        }
685 //        return true;
686 //    }
687 //
688 //    public boolean execute(short key, long val) {
689 //        try {
690 //            stream.writeShort(key);
691 //            stream.writeLong(val);
692 //        } catch (IOException e) {
693 //            this.exception = e;
694 //            return false;
695 //        }
696 //        return true;
697 //    }
698 //
699 //    public boolean execute(short key, double val) {
700 //        try {
701 //            stream.writeShort(key);
702 //            stream.writeDouble(val);
703 //        } catch (IOException e) {
704 //            this.exception = e;
705 //            return false;
706 //        }
707 //        return true;
708 //    }
709 //
710 //    public boolean execute(short key, float val) {
711 //        try {
712 //            stream.writeShort(key);
713 //            stream.writeFloat(val);
714 //        } catch (IOException e) {
715 //            this.exception = e;
716 //            return false;
717 //        }
718 //        return true;
719 //    }
720 }// SerializationProcedure