@Override public void timeProperty(PropertyName name, Cell context) throws IOException { if (context.getCellTypeEnum() != CellType.NUMERIC) { throw exception(name, context, "date/datetime"); //$NON-NLS-1$ } Calendar calendar = Calendar.getInstance(); calendar.setTime(context.getDateCellValue()); Calendar result = Calendar.getInstance(); result.clear(); result.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY)); result.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE)); result.set(Calendar.SECOND, calendar.get(Calendar.SECOND)); builder.add(name, result); }
@Override public void dateProperty(PropertyName name, Cell context) throws IOException { if (context.getCellTypeEnum() != CellType.NUMERIC) { throw exception(name, context, "date/datetime"); //$NON-NLS-1$ } Calendar calendar = Calendar.getInstance(); calendar.setTime(context.getDateCellValue()); Calendar result = Calendar.getInstance(); result.clear(); result.set( calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE)); builder.add(name, result); }
@Override public void stringProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsString()); }
@Override public void integerProperty(PropertyName name, Cell context) throws IOException { BigDecimal decimal = toDecimal(name, context, "integer"); //$NON-NLS-1$ builder.add(name, decimal.toBigInteger()); }
@Override public void longProperty(PropertyName name, Cell context) throws IOException { long value = toLong(name, context, "long"); //$NON-NLS-1$ builder.add(name, value); }
@Override public void shortProperty(PropertyName name, Cell context) throws IOException { long value = toLong(name, context, "short"); //$NON-NLS-1$ checkRange(name, context, value, Short.MIN_VALUE, Short.MAX_VALUE); builder.add(name, (short) value); }
@Override public void doubleProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsDouble()); }
@Override public void floatProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsFloat()); }
@Override public void booleanProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsBoolean()); }
@Override public void decimalProperty(PropertyName name, Cell context) throws IOException { BigDecimal decimal = toDecimal(name, context, "decimal"); //$NON-NLS-1$ builder.add(name, decimal); }
@Override public void floatProperty(PropertyName name, Cell context) throws IOException { double value = toDouble(name, context, "float"); //$NON-NLS-1$ builder.add(name, (float) value); }
@Override public void intProperty(PropertyName name, Cell context) throws IOException { long value = toLong(name, context, "int"); //$NON-NLS-1$ checkRange(name, context, value, Integer.MIN_VALUE, Integer.MAX_VALUE); builder.add(name, (int) value); }
@Override public void decimalProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsBigDecimal()); }
@Override public void longProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsLong()); }
@Override public void byteProperty(PropertyName name, Cell context) throws IOException { long value = toLong(name, context, "byte"); //$NON-NLS-1$ checkRange(name, context, value, Byte.MIN_VALUE, Byte.MAX_VALUE); builder.add(name, (byte) value); }
@Override public void doubleProperty(PropertyName name, Cell context) throws IOException { double value = toDouble(name, context, "double"); //$NON-NLS-1$ builder.add(name, value); }
@Override public void shortProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsShort()); }
@Override public void byteProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsByte()); }
@Override public void integerProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsBigInteger()); }
@Override public void intProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsInt()); }