@Test public void testFromZeroValue() throws Exception { assertArrayEquals(" ".getBytes(StandardCharsets.UTF_8), typeConverter.from("", 4, -1, true)); }
@Override public byte[] from(Object value, int length, int decimals, boolean addPadding) { byte[] strBytes = null; if(value != null || this.defaultValue != null) { strBytes = (value != null ? (String)value : this.defaultValue).getBytes(this.charset); if (strBytes.length > length) { throw new TypeConverterException("Field to small for value: " + length + " < " + strBytes.length); } if (addPadding) { strBytes = padBytes(strBytes, length); } } else if(addPadding) { strBytes = new byte[length]; Arrays.fill(strBytes, this.nullFillerByte); } return strBytes; }
StringToString extends TypeConverterBase { @Override public byte[] from(Object value, int length, int decimals, boolean addPadding) { byte[] strBytes = null; if(value != null || this.defaultValue != null) { strBytes = (value != null ? (String)value : this.defaultValue).getBytes(this.charset); if (strBytes.length > length) { throw new TypeConverterException("Field to small for value: " + length + " < " + strBytes.length); } if (addPadding) { strBytes = padBytes(strBytes, length); } } else if(addPadding) { strBytes = new byte[length]; Arrays.fill(strBytes, this.nullFillerByte); } return strBytes; } }
StringToString extends TypeConverterBase { @Override public byte[] from(Object value, int length, int decimals, boolean addPadding) { byte[] strBytes = null; if(value != null || this.defaultValue != null) { strBytes = (value != null ? (String)value : this.defaultValue).getBytes(this.charset); if (strBytes.length > length) { throw new TypeConverterException("Field to small for value: " + length + " < " + strBytes.length); } if (addPadding) { strBytes = padBytes(strBytes, length); } } else if(addPadding) { strBytes = new byte[length]; Arrays.fill(strBytes, this.nullFillerByte); } return strBytes; }  }
StringToString extends TypeConverterBase { @Override public byte[] from(Object value, int length, int decimals, boolean addPadding) { byte[] strBytes = null; if(value != null || this.defaultValue != null) { strBytes = (value != null ? (String)value : this.defaultValue).getBytes(this.charset); if (strBytes.length > length) { throw new TypeConverterException("Field to small for value: " + length + " < " + strBytes.length); } if (addPadding) { strBytes = padBytes(strBytes, length); } } else if(addPadding) { strBytes = new byte[length]; Arrays.fill(strBytes, this.nullFillerByte); } return strBytes; }  @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding); }
StringToString extends TypeConverterBase { @Override public byte[] from(Object value, int length, int decimals, boolean addPadding) { byte[] strBytes = null; if(value != null || this.defaultValue != null) { strBytes = (value != null ? (String)value : this.defaultValue).getBytes(this.charset); if (strBytes.length > length) { throw new TypeConverterException("Field to small for value: " + length + " < " + strBytes.length); } if (addPadding) { strBytes = padBytes(strBytes, length); } } else if(addPadding) { strBytes = new byte[length]; Arrays.fill(strBytes, this.nullFillerByte); } return strBytes; }  @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding);  }