1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright (C) 2012, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.storage.file;
import java.io.DataInput;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.NB;
/**
* An implementation of DataInput that only handles readInt() and readLong()
* using the Git conversion utilities for network byte order handling. This is
* needed to read {@link com.googlecode.javaewah.EWAHCompressedBitmap}s.
*/
class SimpleDataInput implements DataInput {
private final InputStream fd;
private final byte[] buf = new byte[8];
SimpleDataInput(InputStream fd) {
this.fd = fd;
}
@Override
public int readInt() throws IOException {
readFully(buf, 0, 4);
return NB.decodeInt32(buf, 0);
}
@Override
public long readLong() throws IOException {
readFully(buf, 0, 8);
return NB.decodeInt64(buf, 0);
}
/**
* Read unsigned int
*
* @return a long.
* @throws java.io.IOException
* if any.
*/
public long readUnsignedInt() throws IOException {
readFully(buf, 0, 4);
return NB.decodeUInt32(buf, 0);
}
@Override
public void readFully(byte[] b) throws IOException {
readFully(b, 0, b.length);
}
@Override
public void readFully(byte[] b, int off, int len) throws IOException {
IO.readFully(fd, b, off, len);
}
@Override
public int skipBytes(int n) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public boolean readBoolean() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public byte readByte() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public int readUnsignedByte() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public short readShort() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public int readUnsignedShort() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public char readChar() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public float readFloat() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public double readDouble() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public String readLine() throws IOException {
throw new UnsupportedOperationException();
}
@Override
public String readUTF() throws IOException {
throw new UnsupportedOperationException();
}
}
|