Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.LongOption


        output.close();

        DataModelReader<Object> reader = support.createReader("testing", new ByteArrayInputStream(output.toByteArray()));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new LongOption(1)));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new LongOption(2)));
        assertThat(reader.readTo(buffer.unwrap()), is(false));
    }
View Full Code Here


        super(TypeInfoFactory.longTypeInfo);
    }

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

        return new LongOption();
    }

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

        return object.get();
    }

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

        MockSimple in = new MockSimple(100, "Hello, world!");
        File file = save(f1, Arrays.asList(in));
        List<MockSimpleWithLong> results = load(f2, file);
        assertThat(results, hasSize(1));
        MockSimpleWithLong out = results.get(0);
        assertThat(out.number, is(new LongOption()));
        assertThat(out.string, is(in.string));
    }
View Full Code Here

        ModelInput<Object> reader = support.createInput(model.unwrap().getClass(), "testing", in(output),
                0, size(output));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new LongOption(1)));
        assertThat(reader.readTo(buffer.unwrap()), is(true));
        assertThat(buffer.getOption("value"), is((Object) new StringOption("Hello\nworld!")));
        assertThat(buffer.getOption("number"), is((Object) new LongOption(2)));
        assertThat(reader.readTo(buffer.unwrap()), is(false));
    }
View Full Code Here

        assertThat(union.getPosition(), is(1));
        ((StringOption) union.switchObject(2)).modify("Hello, world!");
        assertThat(union.getPosition(), is(2));

        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     */
    @Test
    public void createFromObject() throws Exception {
        Union union = new WritableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));
        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     */
    @Test
    public void serialize() throws Exception {
        WritableUnion union = new WritableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"),
                new StringOption());

        StringBuilder buf = new StringBuilder(100000);
        for (int i = 0, n = buf.capacity(); i < n; i++) {
            buf.append((char) ('A' + (i * 257 % 26)));
        }
        ((StringOption) union.switchObject(3)).modify(buf.toString());

        WritableUnion r0 = new WritableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(0);
        byte[] s0 = ser(union);
        des(r0, s0);
        assertThat(r0.getPosition(), is(0));
        assertThat(r0.getObject(), is((Object) new IntOption(100)));

        WritableUnion r1 = new WritableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(1);
        byte[] s1 = ser(union);
        des(r1, s1);
        assertThat(r1.getPosition(), is(1));
        assertThat(r1.getObject(), is((Object) new LongOption(200L)));

        WritableUnion r2 = new WritableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(2);
        byte[] s2 = ser(union);
        des(r2, s2);
View Full Code Here

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

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

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

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

TOP

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

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.