view test/mergertest/RemoteEditorSimulator.java @ 471:d2762d669617

sleep command to wait for singleton prevention
author one
date Tue, 12 Oct 2010 10:19:59 +0900
parents 5c95a9020e31
children
line wrap: on
line source

package test.mergertest;

import java.util.List;

import rep.REP;
import rep.REPCommand;
import test.editortest.Logger;
import test.editortest.REPText;

public class RemoteEditorSimulator {

	private REPText repText;
	private int eid;
	
	public RemoteEditorSimulator(int eid){
		this.eid = eid;
		repText = new REPTextWithLinkedList();
	}

	public void edit(REPCommand command) {
		Logger.print(command);
		if(command.cmd == REP.REPCMD_INSERT_USER){
			repText.insert(command.lineno, command.string);
		}else if(command.cmd == REP.REPCMD_DELETE_USER){
			repText.delete(command.lineno);
		}
	}

	public int getEID() {
		return eid;
	}

	public void display() {
		List<String> list = repText.list();
		System.out.println();
		System.out.println("---------- Editor" + eid + " ----------");
		for(String str : list){
			System.out.println(str);
		}
	}

}