view src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/operations/PutAttributeOperation.java @ 78:540a27dde42f

Delete EnableNode and EnableNodeWrapper but not repair test program
author one
date Sun, 31 Aug 2014 00:44:35 +0900
parents 4ff16d970ffc
children 715a9fbf02fc
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations;

import java.nio.ByteBuffer;

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.trasnformer.PutAttribute;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;

public class PutAttributeOperation implements NodeOperation
{
	private final String key;
	private final ByteBuffer value;
	
	public PutAttributeOperation(String _key,ByteBuffer _value)
	{
		key = _key;
		value = _value;
	}
	
	@Override
	public Command getCommand()
	{
		return Command.PUT_ATTRIBUTE;
	}
	
	@Override
	public <T extends TreeNode<T>> Either<Error,T> invoke(T _target)
	{
		PutAttribute putAttribute = new PutAttribute(key,value);
		return putAttribute.edit(_target);
	}

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

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

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