blob: 61465708d682569906548fa76a7e0f7b24d1fd4d (
plain) (
blame)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*******************************************************************************
* Copyright (c) 2009 STMicroelectronics.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.gcov.utils;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
/**
*
*/
public class BEDataInputStream implements DataInput {
private final DataInputStream in;
private final byte[] buffer = new byte[8];
/**
* Constructor
* @param in
*/
public BEDataInputStream(DataInputStream in) {
this.in = in;
}
@Override
public final short readShort() throws IOException
{
return in.readShort();
}
@Override
public final int readUnsignedShort() throws IOException
{
return in.readUnsignedShort();
}
@Override
public final char readChar() throws IOException
{
return in.readChar();
}
@Override
public final int readInt() throws IOException
{
return in.readInt();
}
@Override
public final long readLong() throws IOException
{
in.readFully(buffer, 0, 8);
return (((long)buffer[7] << 32) +
((long)(buffer[6] & 255) << 40) +
((long)(buffer[5] & 255) << 48) +
((long)(buffer[4] & 255) << 56) +
((long)(buffer[3] & 255) << 0) +
((buffer[2] & 255) << 8) +
((buffer[1] & 255) << 16) +
((buffer[0] & 255) << 24));
}
@Override
public final float readFloat() throws IOException
{
return Float.intBitsToFloat(readInt());
}
@Override
public final double readDouble() throws IOException
{
return Double.longBitsToDouble(readLong());
}
@Override
public boolean readBoolean() throws IOException {
return in.readBoolean();
}
@Override
public byte readByte() throws IOException {
return in.readByte();
}
@Override
public void readFully(byte[] b) throws IOException {
in.readFully(b);
}
@Override
public void readFully(byte[] b, int off, int len) throws IOException {
in.readFully(b,off,len);
}
@Override
@Deprecated
public String readLine() throws IOException {
return in.readLine();
}
@Override
public String readUTF() throws IOException {
return in.readUTF();
}
@Override
public int readUnsignedByte() throws IOException {
return in.readUnsignedByte();
}
@Override
public int skipBytes(int n) throws IOException {
return in.skipBytes(n);
}
/**
* Close this stream.
*/
public void close() throws IOException {
in.close();
}
public final long readUnsignedInt() throws IOException
{
in.readFully(buffer, 0, 4);
return
((
(buffer[0]) << 24 |
(buffer[1]&0xff) << 16 |
(buffer[2]&0xff) << 8 |
(buffer[3]&0xff)
)
& MasksGenerator.UNSIGNED_INT_MASK );
}
}
|