1 /**********************************************************************
2 * SojoJsonAdapter.java
3 * created on 01.12.2006 by netseeker
4 * $Id: SojoJsonAdapter.java,v 1.2 2007/03/22 21:01:34 netseeker Exp $
5 * $Log: SojoJsonAdapter.java,v $
6 * Revision 1.2 2007/03/22 21:01:34 netseeker
7 * *** empty log message ***
8 *
9 * Revision 1.1 2006/12/01 23:36:02 netseeker
10 * *** empty log message ***
11 *
12 *
13 * ====================================================================
14 *
15 * Copyright 2005-2006 netseeker aka Michael Manske
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 * ====================================================================
29 *
30 * This file is part of the EJOE framework.
31 * For more information on the author, please see
32 * <http://www.manskes.de/>.
33 *
34 *********************************************************************/
35 package de.netseeker.ejoe.adapter.json;
36
37 import java.io.InputStream;
38 import java.io.OutputStream;
39
40 import net.sf.sojo.interchange.json.JsonSerializer;
41 import de.netseeker.ejoe.adapter.UTF8StringAdapter;
42
43 /***
44 * An adapter for (de)serializing objects via the JsonSerializer of
45 * SOJO - Simplify your Old Java Objects
46 *
47 * @see <a href="http://sojo.sourceforge.net/">SOJO</a>
48 * @author netseeker
49 * @since 0.3.9.2
50 */
51 public class SojoJsonAdapter extends UTF8StringAdapter
52 {
53 /***
54 *
55 */
56 private static final long serialVersionUID = 1L;
57
58
59
60
61
62
63 public Object read( InputStream in ) throws Exception
64 {
65 JsonSerializer serializer = new JsonSerializer();
66 String json = (String) super.read( in );
67 return serializer.deserialize( json );
68 }
69
70
71
72
73
74
75 public void write( Object obj, OutputStream out ) throws Exception
76 {
77 JsonSerializer serializer = new JsonSerializer();
78 super.write( serializer.serialize( obj ), out );
79 }
80 }