mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-20 05:27:56 +01:00
java: throws MessagePackException if target==null on *ArrayTemplate
This commit is contained in:
parent
aff964c58b
commit
339725f73d
@ -28,7 +28,11 @@ public class BooleanArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
boolean[] array = (boolean[])target;
|
boolean[] array = (boolean[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(boolean a : array) {
|
for(boolean a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ public class ByteTemplate implements Template {
|
|||||||
private ByteTemplate() { }
|
private ByteTemplate() { }
|
||||||
|
|
||||||
public void pack(Packer pk, Object target) throws IOException {
|
public void pack(Packer pk, Object target) throws IOException {
|
||||||
|
try {
|
||||||
pk.packByte((Byte)target);
|
pk.packByte((Byte)target);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||||
|
@ -42,6 +42,9 @@ public class DefaultTemplate implements Template {
|
|||||||
|
|
||||||
public void pack(Packer pk, Object target) throws IOException {
|
public void pack(Packer pk, Object target) throws IOException {
|
||||||
if(messagePackable) {
|
if(messagePackable) {
|
||||||
|
if(target == null) {
|
||||||
|
throw new MessageTypeException("target is null.");
|
||||||
|
}
|
||||||
((MessagePackable)target).messagePack(pk);
|
((MessagePackable)target).messagePack(pk);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@ public class DoubleArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
double[] array = (double[])target;
|
double[] array = (double[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(double a : array) {
|
for(double a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@ public class FloatArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
float[] array = (float[])target;
|
float[] array = (float[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(float a : array) {
|
for(float a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@ public class IntArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
int[] array = (int[])target;
|
int[] array = (int[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(int a : array) {
|
for(int a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@ public class LongArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
long[] array = (long[])target;
|
long[] array = (long[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(long a : array) {
|
for(long a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,11 @@ public class ShortArrayTemplate implements Template {
|
|||||||
throw new MessageTypeException();
|
throw new MessageTypeException();
|
||||||
}
|
}
|
||||||
short[] array = (short[])target;
|
short[] array = (short[])target;
|
||||||
|
try {
|
||||||
pk.packArray(array.length);
|
pk.packArray(array.length);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
for(short a : array) {
|
for(short a : array) {
|
||||||
pk.pack(a);
|
pk.pack(a);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ public class ShortTemplate implements Template {
|
|||||||
private ShortTemplate() { }
|
private ShortTemplate() { }
|
||||||
|
|
||||||
public void pack(Packer pk, Object target) throws IOException {
|
public void pack(Packer pk, Object target) throws IOException {
|
||||||
|
try {
|
||||||
pk.packShort((Short)target);
|
pk.packShort((Short)target);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
throw new MessageTypeException("target is null.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user