view src/main/java/alice/datasegment/ReceiveLocalData.java @ 443:2f2623484b77 dispose

change protocol
author sugi
date Sat, 18 Oct 2014 19:30:13 +0900
parents aefbe41fcf12
children
line wrap: on
line source

package alice.datasegment;

import java.io.IOException;

import org.msgpack.type.Value;

import alice.codesegment.SingletonMessage;
import alice.datasegment.ReceiverData;

public class ReceiveLocalData implements ReceiverData {
    private Object obj;

    public ReceiveLocalData(Object obj) {
        this.obj = obj;
    }

    public String asString() {
        return (String) obj;
    }

    public int asInteger() {
        return (Integer) obj;
    }

    public Float asFloat() {
        return (Float) obj;
    }

    @SuppressWarnings("unchecked")
    public <T> T asClass(Class<T> clazz) {
        return (T) obj;

    }

    public Value getVal() {
        try {
            return SingletonMessage.getInstance().unconvert(obj);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public Object getObj() {
        return obj;
    }

}