view src/main/java/alice/jungle/operations/NetworkPutAttributeOperation.java @ 190:269bada9eedc

add
author tatsuki
date Fri, 17 Oct 2014 15:16:56 +0900
parents 2828205bdc3a
children 5d0734fd859d
line wrap: on
line source

package alice.jungle.operations;

import java.nio.ByteBuffer;

import org.msgpack.annotation.Message;

import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.LoggingNode;
@Message
public class NetworkPutAttributeOperation  implements NodeOperation
{
	
/*  MessagePack cannot handle final.
 *
 *	private final String key;
 *	private final ByteBuffer value;
 */
	public String key;
	public ByteBuffer value;
	
	public NetworkPutAttributeOperation()
	{
		key = null;
		value = null;
	}
	
	public NetworkPutAttributeOperation(String _key,ByteBuffer _value)
	{
		key = _key;
		value = _value;
	}
	
	@Override
	public Command getCommand()
	{
		return Command.PUT_ATTRIBUTE;
	}
	
	@Override
	public Either<Error, TreeNode> invoke(TreeNode _target)
	{
		return _target.getAttributes().put(key,value);
	}

	@Override
	public int getPosition()
	{
		return -1;
	}

	@Override
	public String getKey()
	{
		return key;
	}

	@Override
	public ByteBuffer getValue()
	{
		return value;
	}
}