KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > marshal > http > HTTPMarshaller


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.remoting.marshal.http;
8
9 import java.io.IOException JavaDoc;
10 import java.io.OutputStream JavaDoc;
11 import org.jboss.remoting.marshal.Marshaller;
12 import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
13
14 /**
15  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
16  */

17 public class HTTPMarshaller extends SerializableMarshaller
18 {
19    static final long serialVersionUID = -51801299849879386L;
20
21    public final static String JavaDoc DATATYPE = "http";
22
23    /**
24     * Take the data object and write to the output.
25     * If the data object is of type String, will just
26     * write the bytes of the String, otherwise will
27     * use the SerializableMarshaller implementation.
28     *
29     * @param dataObject Object to be writen to output
30     * @param output The data output to write the object
31     * data to.
32     */

33    public void write(Object JavaDoc dataObject, OutputStream JavaDoc output) throws IOException JavaDoc
34    {
35       if(dataObject instanceof String JavaDoc)
36       {
37          output.write(((String JavaDoc) dataObject).getBytes());
38          output.flush();
39       }
40       else
41       {
42          super.write(dataObject, output);
43       }
44    }
45
46    public Marshaller cloneMarshaller() throws CloneNotSupportedException JavaDoc
47    {
48       return new HTTPMarshaller();
49    }
50 }
Popular Tags