Lines 7-13
Link Here
|
7 |
* http://www.sun.com/ |
7 |
* http://www.sun.com/ |
8 |
* |
8 |
* |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun |
10 |
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun |
11 |
* Microsystems, Inc. All Rights Reserved. |
11 |
* Microsystems, Inc. All Rights Reserved. |
12 |
*/ |
12 |
*/ |
13 |
package org.netbeans.mdr.util; |
13 |
package org.netbeans.mdr.util; |
Lines 78-93
Link Here
|
78 |
public static void writeInt(OutputStream outputStream, int val) throws IOException { |
78 |
public static void writeInt(OutputStream outputStream, int val) throws IOException { |
79 |
if ((int) ((byte) val & 0x7F) == val) { |
79 |
if ((int) ((byte) val & 0x7F) == val) { |
80 |
outputStream.write((byte)val); |
80 |
outputStream.write((byte)val); |
81 |
} else if ((int) ((byte) (val >>> 8) & 0xFF) == val >>> 8) { |
|
|
82 |
outputStream.write(T_SHORT | 0x80); |
83 |
outputStream.write((byte)(val & 0xff)); |
84 |
outputStream.write((byte)((val & 0xff00) >>> 8)); |
85 |
} else { |
81 |
} else { |
86 |
outputStream.write(T_INTEGER | 0x80); |
82 |
byte [] arr = new byte [5]; |
87 |
outputStream.write((byte)(val & 0xff)); |
83 |
arr[1] = (byte)(val & 0xff); |
88 |
outputStream.write((byte)((val & 0xff00) >>> 8)); |
84 |
arr[2] = (byte)((val & 0xff00) >>> 8); |
89 |
outputStream.write((byte)((val & 0xff0000) >>> 16)); |
85 |
if ((int) ((byte) (val >>> 8) & 0xFF) == val >>> 8) { |
90 |
outputStream.write((byte)((val >>> 24) & 0xff)); |
86 |
arr[0] = (byte)(T_SHORT | 0x80); |
|
|
87 |
outputStream.write(arr, 0, 3); |
88 |
} else { |
89 |
arr[3] = (byte)((val & 0xff0000) >>> 16); |
90 |
arr[4] = (byte)((val >>> 24) & 0xff); |
91 |
arr[0] = (byte)(T_INTEGER | 0x80); |
92 |
outputStream.write(arr, 0, 5); |
93 |
} |
91 |
} |
94 |
} |
92 |
} |
95 |
} |
93 |
|
96 |
|
Lines 123-131
Link Here
|
123 |
return; |
126 |
return; |
124 |
} |
127 |
} |
125 |
int len = val.length(); |
128 |
int len = val.length(); |
|
|
129 |
char [] arr = new char[len]; |
130 |
val.getChars(0, len, arr, 0); |
126 |
writeInt(outputStream, len + 1); |
131 |
writeInt(outputStream, len + 1); |
127 |
for (int i = 0; i < len; i++) { |
132 |
for (int i = 0; i < len; i++) { |
128 |
char ch = val.charAt(i); |
133 |
char ch = arr[i]; |
129 |
if (ch <= 0x7f) { |
134 |
if (ch <= 0x7f) { |
130 |
outputStream.write((byte) ch); |
135 |
outputStream.write((byte) ch); |
131 |
} else if (ch <= 0x7ff) { |
136 |
} else if (ch <= 0x7ff) { |