Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.ByteOption


        super(TypeInfoFactory.byteTypeInfo);
    }

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


        return new ByteOption();
    }

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

        return object.get();
    }

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

     * @throws Exception if failed
     */
    @Test
    public void byte_values() throws Exception {
        CsvParser parser = create("0,1,50,-1,-50,127,-128, 0,0 ,");
        ByteOption option = new ByteOption();

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

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

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

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

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

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

        parser.fill(option);
        assertThat(option.get(), is((byte) 127));

        parser.fill(option);
        assertThat(option.get(), is((byte) -128));

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

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

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

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

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

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

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

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

        emitter.close();

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

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

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

     * test for byte values.
     * @throws Exception if failed
     */
    @Test
    public void byte_values() throws Exception {
        assertRestorable(new ByteOption((byte) 0));
        assertRestorable(new ByteOption((byte) 1));
        assertRestorable(new ByteOption((byte) -1));
        assertRestorable(new ByteOption((byte) 50));
        assertRestorable(new ByteOption((byte) -50));
        assertRestorable(new ByteOption(Byte.MAX_VALUE));
        assertRestorable(new ByteOption(Byte.MIN_VALUE));
        assertRestorable(new ByteOption());
    }
View Full Code Here

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

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

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

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

                } else {
                    ps.setInt(parameterIndex, shortOption.get());
                }
                break;
            case TINY_INT:
                ByteOption byteOption = (ByteOption) vo;
                if (byteOption.isNull()) {
                    ps.setNull(parameterIndex, Types.TINYINT);
                } else {
                    ps.setByte(parameterIndex, byteOption.get());
                }
                break;
            case CHAR:
                StringOption charStringOption = (StringOption) vo;
                if (charStringOption.isNull()) {
View Full Code Here

                    shortOption.modify(sv);
                }
                modelClass.getMethod(name, ShortOption.class).invoke(model, shortOption);
                break;
            case TINY_INT:
                ByteOption byteOption = new ByteOption();
                Byte b = rs.getByte(columnIndex);
                if (rs.wasNull()) {
                    byteOption.setNull();
                } else {
                    byteOption.modify(b);
                }
                modelClass.getMethod(name, ByteOption.class).invoke(model, byteOption);
                break;
            case CHAR:
            case VARCHAR:
View Full Code Here

TOP

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

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.