Skip to content

Commit 90a8186

Browse files
author
Steve Powell
committed
Added writeArray(Object[]) method so that AMQP arrays can be Java Arrays.
1 parent ebd1719 commit 90a8186

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/com/rabbitmq/client/impl/ValueWriter.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ else if(value instanceof List) {
189189
writeOctet('A');
190190
writeArray((List<?>)value);
191191
}
192+
else if(value instanceof Object[]) {
193+
writeOctet('A');
194+
writeArray((Object[])value);
195+
}
192196
else {
193197
throw new IllegalArgumentException
194198
("Invalid value type: " + value.getClass().getName());
@@ -209,6 +213,20 @@ public final void writeArray(List<?> value)
209213
}
210214
}
211215

216+
public final void writeArray(Object[] value)
217+
throws IOException
218+
{
219+
if (value==null) {
220+
out.write(0);
221+
}
222+
else {
223+
out.writeInt(value.length);
224+
for (Object item : value) {
225+
writeFieldValue(item);
226+
}
227+
}
228+
}
229+
212230
/** Public API - encodes an octet from an int. */
213231
public final void writeOctet(int octet)
214232
throws IOException

0 commit comments

Comments
 (0)