Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.DecimalOption$DecimalBuffer


        CsvConfiguration conf = createConfiguration();
        RCReader reader = new RCReader("3.141592\r\n".getBytes(conf.getCharset()), count);
        try {
            int rows = 0;
            CsvParser parser = new CsvParser(reader, "testing", conf);
            DecimalOption date = new DecimalOption();
            while (parser.next()) {
                parser.fill(date);
                parser.endRecord();
                if (rows == 0) {
                    assertThat(date, is(new DecimalOption(new BigDecimal("3.141592"))));
                }
                rows++;
            }
            parser.close();
            assertThat(rows, is(count));
View Full Code Here


     * decimalの値を出力するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void emitDecimal() throws Exception {
        DecimalOption value = new DecimalOption();

        value.modify(decimal("0"));
        emitter.emit(value);
        value.modify(decimal("10"));
        emitter.emit(value);
        value.modify(decimal("-10"));
        emitter.emit(value);
        emitter.endRecord();

        value.setNull();
        emitter.emit(value);
        value.modify(decimal("0.9999999999999999999999999999999999999999999999999"));
        emitter.emit(value);
        value.modify(decimal("9223372036854775809"));
        emitter.emit(value);
        emitter.endRecord();

        emitter.close();

        RecordParser parser = parser();
        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(decimal("0")));
        parser.fill(value);
        assertThat(value.get(), is(decimal("10")));
        parser.fill(value);
        assertThat(value.get(), is(decimal("-10")));

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(decimal("0.9999999999999999999999999999999999999999999999999")));
        parser.fill(value);
        assertThat(value.get(), is(decimal("9223372036854775809")));

        assertThat(parser.next(), is(false));
    }
View Full Code Here

                    java.sql.Date sqlDate = new java.sql.Date(cal.getTimeInMillis());
                    ps.setDate(parameterIndex, sqlDate);
                }
                break;
            case DECIMAL:
                DecimalOption decimalOption = (DecimalOption) vo;
                if (decimalOption.isNull()) {
                    ps.setNull(parameterIndex, Types.DECIMAL);
                } else {
                    ps.setBigDecimal(parameterIndex, decimalOption.get());
                }
                break;
            default:
                throw new RuntimeException("Unsupported data type: " + info.getDataType());
            }
View Full Code Here

                    dateOption.modify(days);
                }
                modelClass.getMethod(name, DateOption.class).invoke(model, dateOption);
                break;
            case DECIMAL:
                DecimalOption decimalOption = new DecimalOption();
                BigDecimal bigDecimal = rs.getBigDecimal(columnIndex);
                if (rs.wasNull()) {
                    decimalOption.setNull();
                } else {
                    decimalOption.modify(bigDecimal);
                }
                modelClass.getMethod(name, DecimalOption.class).invoke(model, decimalOption);
                break;
            default:
                throw new RuntimeException("Unsupported data type: " + info.getDataType());
View Full Code Here

        testField(list, "getCDateOption", DATA.DATETIME_DATETIME_FIMT1, dateOption);
        testField(list, "getCDateOption", DATA.DATETIME_DATETIME_FIMT2, dateOption);
        testField(list, "getCDateOption", DATA.STRING_DATETIME, dateOption);

        // C_DECIMAL20_0のテスト
        DecimalOption decimalOption = new DecimalOption();
        testField(list, "getCDecimal200Option", DATA.NUMERIC_0, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_1, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_MINUS1, decimalOption.modify(new BigDecimal(-1)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_MAX, decimalOption.modify(new BigDecimal(999999999999999L)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_MIN, decimalOption.modify(new BigDecimal(-999999999999999L)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_DECIMAL, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.NUMERIC_OVER_MAX, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.NUMERIC_UNDER_MIN, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.NUMERIC_BIG_VALUE, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.STRING_0, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal200Option", DATA.STRING_1, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal200Option", DATA.STRING_MINUS1, decimalOption.modify(new BigDecimal(-1)));
        testField(list, "getCDecimal200Option", DATA.STRING_MAX, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.STRING_MIN, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.STRING_DECIMAL, decimalOption.modify(new BigDecimal("7")));
        testField(list, "getCDecimal200Option", DATA.STRING_OVER_MAX, decimalOption.modify(new BigDecimal("9223372036854775808")));
        testField(list, "getCDecimal200Option", DATA.STRING_UNDER_MIN, decimalOption.modify(new BigDecimal("-9223372036854775809")));
        testField(list, "getCDecimal200Option", DATA.STRING_BIG_VALUE, decimalOption.modify(new BigDecimal("12345678901234567890")));
        testField(list, "getCDecimal200Option", DATA.BLANK, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.NULL_STRING, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.BOOL_TRUE, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal200Option", DATA.BOOL_FALSE, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal200Option", DATA.NUMERIC_DATE, decimalOption.modify(new BigDecimal(40179)));
        testField(list, "getCDecimal200Option", DATA.DATE_DATE_FMT1, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATE_DATE_FMT2, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATE_DATETIME_FIMT1, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATE_DATETIME_FIMT2, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.STRING_DATE, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.NUMERIC_DATETIME, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATETIME_DATE_FMT1, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATETIME_DATE_FMT2, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATETIME_DATETIME_FIMT1, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.DATETIME_DATETIME_FIMT2, decimalOption.setNull());
        testField(list, "getCDecimal200Option", DATA.STRING_DATETIME, decimalOption.setNull());

        // C_DECIMAL10_5のテスト
        testField(list, "getCDecimal255Option", DATA.NUMERIC_0, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_1, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_MINUS1, decimalOption.modify(new BigDecimal(-1)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_MAX, decimalOption.modify(new BigDecimal(999999999999999L)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_MIN, decimalOption.modify(new BigDecimal(-999999999999999L)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_DECIMAL, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.NUMERIC_OVER_MAX, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.NUMERIC_UNDER_MIN, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.NUMERIC_BIG_VALUE, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.STRING_0, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal255Option", DATA.STRING_1, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal255Option", DATA.STRING_MINUS1, decimalOption.modify(new BigDecimal(-1)));
        testField(list, "getCDecimal255Option", DATA.STRING_MAX, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.STRING_MIN, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.STRING_DECIMAL, decimalOption.modify(new BigDecimal("6.54321")));
        testField(list, "getCDecimal255Option", DATA.STRING_OVER_MAX, decimalOption.modify(new BigDecimal("9223372036854775808")));
        testField(list, "getCDecimal255Option", DATA.STRING_UNDER_MIN, decimalOption.modify(new BigDecimal("-9223372036854775809")));
        testField(list, "getCDecimal255Option", DATA.STRING_BIG_VALUE, decimalOption.modify(new BigDecimal("12345678901234567890")));
        testField(list, "getCDecimal255Option", DATA.BLANK, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.NULL_STRING, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.BOOL_TRUE, decimalOption.modify(new BigDecimal(1)));
        testField(list, "getCDecimal255Option", DATA.BOOL_FALSE, decimalOption.modify(new BigDecimal(0)));
        testField(list, "getCDecimal255Option", DATA.NUMERIC_DATE, decimalOption.modify(new BigDecimal(40179)));
        testField(list, "getCDecimal255Option", DATA.DATE_DATE_FMT1, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATE_DATE_FMT2, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATE_DATETIME_FIMT1, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATE_DATETIME_FIMT2, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.STRING_DATE, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.NUMERIC_DATETIME, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATETIME_DATE_FMT1, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATETIME_DATE_FMT2, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATETIME_DATETIME_FIMT1, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.DATETIME_DATETIME_FIMT2, decimalOption.setNull());
        testField(list, "getCDecimal255Option", DATA.STRING_DATETIME, decimalOption.setNull());
    }
View Full Code Here

        case Cell.CELL_TYPE_FORMULA:
        default:
            String msg = createCellTypeMismatchExceptionMsg(cell, "DECIMAL");
            throw new CellTypeMismatchException(msg);
        }
        DecimalOption decimalOption = new DecimalOption();
        decimalOption.modify(bigDecimal);
        return decimalOption;
    }
View Full Code Here

        testGetXXXOptionDo(excelUtils, sheet, DATA.FORMULA, TYPES.DATETIME, new CellTypeMismatchException("日付"));


        // getDecimalOptionのテスト

        DecimalOption decimalOption = new DecimalOption();
        decimalOption.modify(new BigDecimal("0"));
        testGetXXXOptionDo(excelUtils, sheet,  DATA.NUMERIC_0, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("1"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_1, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("-1"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_MINUS1, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("999999999999999"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_MAX, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("-999999999999999"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_MIN, TYPES.DECIMAL, decimalOption);
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_DECIMAL, TYPES.DECIMAL, new NumberFormatException("小数部を持つ実数をDECIMALに変換できません。"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_OVER_MAX, TYPES.DECIMAL, new NumberFormatException("表現可能な範囲外の数値"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_UNDER_MIN, TYPES.DECIMAL, new NumberFormatException("表現可能な範囲外の数値"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_BIG_VALUE, TYPES.DECIMAL, new NumberFormatException("表現可能な範囲外の数値"));
        decimalOption.modify(new BigDecimal("0"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_0, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("1"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_1, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("-1"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_MINUS1, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("6.54321"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_DECIMAL, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("9223372036854775808"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_OVER_MAX, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("-9223372036854775809"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_UNDER_MIN, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("12345678901234567890"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.STRING_BIG_VALUE, TYPES.DECIMAL, decimalOption);
        decimalOption.setNull();
        testGetXXXOptionDo(excelUtils, sheet, DATA.BLANK, TYPES.DECIMAL, decimalOption);
        longOption.setNull();
        testGetXXXOptionDo(excelUtils, sheet, DATA.NULL_STRING, TYPES.DECIMAL, new NumberFormatException("DECIMALに変換できない文字列"));
        decimalOption.modify(new BigDecimal("1"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.BOOL_TRUE, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("0"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.BOOL_FALSE, TYPES.DECIMAL, decimalOption);
        decimalOption.modify(new BigDecimal("40179"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.NUMERIC_DATE, TYPES.DECIMAL, decimalOption);
        testGetXXXOptionDo(excelUtils, sheet, DATA.DATE_DATE_FMT1, TYPES.DECIMAL, new CellTypeMismatchException("DECIMAL"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.DATE_DATE_FMT2, TYPES.DECIMAL, new CellTypeMismatchException("DECIMAL"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.DATE_DATETIME_FIMT1, TYPES.DECIMAL, new CellTypeMismatchException("DECIMAL"));
        testGetXXXOptionDo(excelUtils, sheet, DATA.DATE_DATETIME_FIMT2, TYPES.DECIMAL, new CellTypeMismatchException("DECIMAL"));
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.DecimalOption$DecimalBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.