Package de.netseeker.ejoe.adapter.json

Source Code of de.netseeker.ejoe.adapter.json.SojoJsonAdapter

/*********************************************************************
* SojoJsonAdapter.java
* created on 01.12.2006 by netseeker
* $Id: SojoJsonAdapter.java,v 1.2 2007/03/22 21:01:34 netseeker Exp $
* $Log: SojoJsonAdapter.java,v $
* Revision 1.2  2007/03/22 21:01:34  netseeker
* *** empty log message ***
*
* Revision 1.1  2006/12/01 23:36:02  netseeker
* *** empty log message ***
*
*
* ====================================================================
*
*  Copyright 2005-2006 netseeker aka Michael Manske
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* ====================================================================
*
* This file is part of the EJOE framework.
* For more information on the author, please see
* <http://www.manskes.de/>.
*
*********************************************************************/
package de.netseeker.ejoe.adapter.json;

import java.io.InputStream;
import java.io.OutputStream;

import net.sf.sojo.interchange.json.JsonSerializer;
import de.netseeker.ejoe.adapter.UTF8StringAdapter;

/**
* An adapter for (de)serializing objects via the JsonSerializer of
* SOJO - Simplify your Old Java Objects
*
* @see <a href="http://sojo.sourceforge.net/">SOJO</a>
* @author netseeker
* @since 0.3.9.2
*/
public class SojoJsonAdapter extends UTF8StringAdapter
{
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /*
     * (non-Javadoc)
     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#read(java.io.InputStream)
     */
    public Object read( InputStream in ) throws Exception
    {
        JsonSerializer serializer = new JsonSerializer();
        String json = (String) super.read( in );
        return serializer.deserialize( json );
    }

    /*
     * (non-Javadoc)
     *
     * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object, java.io.OutputStream)
     */
    public void write( Object obj, OutputStream out ) throws Exception
    {
        JsonSerializer serializer = new JsonSerializer();
        super.write( serializer.serialize( obj ), out );
    }
}
TOP

Related Classes of de.netseeker.ejoe.adapter.json.SojoJsonAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.