de.netseeker.ejoe.adapter.json
Class JsonLibAdapter

java.lang.Object
  extended by de.netseeker.ejoe.adapter.BaseAdapter
      extended by de.netseeker.ejoe.adapter.UTF8StringAdapter
          extended by de.netseeker.ejoe.adapter.json.JsonLibAdapter
All Implemented Interfaces:
SerializeAdapter, java.io.Serializable

public class JsonLibAdapter
extends UTF8StringAdapter

Multimode SerializeAdapter supporting JSON via the JSON-lib. By default this adapter is write-only: It is able to serialize Objects to JSON but does just return JSON strings on read operations. The read mode can be switched but then Objects according to what JSON-lib creates will be returned.

Since:
0.3.9.1
Author:
netseeker
See Also:
JSON-lib, Serialized Form

Constructor Summary
JsonLibAdapter()
          Creates a write-only instance of this adapter.
JsonLibAdapter(boolean writeOnly)
          Creates either a write-only or a mixed-mode instance of this adapter.
 
Method Summary
 java.lang.String getContentType()
           
 java.lang.Object read(java.io.InputStream in)
          Deserializes an object out of an given InputStream
 void write(java.lang.Object obj, java.io.OutputStream out)
          Serializes an object into an output stream
 
Methods inherited from class de.netseeker.ejoe.adapter.BaseAdapter
handleClassLoaderChange, isSelfBuffered, requiresCustomEOFHandling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonLibAdapter

public JsonLibAdapter()
Creates a write-only instance of this adapter. It will write Object instances to JSON but will just return JSON string representations on read operations.


JsonLibAdapter

public JsonLibAdapter(boolean writeOnly)
Creates either a write-only or a mixed-mode instance of this adapter. In write-only mode it will write Object instances to JSON but will just return JSON string representations on read operations. In mixed-mode Objects according to what JSON-lib creates will be returned on read operations.

Parameters:
writeOnly - whether to uses write-only mode or not
Method Detail

read

public java.lang.Object read(java.io.InputStream in)
                      throws java.lang.Exception
Description copied from interface: SerializeAdapter
Deserializes an object out of an given InputStream

Specified by:
read in interface SerializeAdapter
Overrides:
read in class UTF8StringAdapter
Parameters:
in - the input stream to use for deserialization
Returns:
a deserialized object instance
Throws:
java.lang.Exception

write

public void write(java.lang.Object obj,
                  java.io.OutputStream out)
           throws java.lang.Exception
Description copied from interface: SerializeAdapter
Serializes an object into an output stream

Specified by:
write in interface SerializeAdapter
Overrides:
write in class UTF8StringAdapter
Parameters:
obj - object that should get serialized
out - the outputstream into which the object should serialized
Throws:
java.lang.Exception

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface SerializeAdapter
Overrides:
getContentType in class UTF8StringAdapter
Returns:
A recognized mime type
See Also:
mime type list of IANA


Copyright © 2005-2007 netseeker. All Rights Reserved.