Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.ShortOption


        super(TypeInfoFactory.shortTypeInfo);
    }

    @Override
    protected ValueOption<?> newObject() {
        return new ShortOption();
    }
View Full Code Here


        return new ShortOption();
    }

    @Override
    public Object getPrimitiveJavaObject(Object o) {
        ShortOption object = (ShortOption) o;
        if (object == null || object.isNull()) {
            return null;
        }
        return object.get();
    }
View Full Code Here

        return object.get();
    }

    @Override
    public Object getPrimitiveWritableObject(Object o) {
        ShortOption object = (ShortOption) o;
        if (object == null || object.isNull()) {
            return null;
        }
        return new ShortWritable(object.get());
    }
View Full Code Here

     * shortの値を解析するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void fillShort() throws Exception {
        ShortOption value = new ShortOption();
        create("short");

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is((short) 0));
        parser.fill(value);
        assertThat(value.get(), is((short) 10));
        parser.fill(value);
        assertThat(value.get(), is((short) -10));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Short.MAX_VALUE));
        parser.fill(value);
        assertThat(value.get(), is(Short.MIN_VALUE));
        parser.endRecord();

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

     * test for short values.
     * @throws Exception if failed
     */
    @Test
    public void short_values() throws Exception {
        assertRestorable(new ShortOption((short) 0));
        assertRestorable(new ShortOption((short) 1));
        assertRestorable(new ShortOption((short) -1));
        assertRestorable(new ShortOption((short) 50));
        assertRestorable(new ShortOption((short) -50));
        assertRestorable(new ShortOption(Short.MAX_VALUE));
        assertRestorable(new ShortOption(Short.MIN_VALUE));
        assertRestorable(new ShortOption());
    }
View Full Code Here

    @Test
    public void short_values() throws Exception {
        CsvParser parser = create("0,1,50,-1,-50,"
                + Short.MAX_VALUE + ","
                + Short.MIN_VALUE + ", 0,0 ,");
        ShortOption option = new ShortOption();

        assertThat(parser.next(), is(true));

        parser.fill(option);
        assertThat(option.get(), is((short) 0));

        parser.fill(option);
        assertThat(option.get(), is((short) 1));

        parser.fill(option);
        assertThat(option.get(), is((short) 50));

        parser.fill(option);
        assertThat(option.get(), is((short) -1));

        parser.fill(option);
        assertThat(option.get(), is((short) -50));

        parser.fill(option);
        assertThat(option.get(), is(Short.MAX_VALUE));

        parser.fill(option);
        assertThat(option.get(), is(Short.MIN_VALUE));

        parser.fill(option);
        assertThat(option.get(), is((short) 0));

        parser.fill(option);
        assertThat(option.get(), is((short) 0));

        parser.fill(option);
        assertThat(option.isNull(), is(true));

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

    @Test
    public void invalid_short() throws Exception {
        CsvParser parser = create(String.valueOf(Short.MAX_VALUE + 1));
        assertThat(parser.next(), is(true));
        try {
            parser.fill(new ShortOption());
            fail();
        } catch (CsvFormatException e) {
            assertThat(e.getStatus().getReason(), is(Reason.INVALID_CELL_FORMAT));
        }
    }
View Full Code Here

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

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

        value.setNull();
        emitter.emit(value);
        value.modify(Short.MAX_VALUE);
        emitter.emit(value);
        value.modify(Short.MIN_VALUE);
        emitter.emit(value);
        emitter.endRecord();

        emitter.close();

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

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Short.MAX_VALUE));
        parser.fill(value);
        assertThat(value.get(), is(Short.MIN_VALUE));

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

                } else {
                    ps.setInt(parameterIndex, intOption.get());
                }
                break;
            case SMALL_INT:
                ShortOption shortOption = (ShortOption) vo;
                if (shortOption.isNull()) {
                    ps.setNull(parameterIndex, Types.SMALLINT);
                } else {
                    ps.setInt(parameterIndex, shortOption.get());
                }
                break;
            case TINY_INT:
                ByteOption byteOption = (ByteOption) vo;
                if (byteOption.isNull()) {
View Full Code Here

                    intOption.modify(i);
                }
                modelClass.getMethod(name, IntOption.class).invoke(model, intOption);
                break;
            case SMALL_INT:
                ShortOption shortOption = new ShortOption();
                short sv = rs.getShort(columnIndex);
                if (rs.wasNull()) {
                    shortOption.setNull();
                } else {
                    shortOption.modify(sv);
                }
                modelClass.getMethod(name, ShortOption.class).invoke(model, shortOption);
                break;
            case TINY_INT:
                ByteOption byteOption = new ByteOption();
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.ShortOption

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.