1
2 package jsdsi.sexp;
3
4 import java.io.FilterOutputStream;
5 import java.io.IOException;
6 import java.io.OutputStream;
7
8 import jsdsi.Obj;
9
10 /***
11 Writes serialized Objs as S-expressions to an underlying stream.
12 Supports the canonical, transport, and readable S-expression
13 encodings.
14
15 @author Sameer Ajmani
16 @see SexpOutputStream
17 @see ObjInputStream
18 **/
19 public class ObjOutputStream extends FilterOutputStream
20 {
21 SexpOutputStream s;
22 /***
23 Creates a new ObjOutputStream that writes to the given stream.
24 **/
25 public ObjOutputStream(OutputStream os)
26 {
27 super(new SexpOutputStream(os));
28 s = (SexpOutputStream)super.out;
29 }
30 /***
31 Writes an Obj to the stream as a readable S-expression.
32 @param o the Obj to write
33 @param offset spaces indented from left
34 @param width total width of window, in characters
35 @param last spaces reserved on right (e.g., for closing parens)
36 @throws IOException if there is an IO error
37 **/
38 public void writeReadable(Obj o, int offset, int width, int last)
39 throws IOException
40 {
41 s.writeReadable(o.toSexp(), offset, width, last);
42 }
43 /***
44 Writes an Obj to the stream as a transport S-expression.
45 @param o the Obj to write
46 @throws IOException if there is an IO error
47 **/
48 public void writeTransport(Obj o) throws IOException
49 {
50 s.writeTransport(o.toSexp());
51 }
52 /***
53 Writes an Obj to the stream as a canonical S-expression.
54 @param o the Obj to write
55 @throws IOException if there is an IO error
56 **/
57 public void writeCanonical(Obj o) throws IOException
58 {
59 s.writeCanonical(o.toSexp());
60 }
61 }
This page was automatically generated by Maven