View Javadoc
1 2 package jsdsi.sexp; 3 4 import java.io.FilterInputStream; 5 import java.io.IOException; 6 import java.io.InputStream; 7 8 import jsdsi.Obj; 9 10 /*** 11 * Reads SDSI objects encoded as S-expressions from an underlying 12 * stream. Supports the canonical, transport, and readable S-expression 13 * encodings. 14 * 15 * @author Sameer Ajmani 16 * @version $Revision: 1.1.6.1 $ $Date: 2005/11/08 03:12:52 $ 17 * 18 * @see SexpInputStream 19 * @see ObjOutputStream 20 */ 21 public class ObjInputStream extends FilterInputStream { 22 public static final int MAX_OBJ_SIZE = 4096; 23 private SexpInputStream s; 24 /*** 25 * Creates a new ObjInputStream that reads from the given stream. 26 */ 27 public ObjInputStream(InputStream is) { 28 super(new SexpInputStream(is)); 29 s = (SexpInputStream) super.in; 30 } 31 /*** 32 * Reads an Obj from the underlying stream. 33 */ 34 public Obj readObj() 35 throws SexpParseException, SexpException, IOException { 36 try { 37 if (s.markSupported()) { 38 s.mark(MAX_OBJ_SIZE); 39 } 40 return Obj.parseObj(s.readSexp()); 41 } catch (SexpParseException e) { 42 if (s.markSupported()) { 43 s.reset(); 44 } 45 throw e; 46 } catch (SexpException e) { 47 if (s.markSupported()) { 48 s.reset(); 49 } 50 throw e; 51 } catch (IOException e) { 52 if (s.markSupported()) { 53 s.reset(); 54 } 55 throw e; 56 } 57 } 58 }

This page was automatically generated by Maven