Mercurial > projects > dwt2
annotate base/src/java/io/ByteArrayOutputStream.d @ 107:e944a4cf537b
Updated to dmd 1.063 and Tango trunk.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 22 Aug 2010 18:53:29 +0200 |
parents | 1bf55a6eb092 |
children | 9f4c18c268b2 |
rev | line source |
---|---|
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /** |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2 * Authors: Frank Benoit <keinfarbton@googlemail.com> |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 */ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 module java.io.ByteArrayOutputStream; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 public import java.io.OutputStream; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 import java.lang.all; |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
8 |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
9 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
10 import tango.io.device.Array; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
11 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
12 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 public class ByteArrayOutputStream : java.io.OutputStream.OutputStream { |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
16 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
17 protected Array buffer; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
18 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
19 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
21 public this (){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
22 version(Tango){ |
107
e944a4cf537b
Updated to dmd 1.063 and Tango trunk.
Jacob Carlborg <doob@me.com>
parents:
27
diff
changeset
|
23 buffer = new Array(0); |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
24 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
25 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
26 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 public this ( int par_size ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
30 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
31 buffer = new Array(par_size); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
32 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
33 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
34 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
35 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
36 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 public synchronized override void write( int b ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
38 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
39 byte[1] a; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
40 a[0] = b & 0xFF; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
41 buffer.append(a); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
42 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
43 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
44 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 public synchronized override void write( byte[] b, int off, int len ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
48 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
49 buffer.append( b[ off .. off + len ]); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
50 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
51 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
52 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 public synchronized override void write( byte[] b ){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
56 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
57 buffer.append( b ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
58 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
59 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
60 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 public synchronized void writeTo( java.io.OutputStream.OutputStream out_KEYWORDESCAPE ){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 public synchronized void reset(){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 public synchronized byte[] toByteArray(){ |
21
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
72 version(Tango){ |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
73 return cast(byte[])buffer.slice(); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
74 } else { // Phobos |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
75 implMissing( __FILE__, __LINE__ ); |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
76 return null; |
9b96950f2c3c
the 'java' tree compiles on both D1-Tango and D2-Phobos
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
77 } |
0
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 public int size(){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 return 0; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 public override String toString(){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 return null; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 public String toString( String enc ){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 return null; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 public String toString( int hibyte ){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 return null; |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 public override void close(){ |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 implMissing( __FILE__, __LINE__ ); |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 } |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 |
6dd524f61e62
add dwt win and basic java stuff
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 |