View Javadoc

1   /*
2    * Created on 18.03.2005
3    */
4   package de.netseeker.ejoe.adapter;
5   
6   import java.io.DataInputStream;
7   import java.io.DataOutputStream;
8   import java.io.IOException;
9   import java.io.InputStream;
10  import java.io.OutputStream;
11  
12  /***
13   * Simple raw string (de)Serializer for serializing/deserializing string
14   * messages. This adapter will always use UTF8 encoding.
15   * 
16   * @author netseeker
17   */
18  public class UTF8StringAdapter implements SerializeAdapter
19  {
20  	/*
21  	 * (non-Javadoc)
22  	 * 
23  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#read(java.io.InputStream)
24  	 */
25  	public Object read(InputStream in) throws IOException
26  	{
27  		return new DataInputStream(in).readUTF();
28  	}
29  
30  	/*
31  	 * (non-Javadoc)
32  	 * 
33  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#write(java.lang.Object,
34  	 *      java.io.OutputStream)
35  	 */
36  	public void write(Object obj, OutputStream out) throws IOException
37  	{
38  		new DataOutputStream(out).writeUTF(obj.toString());
39  	}
40  
41  	/*
42  	 * (non-Javadoc)
43  	 * 
44  	 * @see de.netseeker.ejoe.adapter.SerializeAdapter#handleClassLoaderChange(java.lang.ClassLoader)
45  	 */
46  	public void handleClassLoaderChange(ClassLoader classLoader)
47  	{
48  		// nothing to do
49  	}
50  
51  }