1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
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.
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.
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 ///////////////////////////////////////////////////////////////////////////////
21 import java.io.IOException;
22 import java.io.ObjectOutput;
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.
32 * Any IOException is trapped here so that it can be rethrown in a writeObject
36 * Created: Sun Jul 7 00:14:18 2002
38 * @author Eric D. Friedman
39 * @version $Id: SerializationProcedure.java,v 1.5 2006/11/10 23:27:54 robeden Exp $
42 @SuppressWarnings("rawtypes")
43 class SerializationProcedure implements
44 // TDoubleDoubleProcedure,
45 // TDoubleFloatProcedure,
46 // TDoubleIntProcedure,
47 // TDoubleLongProcedure,
48 // TDoubleShortProcedure,
49 // TDoubleByteProcedure,
50 // TDoubleObjectProcedure,
52 // TFloatDoubleProcedure,
53 // TFloatFloatProcedure,
54 // TFloatIntProcedure,
55 // TFloatLongProcedure,
56 // TFloatShortProcedure,
57 // TFloatByteProcedure,
58 // TFloatObjectProcedure,
60 // TIntDoubleProcedure,
61 // TIntFloatProcedure,
64 // TIntShortProcedure,
68 // TLongDoubleProcedure,
69 // TLongFloatProcedure,
71 // TLongLongProcedure,
72 // TLongShortProcedure,
73 // TLongByteProcedure,
74 // TLongObjectProcedure,
76 // TShortDoubleProcedure,
77 // TShortFloatProcedure,
78 // TShortIntProcedure,
79 // TShortLongProcedure,
80 // TShortShortProcedure,
81 // TShortByteProcedure,
82 // TShortObjectProcedure,
84 // TByteDoubleProcedure,
85 // TByteFloatProcedure,
87 // TByteLongProcedure,
88 // TByteShortProcedure,
89 // TByteByteProcedure,
90 // TByteObjectProcedure,
92 // TObjectDoubleProcedure,
93 // TObjectFloatProcedure,
94 // TObjectIntProcedure,
95 // TObjectLongProcedure,
96 // TObjectShortProcedure,
97 // TObjectByteProcedure,
98 // TObjectObjectProcedure,
102 private final ObjectOutput stream;
103 IOException exception;
105 SerializationProcedure ( ObjectOutput stream) {
106 this.stream = stream;
109 // public boolean execute(byte val) {
111 // stream.writeByte(val);
112 // } catch (IOException e) {
113 // this.exception = e;
119 // public boolean execute(short val) {
121 // stream.writeShort(val);
122 // } catch (IOException e) {
123 // this.exception = e;
130 public boolean execute(int val) {
132 stream.writeInt(val);
133 } catch (IOException e) {
140 // public boolean execute(double val) {
142 // stream.writeDouble(val);
143 // } catch (IOException e) {
144 // this.exception = e;
150 // public boolean execute(long val) {
152 // stream.writeLong(val);
153 // } catch (IOException e) {
154 // this.exception = e;
161 public boolean execute(float val) {
163 stream.writeFloat(val);
164 } catch (IOException e) {
171 // public boolean execute(Object val) {
173 // stream.writeObject(val);
174 // } catch (IOException e) {
175 // this.exception = e;
181 // public boolean execute(Object key, Object val) {
183 // stream.writeObject(key);
184 // stream.writeObject(val);
185 // } catch (IOException e) {
186 // this.exception = e;
192 // public boolean execute(Object key, byte val) {
194 // stream.writeObject(key);
195 // stream.writeByte(val);
196 // } catch (IOException e) {
197 // this.exception = e;
203 // public boolean execute(Object key, short val) {
205 // stream.writeObject(key);
206 // stream.writeShort(val);
207 // } catch (IOException e) {
208 // this.exception = e;
214 // public boolean execute(Object key, int val) {
216 // stream.writeObject(key);
217 // stream.writeInt(val);
218 // } catch (IOException e) {
219 // this.exception = e;
225 // public boolean execute(Object key, long val) {
227 // stream.writeObject(key);
228 // stream.writeLong(val);
229 // } catch (IOException e) {
230 // this.exception = e;
236 // public boolean execute(Object key, double val) {
238 // stream.writeObject(key);
239 // stream.writeDouble(val);
240 // } catch (IOException e) {
241 // this.exception = e;
247 // public boolean execute(Object key, float val) {
249 // stream.writeObject(key);
250 // stream.writeFloat(val);
251 // } catch (IOException e) {
252 // this.exception = e;
258 // public boolean execute(int key, byte val) {
260 // stream.writeInt(key);
261 // stream.writeByte(val);
262 // } catch (IOException e) {
263 // this.exception = e;
269 // public boolean execute(int key, short val) {
271 // stream.writeInt(key);
272 // stream.writeShort(val);
273 // } catch (IOException e) {
274 // this.exception = e;
281 public boolean execute(int key, Object val) {
283 stream.writeInt(key);
284 stream.writeObject(val);
285 } catch (IOException e) {
292 // public boolean execute(int key, int val) {
294 // stream.writeInt(key);
295 // stream.writeInt(val);
296 // } catch (IOException e) {
297 // this.exception = e;
303 // public boolean execute(int key, long val) {
305 // stream.writeInt(key);
306 // stream.writeLong(val);
307 // } catch (IOException e) {
308 // this.exception = e;
314 // public boolean execute(int key, double val) {
316 // stream.writeInt(key);
317 // stream.writeDouble(val);
318 // } catch (IOException e) {
319 // this.exception = e;
325 // public boolean execute(int key, float val) {
327 // stream.writeInt(key);
328 // stream.writeFloat(val);
329 // } catch (IOException e) {
330 // this.exception = e;
336 // public boolean execute(long key, Object val) {
338 // stream.writeLong(key);
339 // stream.writeObject(val);
340 // } catch (IOException e) {
341 // this.exception = e;
347 // public boolean execute(long key, byte val) {
349 // stream.writeLong(key);
350 // stream.writeByte(val);
351 // } catch (IOException e) {
352 // this.exception = e;
358 // public boolean execute(long key, short val) {
360 // stream.writeLong(key);
361 // stream.writeShort(val);
362 // } catch (IOException e) {
363 // this.exception = e;
369 // public boolean execute(long key, int val) {
371 // stream.writeLong(key);
372 // stream.writeInt(val);
373 // } catch (IOException e) {
374 // this.exception = e;
380 // public boolean execute(long key, long val) {
382 // stream.writeLong(key);
383 // stream.writeLong(val);
384 // } catch (IOException e) {
385 // this.exception = e;
391 // public boolean execute(long key, double val) {
393 // stream.writeLong(key);
394 // stream.writeDouble(val);
395 // } catch (IOException e) {
396 // this.exception = e;
402 // public boolean execute(long key, float val) {
404 // stream.writeLong(key);
405 // stream.writeFloat(val);
406 // } catch (IOException e) {
407 // this.exception = e;
413 // public boolean execute(double key, Object val) {
415 // stream.writeDouble(key);
416 // stream.writeObject(val);
417 // } catch (IOException e) {
418 // this.exception = e;
424 // public boolean execute(double key, byte val) {
426 // stream.writeDouble(key);
427 // stream.writeByte(val);
428 // } catch (IOException e) {
429 // this.exception = e;
435 // public boolean execute(double key, short val) {
437 // stream.writeDouble(key);
438 // stream.writeShort(val);
439 // } catch (IOException e) {
440 // this.exception = e;
446 // public boolean execute(double key, int val) {
448 // stream.writeDouble(key);
449 // stream.writeInt(val);
450 // } catch (IOException e) {
451 // this.exception = e;
457 // public boolean execute(double key, long val) {
459 // stream.writeDouble(key);
460 // stream.writeLong(val);
461 // } catch (IOException e) {
462 // this.exception = e;
468 // public boolean execute(double key, double val) {
470 // stream.writeDouble(key);
471 // stream.writeDouble(val);
472 // } catch (IOException e) {
473 // this.exception = e;
479 // public boolean execute(double key, float val) {
481 // stream.writeDouble(key);
482 // stream.writeFloat(val);
483 // } catch (IOException e) {
484 // this.exception = e;
490 // public boolean execute(float key, Object val) {
492 // stream.writeFloat(key);
493 // stream.writeObject(val);
494 // } catch (IOException e) {
495 // this.exception = e;
501 // public boolean execute(float key, byte val) {
503 // stream.writeFloat(key);
504 // stream.writeByte(val);
505 // } catch (IOException e) {
506 // this.exception = e;
512 // public boolean execute(float key, short val) {
514 // stream.writeFloat(key);
515 // stream.writeShort(val);
516 // } catch (IOException e) {
517 // this.exception = e;
523 // public boolean execute(float key, int val) {
525 // stream.writeFloat(key);
526 // stream.writeInt(val);
527 // } catch (IOException e) {
528 // this.exception = e;
534 // public boolean execute(float key, long val) {
536 // stream.writeFloat(key);
537 // stream.writeLong(val);
538 // } catch (IOException e) {
539 // this.exception = e;
545 // public boolean execute(float key, double val) {
547 // stream.writeFloat(key);
548 // stream.writeDouble(val);
549 // } catch (IOException e) {
550 // this.exception = e;
556 // public boolean execute(float key, float val) {
558 // stream.writeFloat(key);
559 // stream.writeFloat(val);
560 // } catch (IOException e) {
561 // this.exception = e;
567 // public boolean execute(byte key, Object val) {
569 // stream.writeByte(key);
570 // stream.writeObject(val);
571 // } catch (IOException e) {
572 // this.exception = e;
578 // public boolean execute(byte key, byte val) {
580 // stream.writeByte(key);
581 // stream.writeByte(val);
582 // } catch (IOException e) {
583 // this.exception = e;
589 // public boolean execute(byte key, short val) {
591 // stream.writeByte(key);
592 // stream.writeShort(val);
593 // } catch (IOException e) {
594 // this.exception = e;
600 // public boolean execute(byte key, int val) {
602 // stream.writeByte(key);
603 // stream.writeInt(val);
604 // } catch (IOException e) {
605 // this.exception = e;
611 // public boolean execute(byte key, long val) {
613 // stream.writeByte(key);
614 // stream.writeLong(val);
615 // } catch (IOException e) {
616 // this.exception = e;
622 // public boolean execute(byte key, double val) {
624 // stream.writeByte(key);
625 // stream.writeDouble(val);
626 // } catch (IOException e) {
627 // this.exception = e;
633 // public boolean execute(byte key, float val) {
635 // stream.writeByte(key);
636 // stream.writeFloat(val);
637 // } catch (IOException e) {
638 // this.exception = e;
644 // public boolean execute(short key, Object val) {
646 // stream.writeShort(key);
647 // stream.writeObject(val);
648 // } catch (IOException e) {
649 // this.exception = e;
655 // public boolean execute(short key, byte val) {
657 // stream.writeShort(key);
658 // stream.writeByte(val);
659 // } catch (IOException e) {
660 // this.exception = e;
666 // public boolean execute(short key, short val) {
668 // stream.writeShort(key);
669 // stream.writeShort(val);
670 // } catch (IOException e) {
671 // this.exception = e;
677 // public boolean execute(short key, int val) {
679 // stream.writeShort(key);
680 // stream.writeInt(val);
681 // } catch (IOException e) {
682 // this.exception = e;
688 // public boolean execute(short key, long val) {
690 // stream.writeShort(key);
691 // stream.writeLong(val);
692 // } catch (IOException e) {
693 // this.exception = e;
699 // public boolean execute(short key, double val) {
701 // stream.writeShort(key);
702 // stream.writeDouble(val);
703 // } catch (IOException e) {
704 // this.exception = e;
710 // public boolean execute(short key, float val) {
712 // stream.writeShort(key);
713 // stream.writeFloat(val);
714 // } catch (IOException e) {
715 // this.exception = e;
720 }// SerializationProcedure