mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 13:02:13 +01:00
java: change spec. of pack methods in several template classes as follow: If user passes null object to the pack method, MessageTypeException is thrown.
This commit is contained in:
parent
f936a307c6
commit
419d2e9564
@ -25,7 +25,11 @@ public class BigIntegerTemplate implements Template {
|
||||
private BigIntegerTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packBigInteger((BigInteger)target);
|
||||
try {
|
||||
pk.packBigInteger((BigInteger)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class BooleanTemplate implements Template {
|
||||
private BooleanTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packBoolean((Boolean)target);
|
||||
try {
|
||||
pk.packBoolean((Boolean)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class ByteArrayTemplate implements Template {
|
||||
private ByteArrayTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packByteArray((byte[])target);
|
||||
try {
|
||||
pk.packByteArray((byte[])target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -26,11 +26,14 @@ public class ByteBufferTemplate implements Template {
|
||||
}
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.pack((ByteBuffer) target);
|
||||
try {
|
||||
pk.packByteBuffer((ByteBuffer) 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 {
|
||||
return pac.unpackByteBuffer();
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,11 @@ public class DoubleTemplate implements Template {
|
||||
private DoubleTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packDouble(((Double)target));
|
||||
try {
|
||||
pk.packDouble(((Double)target));
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class FloatTemplate implements Template {
|
||||
private FloatTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packFloat((Float)target);
|
||||
try {
|
||||
pk.packFloat((Float)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class IntegerTemplate implements Template {
|
||||
private IntegerTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packInt((Integer)target);
|
||||
try {
|
||||
pk.packInt((Integer)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class LongTemplate implements Template {
|
||||
private LongTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packLong((Long)target);
|
||||
try {
|
||||
pk.packLong((Long)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -24,7 +24,11 @@ public class StringTemplate implements Template {
|
||||
private StringTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packString((String)target);
|
||||
try {
|
||||
pk.packString((String)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user