blob: eb881757d7953eae41df0fb8e5a17a211d89cdb5 (
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
package NET.worlds.network;
import java.io.IOException;
import java.io.UTFDataFormatException;
public class net2Property {
private int _propID;
protected int _flags;
protected int _access;
protected String _stringValue;
protected byte[] _binValue;
public net2Property(int p, int flags, int access, byte[] data) {
this._propID = p;
this._flags = flags;
this._access = access;
assert (flags & 16) > 0;
this._binValue = data;
this._stringValue = null;
}
public net2Property(int p, int flags, int access, String data) {
this._propID = p;
this._flags = flags;
this._access = access;
assert (flags & 16) == 0;
this._stringValue = data;
this._binValue = null;
}
public net2Property() {
this._propID = 0;
this._flags = 0;
this._access = 0;
this._stringValue = null;
this._binValue = null;
}
public int property() {
return this._propID;
}
public int flags() {
return this._flags;
}
public int access() {
return this._access;
}
public byte[] data() {
if ((this._flags & 16) > 0) {
return this._binValue;
} else {
byte[] data = new byte[this._stringValue.length()];
this._stringValue.getBytes(0, this._stringValue.length(), data, 0);
return data;
}
}
public String value() {
return (this._flags & 16) == 0 ? this._stringValue : new String(this._binValue);
}
int packetSize() {
if ((this._flags & 16) > 0) {
assert this._binValue != null;
return 4 + this._binValue.length;
} else {
assert this._stringValue != null;
return 4 + ServerOutputStream.utfLength(this._stringValue);
}
}
void parseNetData(ServerInputStream data) throws IOException, UTFDataFormatException {
this._propID = data.readUnsignedByte();
this._flags = data.readUnsignedByte();
this._access = data.readUnsignedByte();
if ((this._flags & 16) > 0) {
int size = data.readUnsignedByte();
this._binValue = new byte[size];
data.readFully(this._binValue);
this._stringValue = null;
} else {
try {
this._stringValue = data.readUTF();
} catch (UTFDataFormatException var3) {
this._stringValue = "";
throw var3;
}
this._binValue = null;
}
}
void send(ServerOutputStream o) throws IOException {
o.writeByte(this._propID);
o.writeByte(this._flags);
o.writeByte(this._access);
if ((this._flags & 16) > 0) {
o.writeByte(this._binValue.length);
o.write(this._binValue);
} else {
o.writeUTF(this._stringValue);
}
}
private String flagString() {
String out = "";
if ((this._flags & 128) > 0) {
out = out + "DBSTORE ";
}
if ((this._flags & 64) > 0) {
out = out + "AUTOUPDATE ";
}
if ((this._flags & 32) > 0) {
out = out + "FINGER ";
}
if ((this._flags & 16) > 0) {
out = out + "BINARY ";
}
if (out.length() == 0) {
out = "NONE";
}
return out;
}
private String accessString() {
String out = "";
if ((this._access & 1) > 0) {
out = out + "POSSESS ";
}
if ((this._access & 2) > 0) {
out = out + "PRIVATE ";
}
if (out.length() == 0) {
out = "NONE";
}
return out;
}
@Override
public String toString() {
String tmp = "#" + this._propID + " [" + this.flagString() + "/" + this.accessString() + "] ";
if ((this._flags & 16) == 0) {
return tmp + this._stringValue;
} else {
tmp = tmp + "val=[";
for (int i = 0; i < this._binValue.length; i++) {
tmp = tmp + Integer.toString(this._binValue[i], 16) + " ";
}
return tmp + "] (" + this._binValue + ")";
}
}
}
|