KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > trove > SerializationProcedure


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 JavaDoc;
22 import java.io.ObjectOutput JavaDoc;
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 class SerializationProcedure implements TDoubleDoubleProcedure,
43     TDoubleFloatProcedure,
44     TDoubleIntProcedure,
45     TDoubleLongProcedure,
46     TDoubleShortProcedure,
47     TDoubleByteProcedure,
48     TDoubleObjectProcedure,
49     TDoubleProcedure,
50     TFloatDoubleProcedure,
51     TFloatFloatProcedure,
52     TFloatIntProcedure,
53     TFloatLongProcedure,
54     TFloatShortProcedure,
55     TFloatByteProcedure,
56     TFloatObjectProcedure,
57     TFloatProcedure,
58     TIntDoubleProcedure,
59     TIntFloatProcedure,
60     TIntIntProcedure,
61     TIntLongProcedure,
62     TIntShortProcedure,
63     TIntByteProcedure,
64     TIntObjectProcedure,
65     TIntProcedure,
66     TLongDoubleProcedure,
67     TLongFloatProcedure,
68     TLongIntProcedure,
69     TLongLongProcedure,
70     TLongShortProcedure,
71     TLongByteProcedure,
72     TLongObjectProcedure,
73     TLongProcedure,
74     TShortDoubleProcedure,
75     TShortFloatProcedure,
76     TShortIntProcedure,
77     TShortLongProcedure,
78     TShortShortProcedure,
79     TShortByteProcedure,
80     TShortObjectProcedure,
81     TShortProcedure,
82     TByteDoubleProcedure,
83     TByteFloatProcedure,
84     TByteIntProcedure,
85     TByteLongProcedure,
86     TByteShortProcedure,
87     TByteByteProcedure,
88     TByteObjectProcedure,
89     TByteProcedure,
90     TObjectDoubleProcedure,
91     TObjectFloatProcedure,
92     TObjectIntProcedure,
93     TObjectLongProcedure,
94     TObjectShortProcedure,
95     TObjectByteProcedure,
96     TObjectObjectProcedure,
97     TObjectProcedure {
98
99     private final ObjectOutput JavaDoc stream;
100     IOException JavaDoc exception;
101
102     SerializationProcedure ( ObjectOutput JavaDoc stream) {
103         this.stream = stream;
104     }
105
106     public boolean execute(byte val) {
107         try {
108             stream.writeByte(val);
109         } catch (IOException JavaDoc e) {
110             this.exception = e;
111             return false;
112         }
113         return true;
114     }
115
116     public boolean execute(short val) {
117         try {
118             stream.writeShort(val);
119         } catch (IOException JavaDoc e) {
120             this.exception = e;
121             return false;
122         }
123         return true;
124     }
125
126     public boolean execute(int val) {
127         try {
128             stream.writeInt(val);
129         } catch (IOException JavaDoc e) {
130             this.exception = e;
131             return false;
132         }
133         return true;
134     }
135
136     public boolean execute(double val) {
137         try {
138             stream.writeDouble(val);
139         } catch (IOException JavaDoc e) {
140             this.exception = e;
141             return false;
142         }
143         return true;
144     }
145
146     public boolean execute(long val) {
147         try {
148             stream.writeLong(val);
149         } catch (IOException JavaDoc e) {
150             this.exception = e;
151             return false;
152         }
153         return true;
154     }
155
156     public boolean execute(float val) {
157         try {
158             stream.writeFloat(val);
159         } catch (IOException JavaDoc e) {
160             this.exception = e;
161             return false;
162         }
163         return true;
164     }
165
166     public boolean execute(Object JavaDoc val) {
167         try {
168             stream.writeObject(val);
169         } catch (IOException JavaDoc e) {
170             this.exception = e;
171             return false;
172         }
173         return true;
174     }
175
176     public boolean execute(Object JavaDoc key, Object JavaDoc val) {
177         try {
178             stream.writeObject(key);
179             stream.writeObject(val);
180         } catch (IOException JavaDoc e) {
181             this.exception = e;
182             return false;
183         }
184         return true;
185     }
186
187     public boolean execute(Object JavaDoc key, byte val) {
188         try {
189             stream.writeObject(key);
190             stream.writeByte(val);
191         } catch (IOException JavaDoc e) {
192             this.exception = e;
193             return false;
194         }
195         return true;
196     }
197
198     public boolean execute(Object JavaDoc key, short val) {
199         try {
200             stream.writeObject(key);
201             stream.writeShort(val);
202         } catch (IOException JavaDoc e) {
203             this.exception = e;
204             return false;
205         }
206         return true;
207     }
208
209     public boolean execute(Object JavaDoc key, int val) {
210         try {
211             stream.writeObject(key);
212             stream.writeInt(val);
213         } catch (IOException JavaDoc e) {
214             this.exception = e;
215             return false;
216         }
217         return true;
218     }
219
220     public boolean execute(Object JavaDoc key, long val) {
221         try {
222             stream.writeObject(key);
223             stream.writeLong(val);
224         } catch (IOException JavaDoc e) {
225             this.exception = e;
226             return false;
227         }
228         return true;
229     }
230
231     public boolean execute(Object JavaDoc key, double val) {
232         try {
233             stream.writeObject(key);
234             stream.writeDouble(val);
235         } catch (IOException JavaDoc e) {
236             this.exception = e;
237             return false;
238         }
239         return true;
240     }
241
242     public boolean execute(Object JavaDoc key, float val) {
243         try {
244             stream.writeObject(key);
245             stream.writeFloat(val);
246         } catch (IOException JavaDoc e) {
247             this.exception = e;
248             return false;
249         }
250         return true;
251     }
252
253     public boolean execute(int key, byte val) {
254         try {
255             stream.writeInt(key);
256             stream.writeByte(val);
257         } catch (IOException JavaDoc e) {
258             this.exception = e;
259             return false;
260         }
261         return true;
262     }
263
264     public boolean execute(int key, short val) {
265         try {
266             stream.writeInt(key);
267             stream.writeShort(val);
268         } catch (IOException JavaDoc e) {
269             this.exception = e;
270             return false;
271         }
272         return true;
273     }
274
275     public boolean execute(int key, Object JavaDoc val) {
276         try {
277             stream.writeInt(key);
278             stream.writeObject(val);
279         } catch (IOException JavaDoc e) {
280             this.exception = e;
281             return false;
282         }
283         return true;
284     }
285
286     public boolean execute(int key, int val) {
287         try {
288             stream.writeInt(key);
289             stream.writeInt(val);
290         } catch (IOException JavaDoc e) {
291             this.exception = e;
292             return false;
293         }
294         return true;
295     }
296
297     public boolean execute(int key, long val) {
298         try {
299             stream.writeInt(key);
300             stream.writeLong(val);
301         } catch (IOException JavaDoc e) {
302             this.exception = e;
303             return false;
304         }
305         return true;
306     }
307
308     public boolean execute(int key, double val) {
309         try {
310             stream.writeInt(key);
311             stream.writeDouble(val);
312         } catch (IOException JavaDoc e) {
313             this.exception = e;
314             return false;
315         }
316         return true;
317     }
318
319     public boolean execute(int key, float val) {
320         try {
321             stream.writeInt(key);
322             stream.writeFloat(val);
323         } catch (IOException JavaDoc e) {
324             this.exception = e;
325             return false;
326         }
327         return true;
328     }
329
330     public boolean execute(long key, Object JavaDoc val) {
331         try {
332             stream.writeLong(key);
333             stream.writeObject(val);
334         } catch (IOException JavaDoc e) {
335             this.exception = e;
336             return false;
337         }
338         return true;
339     }
340
341     public boolean execute(long key, byte val) {
342         try {
343             stream.writeLong(key);
344             stream.writeByte(val);
345         } catch (IOException JavaDoc e) {
346             this.exception = e;
347             return false;
348         }
349         return true;
350     }
351
352     public boolean execute(long key, short val) {
353         try {
354             stream.writeLong(key);
355             stream.writeShort(val);
356         } catch (IOException JavaDoc e) {
357             this.exception = e;
358             return false;
359         }
360         return true;
361     }
362
363     public boolean execute(long key, int val) {
364         try {
365             stream.writeLong(key);
366             stream.writeInt(val);
367         } catch (IOException JavaDoc e) {
368             this.exception = e;
369             return false;
370         }
371         return true;
372     }
373
374     public boolean execute(long key, long val) {
375         try {
376             stream.writeLong(key);
377             stream.writeLong(val);
378         } catch (IOException JavaDoc e) {
379             this.exception = e;
380             return false;
381         }
382         return true;
383     }
384
385     public boolean execute(long key, double val) {
386         try {
387             stream.writeLong(key);
388             stream.writeDouble(val);
389         } catch (IOException JavaDoc e) {
390             this.exception = e;
391             return false;
392         }
393         return true;
394     }
395
396     public boolean execute(long key, float val) {
397         try {
398             stream.writeLong(key);
399             stream.writeFloat(val);
400         } catch (IOException JavaDoc e) {
401             this.exception = e;
402             return false;
403         }
404         return true;
405     }
406
407     public boolean execute(double key, Object JavaDoc val) {
408         try {
409             stream.writeDouble(key);
410             stream.writeObject(val);
411         } catch (IOException JavaDoc e) {
412             this.exception = e;
413             return false;
414         }
415         return true;
416     }
417
418     public boolean execute(double key, byte val) {
419         try {
420             stream.writeDouble(key);
421             stream.writeByte(val);
422         } catch (IOException JavaDoc e) {
423             this.exception = e;
424             return false;
425         }
426         return true;
427     }
428
429     public boolean execute(double key, short val) {
430         try {
431             stream.writeDouble(key);
432             stream.writeShort(val);
433         } catch (IOException JavaDoc e) {
434             this.exception = e;
435             return false;
436         }
437         return true;
438     }
439
440     public boolean execute(double key, int val) {
441         try {
442             stream.writeDouble(key);
443             stream.writeInt(val);
444         } catch (IOException JavaDoc e) {
445             this.exception = e;
446             return false;
447         }
448         return true;
449     }
450
451     public boolean execute(double key, long val) {
452         try {
453             stream.writeDouble(key);
454             stream.writeLong(val);
455         } catch (IOException JavaDoc e) {
456             this.exception = e;
457             return false;
458         }
459         return true;
460     }
461
462     public boolean execute(double key, double val) {
463         try {
464             stream.writeDouble(key);
465             stream.writeDouble(val);
466         } catch (IOException JavaDoc e) {
467             this.exception = e;
468             return false;
469         }
470         return true;
471     }
472
473     public boolean execute(double key, float val) {
474         try {
475             stream.writeDouble(key);
476             stream.writeFloat(val);
477         } catch (IOException JavaDoc e) {
478             this.exception = e;
479             return false;
480         }
481         return true;
482     }
483
484     public boolean execute(float key, Object JavaDoc val) {
485         try {
486             stream.writeFloat(key);
487             stream.writeObject(val);
488         } catch (IOException JavaDoc e) {
489             this.exception = e;
490             return false;
491         }
492         return true;
493     }
494
495     public boolean execute(float key, byte val) {
496         try {
497             stream.writeFloat(key);
498             stream.writeByte(val);
499         } catch (IOException JavaDoc e) {
500             this.exception = e;
501             return false;
502         }
503         return true;
504     }
505
506     public boolean execute(float key, short val) {
507         try {
508             stream.writeFloat(key);
509             stream.writeShort(val);
510         } catch (IOException JavaDoc e) {
511             this.exception = e;
512             return false;
513         }
514         return true;
515     }
516
517     public boolean execute(float key, int val) {
518         try {
519             stream.writeFloat(key);
520             stream.writeInt(val);
521         } catch (IOException JavaDoc e) {
522             this.exception = e;
523             return false;
524         }
525         return true;
526     }
527
528     public boolean execute(float key, long val) {
529         try {
530             stream.writeFloat(key);
531             stream.writeLong(val);
532         } catch (IOException JavaDoc e) {
533             this.exception = e;
534             return false;
535         }
536         return true;
537     }
538
539     public boolean execute(float key, double val) {
540         try {
541             stream.writeFloat(key);
542             stream.writeDouble(val);
543         } catch (IOException JavaDoc e) {
544             this.exception = e;
545             return false;
546         }
547         return true;
548     }
549
550     public boolean execute(float key, float val) {
551         try {
552             stream.writeFloat(key);
553             stream.writeFloat(val);
554         } catch (IOException JavaDoc e) {
555             this.exception = e;
556             return false;
557         }
558         return true;
559     }
560
561     public boolean execute(byte key, Object JavaDoc val) {
562         try {
563             stream.writeByte(key);
564             stream.writeObject(val);
565         } catch (IOException JavaDoc e) {
566             this.exception = e;
567             return false;
568         }
569         return true;
570     }
571
572     public boolean execute(byte key, byte val) {
573         try {
574             stream.writeByte(key);
575             stream.writeByte(val);
576         } catch (IOException JavaDoc e) {
577             this.exception = e;
578             return false;
579         }
580         return true;
581     }
582
583     public boolean execute(byte key, short val) {
584         try {
585             stream.writeByte(key);
586             stream.writeShort(val);
587         } catch (IOException JavaDoc e) {
588             this.exception = e;
589             return false;
590         }
591         return true;
592     }
593
594     public boolean execute(byte key, int val) {
595         try {
596             stream.writeByte(key);
597             stream.writeInt(val);
598         } catch (IOException JavaDoc e) {
599             this.exception = e;
600             return false;
601         }
602         return true;
603     }
604
605     public boolean execute(byte key, long val) {
606         try {
607             stream.writeByte(key);
608             stream.writeLong(val);
609         } catch (IOException JavaDoc e) {
610             this.exception = e;
611             return false;
612         }
613         return true;
614     }
615
616     public boolean execute(byte key, double val) {
617         try {
618             stream.writeByte(key);
619             stream.writeDouble(val);
620         } catch (IOException JavaDoc e) {
621             this.exception = e;
622             return false;
623         }
624         return true;
625     }
626
627     public boolean execute(byte key, float val) {
628         try {
629             stream.writeByte(key);
630             stream.writeFloat(val);
631         } catch (IOException JavaDoc e) {
632             this.exception = e;
633             return false;
634         }
635         return true;
636     }
637
638     public boolean execute(short key, Object JavaDoc val) {
639         try {
640             stream.writeShort(key);
641             stream.writeObject(val);
642         } catch (IOException JavaDoc e) {
643             this.exception = e;
644             return false;
645         }
646         return true;
647     }
648
649     public boolean execute(short key, byte val) {
650         try {
651             stream.writeShort(key);
652             stream.writeByte(val);
653         } catch (IOException JavaDoc e) {
654             this.exception = e;
655             return false;
656         }
657         return true;
658     }
659
660     public boolean execute(short key, short val) {
661         try {
662             stream.writeShort(key);
663             stream.writeShort(val);
664         } catch (IOException JavaDoc e) {
665             this.exception = e;
666             return false;
667         }
668         return true;
669     }
670
671     public boolean execute(short key, int val) {
672         try {
673             stream.writeShort(key);
674             stream.writeInt(val);
675         } catch (IOException JavaDoc e) {
676             this.exception = e;
677             return false;
678         }
679         return true;
680     }
681
682     public boolean execute(short key, long val) {
683         try {
684             stream.writeShort(key);
685             stream.writeLong(val);
686         } catch (IOException JavaDoc e) {
687             this.exception = e;
688             return false;
689         }
690         return true;
691     }
692
693     public boolean execute(short key, double val) {
694         try {
695             stream.writeShort(key);
696             stream.writeDouble(val);
697         } catch (IOException JavaDoc e) {
698             this.exception = e;
699             return false;
700         }
701         return true;
702     }
703
704     public boolean execute(short key, float val) {
705         try {
706             stream.writeShort(key);
707             stream.writeFloat(val);
708         } catch (IOException JavaDoc e) {
709             this.exception = e;
710             return false;
711         }
712         return true;
713     }
714 }// SerializationProcedure
715
Popular Tags