blob: 12654f6077161ea468ffc2708a3051f575153d5a (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
package IceInternal;
//
// Class to provide a java.io.InputStream on top of a BasicStream.
// We use this to deserialize arbitrary Java serializable classes from
// a Slice byte sequence. This class is a wrapper around a BasicStream
// that passes all methods through.
//
public class InputStreamWrapper extends java.io.InputStream
{
public
InputStreamWrapper(int size, BasicStream s)
{
_s = s;
_markPos = 0;
}
@Override
public int
read()
throws java.io.IOException
{
try
{
return _s.getBuffer().b.get();
}
catch(java.lang.Exception ex)
{
throw new java.io.IOException(ex.toString());
}
}
@Override
public int
read(byte[] b)
throws java.io.IOException
{
return read(b, 0, b.length);
}
@Override
public int
read(byte[] b, int offset, int count)
throws java.io.IOException
{
try
{
_s.getBuffer().b.get(b, offset, count);
}
catch(java.lang.Exception ex)
{
throw new java.io.IOException(ex.toString());
}
return count;
}
@Override
public int
available()
{
return _s.getBuffer().b.remaining();
}
@Override
public void
mark(int readlimit)
{
_markPos = _s.pos();
}
@Override
public void
reset()
throws java.io.IOException
{
_s.pos(_markPos);
}
@Override
public boolean
markSupported()
{
return true;
}
@Override
public void
close()
throws java.io.IOException
{
}
private BasicStream _s;
private int _markPos;
}
|