• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 
15 package com.google.common.io;
16 
17 import com.google.common.annotations.GwtIncompatible;
18 import com.google.common.annotations.J2ktIncompatible;
19 import com.google.errorprone.annotations.CanIgnoreReturnValue;
20 import java.io.DataInput;
21 import java.io.IOException;
22 import javax.annotation.CheckForNull;
23 
24 /**
25  * An extension of {@code DataInput} for reading from in-memory byte arrays; its methods offer
26  * identical functionality but do not throw {@link IOException}.
27  *
28  * <p><b>Warning:</b> The caller is responsible for not attempting to read past the end of the
29  * array. If any method encounters the end of the array prematurely, it throws {@link
30  * IllegalStateException} to signify <i>programmer error</i>. This behavior is a technical violation
31  * of the supertype's contract, which specifies a checked exception.
32  *
33  * @author Kevin Bourrillion
34  * @since 1.0
35  */
36 @J2ktIncompatible
37 @GwtIncompatible
38 @ElementTypesAreNonnullByDefault
39 public interface ByteArrayDataInput extends DataInput {
40   @Override
readFully(byte b[])41   void readFully(byte b[]);
42 
43   @Override
readFully(byte b[], int off, int len)44   void readFully(byte b[], int off, int len);
45 
46   // not guaranteed to skip n bytes so result should NOT be ignored
47   // use ByteStreams.skipFully or one of the read methods instead
48   @Override
skipBytes(int n)49   int skipBytes(int n);
50 
51   @CanIgnoreReturnValue // to skip a byte
52   @Override
readBoolean()53   boolean readBoolean();
54 
55   @CanIgnoreReturnValue // to skip a byte
56   @Override
readByte()57   byte readByte();
58 
59   @CanIgnoreReturnValue // to skip a byte
60   @Override
readUnsignedByte()61   int readUnsignedByte();
62 
63   @CanIgnoreReturnValue // to skip some bytes
64   @Override
readShort()65   short readShort();
66 
67   @CanIgnoreReturnValue // to skip some bytes
68   @Override
readUnsignedShort()69   int readUnsignedShort();
70 
71   @CanIgnoreReturnValue // to skip some bytes
72   @Override
readChar()73   char readChar();
74 
75   @CanIgnoreReturnValue // to skip some bytes
76   @Override
readInt()77   int readInt();
78 
79   @CanIgnoreReturnValue // to skip some bytes
80   @Override
readLong()81   long readLong();
82 
83   @CanIgnoreReturnValue // to skip some bytes
84   @Override
readFloat()85   float readFloat();
86 
87   @CanIgnoreReturnValue // to skip some bytes
88   @Override
readDouble()89   double readDouble();
90 
91   @CanIgnoreReturnValue // to skip a line
92   @Override
93   @CheckForNull
readLine()94   String readLine();
95 
96   @CanIgnoreReturnValue // to skip a field
97   @Override
readUTF()98   String readUTF();
99 }
100