1 2 /* 3 * Hunt - A refined core library for D programming language. 4 * 5 * Copyright (C) 2018-2019 HuntLabs 6 * 7 * Website: https://www.huntlabs.net/ 8 * 9 * Licensed under the Apache-2.0 License. 10 * 11 */ 12 13 module hunt.stream.ObjectInput; 14 /** 15 * ObjectInput extends the DataInput interface to include the reading of 16 * objects. DataInput includes methods for the input of primitive types, 17 * ObjectInput extends that interface to include objects, arrays, and Strings. 18 * 19 * @author unascribed 20 * @see java.io.InputStream 21 * @see java.io.ObjectOutputStream 22 * @see java.io.ObjectInputStream 23 */ 24 25 import hunt.stream.DataInput; 26 import hunt.util.Common; 27 28 public interface ObjectInput : DataInput, AutoCloseable { 29 /** 30 * Read and return an object. The class that implements this interface 31 * defines where the object is "read" from. 32 * 33 * @return the object read from the stream 34 * @exception java.lang.ClassNotFoundException If the class of a serialized 35 * object cannot be found. 36 * @exception IOException If any of the usual Input/Output 37 * related exceptions occur. 38 */ 39 public Object readObject(); 40 41 /** 42 * Reads a byte of data. This method will block if no input is 43 * available. 44 * @return the byte read, or -1 if the end of the 45 * stream is reached. 46 * @exception IOException If an I/O error has occurred. 47 */ 48 public int read() ; 49 50 /** 51 * Reads into an array of bytes. This method will 52 * block until some input is available. 53 * @param b the buffer into which the data is read 54 * @return the actual number of bytes read, -1 is 55 * returned when the end of the stream is reached. 56 * @exception IOException If an I/O error has occurred. 57 */ 58 public int read(byte[] b) ; 59 60 /** 61 * Reads into an array of bytes. This method will 62 * block until some input is available. 63 * @param b the buffer into which the data is read 64 * @param off the start offset of the data 65 * @param len the maximum number of bytes read 66 * @return the actual number of bytes read, -1 is 67 * returned when the end of the stream is reached. 68 * @exception IOException If an I/O error has occurred. 69 */ 70 public int read(byte[] b, int off, int len) ; 71 72 /** 73 * Skips n bytes of input. 74 * @param n the number of bytes to be skipped 75 * @return the actual number of bytes skipped. 76 * @exception IOException If an I/O error has occurred. 77 */ 78 public long skip(long n) ; 79 80 /** 81 * Returns the number of bytes that can be read 82 * without blocking. 83 * @return the number of available bytes. 84 * @exception IOException If an I/O error has occurred. 85 */ 86 public int available() ; 87 88 /** 89 * Closes the input stream. Must be called 90 * to release any resources associated with 91 * the stream. 92 * @exception IOException If an I/O error has occurred. 93 */ 94 public void close() ; 95 }