@SuppressWarnings("deprecation") @Override public void readFields(DataInput in) throws IOException { if (in.readBoolean()) { modify(in.readInt()); } else { setNull(); } }
@SuppressWarnings("deprecation") @Override public int restore(byte[] bytes, int offset, int limit) throws IOException { if (limit - offset == 0) { throw new IOException(MessageFormat.format( "Cannot restore a Date field ({0})", "invalid length")); } if (bytes[offset + 0] == 0) { setNull(); return 1; } else if (limit - offset >= 4 + 1) { modify(ByteArrayUtil.readInt(bytes, offset + 1)); return 5; } else { throw new IOException(MessageFormat.format( "Cannot restore a Date field ({0})", "invalid length")); } }
@Override @SuppressWarnings("deprecation") public void reset() { this.itemCode.setNull(); this.itemName.setNull(); this.departmentCode.setNull(); this.departmentName.setNull(); this.categoryCode.setNull(); this.categoryName.setNull(); this.unitSellingPrice.setNull(); this.registeredDate.setNull(); this.beginDate.setNull(); this.endDate.setNull(); } @Override
@SuppressWarnings("deprecation") private void fill0(DateOption option, boolean doRecover) throws CsvFormatException { if (lineBuffer.hasRemaining()) { int value = dateFormat.parse(lineBuffer); if (value < 0) { if (doRecover && trimWhitespaces()) { fill0(option, false); return; } throw new CsvFormatException( createStatusInLine(Reason.INVALID_CELL_FORMAT, dateFormat.getPattern()), null); } option.modify(value); } else { option.setNull(); } }
@Override public void fill(DateOption option) throws RecordFormatException, IOException { checkCellStart(); if (applyNull(option)) { return; } int year = toNumber(lookAhead) * 1000 + readNumbers(YEAR_FIELD_LENGTH - 1, option); consume(DATE_FIELD_SEPARATOR); int month = readNumbers(MONTH_FIELD_LENGTH, option); consume(DATE_FIELD_SEPARATOR); int day = readNumbers(DATE_FIELD_LENGTH, option); int last = reader.read(); if (isSeparator(last) == false) { throw new RecordFormatException(MessageFormat.format( "Missing separator for {0}", option.getClass().getSimpleName())); } setLastSeparator(last); if (year == 0 || month == 0 || day == 0) { option.setNull(); } else { option.modify(DateUtil.getDayFromDate(year, month, day)); } fillLookAhead(); }
emitter.endRecord(); value.setNull(); emitter.emit(value); value.modify(date(1, 1, 1));