KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > util > Marshaller


1 /*
2  * Copyright (c) 2004 Your Corporation. All Rights Reserved.
3  */

4 package org.jfox.ioc.util;
5
6 import java.rmi.MarshalledObject JavaDoc;
7
8 /**
9  * @author <a HREF="mailto:yy.young@gmail.com">Young Yang</a>
10  */

11
12 public class Marshaller {
13     public static MarshalledObject JavaDoc marshall(Object JavaDoc obj){
14         if(obj == null) {
15             return null;
16         }
17         else if(obj instanceof MarshalledObject JavaDoc){
18             return (MarshalledObject JavaDoc)obj;
19         }
20         else {
21             try {
22                 return new MarshalledObject JavaDoc(obj);
23             }
24             catch(Exception JavaDoc e){
25                 e.printStackTrace();
26                 return null;
27             }
28         }
29     }
30
31     public static Object JavaDoc unmarshall(Object JavaDoc obj){
32         if(obj == null) {
33             return null;
34         }
35         else if(obj instanceof MarshalledObject JavaDoc){
36             try {
37                 return ((MarshalledObject JavaDoc)obj).get();
38             }
39             catch(Exception JavaDoc e){
40                 e.printStackTrace();
41                 return null;
42             }
43         }
44         else {
45             return obj;
46         }
47     }
48
49     public static void main(String JavaDoc[] args) {
50
51     }
52 }
53
54
Popular Tags