@Test public void testToNullValue() throws Exception { expectedEx.expect(NumberFormatException.class); expectedEx.expectMessage("For input string"); config.setNullFillerChar((char)0); typeConverter.initialize(config); assertEquals(null, typeConverter.to(new byte[4], 0, 2, 2, true)); }
@Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return Integer.parseInt(this.defaultValue); } else { return Integer.parseInt(getIntegerString(bytes, offset, length, removePadding)); } }
IntegerToInteger extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return Integer.parseInt(this.defaultValue); } else { return Integer.parseInt(getIntegerString(bytes, offset, length, removePadding)); } } }
IntegerToInteger extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return Integer.parseInt(this.defaultValue); } else { return Integer.parseInt(getIntegerString(bytes, offset, length, removePadding)); } }  }
IntegerToInteger extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return Integer.parseInt(this.defaultValue); } else { return Integer.parseInt(getIntegerString(bytes, offset, length, removePadding)); } }  @Override void validate(Class<?> type, int size, int decimal); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding); }
IntegerToInteger extends TypeConverterBase { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { if(this.defaultValue != null && ByteUtils.allEquals(bytes, this.nullFillerByte, offset, bytes.length)) { return Integer.parseInt(this.defaultValue); } else { return Integer.parseInt(getIntegerString(bytes, offset, length, removePadding)); } }  @Override void validate(Class<?> type, int size, int decimal); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding);  }