view Main/jungle-network/operations/NetworkTreeOperation.cs @ 35:f2ea780b3e80

fix
author Kazuma Takeda
date Wed, 22 Feb 2017 16:30:19 +0900
parents 1f99e150f336
children
line wrap: on
line source

using System.Collections;

namespace JungleDB {
	public class NetworkTreeOperation : TreeOperation {

		public NetworkNodePath Path;
		public NetworkNodeOperation Operation;

		public NetworkTreeOperation (TreeOperation tOp) {
			this.Path = new NetworkNodePath(tOp.getNodePath());
			this.Operation = new NetworkNodeOperation(tOp.getNodeOperation());
		}

		public NetworkTreeOperation(NodePath path, NodeOperation op) {
			this.Path = new NetworkNodePath(path);
			this.Operation = new NetworkNodeOperation(op);
		}

		public NetworkTreeOperation(NetworkNodePath path, NodeOperation op) {
			this.Path = path;
			this.Operation = new NetworkNodeOperation(op);
		}

		public NetworkTreeOperation(NodePath path, NetworkNodeOperation op) {
			this.Path = new NetworkNodePath(path);
			this.Operation = op;
		}

		public NetworkTreeOperation(NetworkNodePath path, NetworkNodeOperation op) {
			this.Path = path;
			this.Operation = op;
		}

		public NodePath getNodePath () {
			return this.Path;
		}

		public NodeOperation getNodeOperation() {
			Command c = this.Operation.getCommand();
			switch(c){
			case Command.PUT_ATTRIBUTE:
				return new PutAttributeOperation(Operation.getKey(), Operation.getValue());
			case Command.APPEND_CHILD:
				return new AppendChildAtOperation(Operation.getPosition());
			case Command.DELETE_CHILD:
				return new DeleteChildAtOperation(Operation.getPosition());
			case Command.DELETE_ATTRIBUTE:
				return new DeleteAttributeOperation(Operation.getKey());
			default:
				break;
			}
			return null;
		}
	}
}