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.io.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 * @since 1.1 24 */ 25 26 import hunt.io.DataInput; 27 import hunt.util.Common; 28 29 public interface ObjectInput : DataInput, AutoCloseable { 30 /** 31 * Read and return an object. The class that implements this interface 32 * defines where the object is "read" from. 33 * 34 * @return the object read from the stream 35 * @exception java.lang.ClassNotFoundException If the class of a serialized 36 * object cannot be found. 37 * @exception IOException If any of the usual Input/Output 38 * related exceptions occur. 39 */ 40 public Object readObject(); 41 42 /** 43 * Reads a byte of data. This method will block if no input is 44 * available. 45 * @return the byte read, or -1 if the end of the 46 * stream is reached. 47 * @exception IOException If an I/O error has occurred. 48 */ 49 public int read() ; 50 51 /** 52 * Reads into an array of bytes. This method will 53 * block until some input is available. 54 * @param b the buffer into which the data is read 55 * @return the actual number of bytes read, -1 is 56 * returned when the end of the stream is reached. 57 * @exception IOException If an I/O error has occurred. 58 */ 59 public int read(byte[] b) ; 60 61 /** 62 * Reads into an array of bytes. This method will 63 * block until some input is available. 64 * @param b the buffer into which the data is read 65 * @param off the start offset of the data 66 * @param len the maximum number of bytes read 67 * @return the actual number of bytes read, -1 is 68 * returned when the end of the stream is reached. 69 * @exception IOException If an I/O error has occurred. 70 */ 71 public int read(byte[] b, int off, int len) ; 72 73 /** 74 * Skips n bytes of input. 75 * @param n the number of bytes to be skipped 76 * @return the actual number of bytes skipped. 77 * @exception IOException If an I/O error has occurred. 78 */ 79 public long skip(long n) ; 80 81 /** 82 * Returns the number of bytes that can be read 83 * without blocking. 84 * @return the number of available bytes. 85 * @exception IOException If an I/O error has occurred. 86 */ 87 public int available() ; 88 89 /** 90 * Closes the input stream. Must be called 91 * to release any resources associated with 92 * the stream. 93 * @exception IOException If an I/O error has occurred. 94 */ 95 public void close() ; 96 }