001/* 002 * Copyright (C) 2009 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014 015package com.google.common.io; 016 017import com.google.common.annotations.GwtIncompatible; 018import com.google.errorprone.annotations.CanIgnoreReturnValue; 019import java.io.DataInput; 020import java.io.IOException; 021 022/** 023 * An extension of {@code DataInput} for reading from in-memory byte arrays; its methods offer 024 * identical functionality but do not throw {@link IOException}. 025 * 026 * <p><b>Warning:</b> The caller is responsible for not attempting to read past the end of the 027 * array. If any method encounters the end of the array prematurely, it throws {@link 028 * IllegalStateException} to signify <i>programmer error</i>. This behavior is a technical violation 029 * of the supertype's contract, which specifies a checked exception. 030 * 031 * @author Kevin Bourrillion 032 * @since 1.0 033 */ 034@GwtIncompatible 035public interface ByteArrayDataInput extends DataInput { 036 @Override 037 void readFully(byte b[]); 038 039 @Override 040 void readFully(byte b[], int off, int len); 041 042 // not guaranteed to skip n bytes so result should NOT be ignored 043 // use ByteStreams.skipFully or one of the read methods instead 044 @Override 045 int skipBytes(int n); 046 047 @CanIgnoreReturnValue // to skip a byte 048 @Override 049 boolean readBoolean(); 050 051 @CanIgnoreReturnValue // to skip a byte 052 @Override 053 byte readByte(); 054 055 @CanIgnoreReturnValue // to skip a byte 056 @Override 057 int readUnsignedByte(); 058 059 @CanIgnoreReturnValue // to skip some bytes 060 @Override 061 short readShort(); 062 063 @CanIgnoreReturnValue // to skip some bytes 064 @Override 065 int readUnsignedShort(); 066 067 @CanIgnoreReturnValue // to skip some bytes 068 @Override 069 char readChar(); 070 071 @CanIgnoreReturnValue // to skip some bytes 072 @Override 073 int readInt(); 074 075 @CanIgnoreReturnValue // to skip some bytes 076 @Override 077 long readLong(); 078 079 @CanIgnoreReturnValue // to skip some bytes 080 @Override 081 float readFloat(); 082 083 @CanIgnoreReturnValue // to skip some bytes 084 @Override 085 double readDouble(); 086 087 @CanIgnoreReturnValue // to skip a line 088 @Override 089 String readLine(); 090 091 @CanIgnoreReturnValue // to skip a field 092 @Override 093 String readUTF(); 094}