changeset 64:403272ec470c

*** empty log message ***
author pin
date Fri, 02 Nov 2007 17:03:17 +0900
parents 023c20cd07ef
children b1710c49c883
files bin/remoteeditor/editors/RemoteEditor$1.class bin/remoteeditor/editors/RemoteEditor.class bin/remoteeditor/network/REP.class src/remoteeditor/command/REPCommand.java src/remoteeditor/editors/RemoteEditor.java src/remoteeditor/network/REP.java src/remoteeditor/network/REPPacketSend.java src/remoteeditor/ui/REPSelectWindow.java src/sample/merge/TestEditor.java src/sample/merge/TestTranslate.java src/sample/merge/TestTranslate2.java src/sample/merge/Translate.java
diffstat 12 files changed, 118 insertions(+), 325 deletions(-) [+]
line wrap: on
line diff
Binary file bin/remoteeditor/editors/RemoteEditor$1.class has changed
Binary file bin/remoteeditor/editors/RemoteEditor.class has changed
Binary file bin/remoteeditor/network/REP.class has changed
--- a/src/remoteeditor/command/REPCommand.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/remoteeditor/command/REPCommand.java	Fri Nov 02 17:03:17 2007 +0900
@@ -1,6 +1,9 @@
 package remoteeditor.command;
 
+import remoteeditor.network.REP;
+
 public class REPCommand {
+	public static REPCommand SMCMD_SESSION_JOIN = new REPCommand(REP.SMCMD_SM_JOIN, 0, 0, 0, 0, 0, "");
 	public int cmd;
 	public int sid;
 	public int eid;
@@ -11,6 +14,8 @@
 	
 	public  String string;
 	private int textsiz;
+	String host;
+	String port;
 	
 	public REPCommand(int cmd,int sid,int eid, int seq, int lineno, int textsiz, String string) {
 		this.cmd = cmd;
@@ -26,4 +31,35 @@
 		String repCmdString = new String(cmd + "," + sid + "," + eid + "," + seq + "," + lineno + "," + textsiz + "," + string);
 		return repCmdString;
 	}
+
+	public void setEID(int eid2) {
+		// TODO Auto-generated method stub
+		this.eid = eid2;
+	}
+
+	public void setCMD(int cmd2) {
+		// TODO Auto-generated method stub
+		this.cmd = cmd2;
+	}
+
+	public void setSID(int sessionID) {
+		// TODO Auto-generated method stub
+		this.sid = sessionID;
+	}
+
+	public void setString(String string2) {
+		// TODO Auto-generated method stub
+		string = string2;
+	}
+
+	public void setHost(String host) {
+		// TODO Auto-generated method stub
+		this.host = host;
+	}
+
+	public void setPort(String port) {
+		// TODO Auto-generated method stub
+		this.port = port;
+	}
+
 }
--- a/src/remoteeditor/editors/RemoteEditor.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/remoteeditor/editors/RemoteEditor.java	Fri Nov 02 17:03:17 2007 +0900
@@ -3,7 +3,10 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.nio.channels.SocketChannel;
+import java.util.Enumeration;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -130,13 +133,13 @@
 		}
 		if(numberOfLinesNew > numberOfLinesOld){
 			//insert, delete, replace を 行数で判断
-			cmd = REP.REP_INSERT_CMD;
+			cmd = REP.REPCMD_INSERT;
 			lineText = "\n";
 			//line += 1;
 		}else if(numberOfLinesNew == numberOfLinesOld){
-			cmd = REP.REP_REPLACE_CMD;
+			cmd = REP.REPCMD_REPLACE;
 		}else {
-			cmd = REP.REP_DELETE_CMD;
+			cmd = REP.REPCMD_DELETE;
 		}
 		//rep.sendCmd(cmd, line, length, lineText);
 		if(!lock){
@@ -186,17 +189,17 @@
 	
 	public void joinPart(){
 		//String string = "test.txt";
-		repsend.send(new REPCommand(REP.REP_JOIN_CMD, 0, 0, 0, 0, 0, ""));
+		repsend.send(new REPCommand(REP.SMCMD_JOIN, 0, 0, 0, 0, 0, ""));
 	}
 	
 	public void putPart(){
 		if(this.getEditorInput() != null) filename = this.getEditorInput().getName();
-		repsend.send(new REPCommand(REP.REP_PUT_CMD, mysid, myeid, myseq, 0, filename.length(), filename));
+		repsend.send(new REPCommand(REP.SMCMD_PUT, mysid, myeid, myseq, 0, filename.length(), filename));
 	}
 	
 	
 	public void selectPart(){
-		repsend.send(new REPCommand(REP.REP_SELECT_CMD, mysid, myeid, myseq, 0, 0, ""));
+		repsend.send(new REPCommand(REP.SMCMD_SELECT, mysid, myeid, myseq, 0, 0, ""));
 	}
 
 	public void CommandReceived(REPCommandEvent event) {
@@ -212,33 +215,33 @@
 
 	private void commandManager(REPCommand command) {
 		switch(command.cmd){
-		case REP.REP_JOIN_ACK_CMD:
+		case REP.SMCMD_JOIN_ACK:
 			myeid = command.eid;
 			trans.myeid = myeid;
 			putPart();
 			break;
-		case REP.REP_PUT_ACK_CMD:
+		case REP.SMCMD_PUT_ACK:
 			//mysid = command.sid;
 			//selectPart();
 			break;
-		case REP.REP_SELECT_ACK_CMD:
+		case REP.SMCMD_SELECT_ACK:
 			mysid = command.sid;
 			break;
-		case REP.REP_INSERT_CMD:
+		case REP.REPCMD_INSERT:
 			try {
 					textInsert(command.lineno, command.len, command.string);
 				} catch (Exception e) {
 					e.printStackTrace();
 				}
 			break;
-		case REP.REP_REPLACE_CMD:
+		case REP.REPCMD_REPLACE:
 			try {
 					changeText(command.cmd, command.lineno, command.len, command.string);
 				} catch (Exception e1) {
 					e1.printStackTrace();
 				}
 			break;
-		case REP.REP_DELETE_CMD:
+		case REP.REPCMD_DELETE:
 			try {
 					textDelete(command.lineno, command.len, command.string);
 				} catch (BadLocationException e1) {
@@ -302,7 +305,7 @@
 			int offset = document.getLineOffset(i);
 			int length = document.getLineLength(i);
 			String text = document.get(offset, length);
-			repsend.send(new REPCommand(REP.REP_INSERT_CMD, mysid, myeid, myseq, i, text.length(), text));
+			repsend.send(new REPCommand(REP.REPCMD_INSERT, mysid, myeid, myseq, i, text.length(), text));
 		}
 	}
 }
--- a/src/remoteeditor/network/REP.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/remoteeditor/network/REP.java	Fri Nov 02 17:03:17 2007 +0900
@@ -1,288 +1,37 @@
 package remoteeditor.network;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-
-import sample.merge.Rep_Cmd;
-import sample.merge.Translate;
-
-
-
-public class REP implements Runnable{
-	
-	SocketChannel sc;
-	int cmd;
-	int eid;
-	int eid2;
-	int lineno;
-	int sid;
-	int seqid;
-	int textsiz;
-	
-
+public class REP {
+    public static final int REPCMD_OPEN		= 1;
+    public static final int REPCMD_OPEN_ACK	= 2;
     public static final int REPCMD_READ		= 3;
     public static final int REPCMD_READ_ACK	= 4;
-	public static final int REP_INSERT_CMD = 6;
-	public static final int REP_INSERT_ACK_CMD = 7;
-	public static final int REP_DELETE_CMD = 9;
-	public static final int REP_DELETE_ACK_CMD = 10;	
-	public static final int REP_REPLACE_CMD = 13;
-	public static final int REP_REPLACE_ACK_CMD = 14;	
-	public static final int REP_JOIN_CMD = 41;
-	public static final int REP_JOIN_ACK_CMD = 42;
-	public static final int REP_PUT_CMD = 45;
-	public static final int REP_PUT_ACK_CMD = 46;
-	public static final int REP_SELECT_CMD = 47;
-	public static final int REP_SELECT_ACK_CMD = 48;
-	public static final int REP_QUIT_CMD = 53;
-	public static final int REP_QUIT_ACK_CMD = 54;
-	
-    static final int HEADER_SIZE = 24;
-	
-	String string;
-	public RSocketListener socketListener;
-	Shell shell;
-	
-	List <Rep_Cmd> myCmdList = new LinkedList<Rep_Cmd>();
-	List <Rep_Cmd> othersCmdList = new LinkedList<Rep_Cmd>();
-	private String filename;
-	
-	public REP() {
-		String host = "localhost";
-		int port = 8765;
-		
-		InputDialog dialog = new InputDialog(shell, "REP", "host", "localhost", null);
-		if(dialog.open() == Window.OK){
-			host = dialog.getValue();
-		}
-		
-		dialog = new InputDialog(shell, "REP", "port", "8765", null);
-		if (dialog.open() == Window.OK) {
-			try {
-				port = Integer.parseInt(dialog.getValue());
-			} catch (NumberFormatException x) {
-			}
-		}
-		
-		
-		InetSocketAddress addr = new InetSocketAddress(host, port);
-		try {
-			sc = SocketChannel.open();
-
-		sc.configureBlocking(true);
-		sc.connect(addr);
-		while(!sc.finishConnect()){
-			System.out.println("afro");
-		}
-		join();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		
-		dialog = new InputDialog(shell, "repput", "read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string, "hugo", null);
-		if(dialog.open() == Window.OK){
-			filename = dialog.getValue();
-			put();
-		}
-		
-		dialog = new InputDialog(shell, "repselect", "read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string ,Integer.toString(sid), null);
-		if(dialog.open() == Window.OK){
-			try {
-				sid = (byte) Integer.parseInt(dialog.getValue());
-			} catch (NumberFormatException x) {
-			}
-			select();
-		}
-	}
-	
-	public void join() {
-		rWrite(pack( REP_JOIN_CMD, sid, eid, seqid, lineno, "afro"));
-		unpack();
-		eid2 = eid;
-		System.out.println("read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string);
-	}
-	
-	public void put() {
-		rWrite(pack(REP_PUT_CMD, sid, eid, seqid, lineno, filename));
-		unpack();
-		System.out.println("read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string);
-	}
-	
-	public void select() {
-		rWrite(pack(REP_SELECT_CMD, sid, eid, seqid, lineno, "afro"));
-		unpack();
-		System.out.println("read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string);
-	}
-	
-/*	public void insert(int offset, int length, String text)  {
-		cmd = REP_INSERT_CMD;
-		seqid = (byte)offset;
-		try {
-			sc.write(pack(cmd, sid, eid, seqid, lineno, text));
-		} catch (IOException e1) {
-			e1.printStackTrace();
-		}
-		try {
-			myCmdList.add(new Rep_Cmd(cmd, sid, eid, seqid, lineno, length, text));
-			System.out.println("myCmdList : " + myCmdList.toString());
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public void replace(int offset, int length, String text) throws IOException {
-		cmd = REP_REPLACE_CMD;
-		seqid = (byte)offset;
-		sc.write(pack(cmd, sid, eid, seqid, lineno, text));
-		try {
-			myCmdList.add(new Rep_Cmd(cmd, sid, eid, seqid, lineno, length, text));
-			System.out.println("myCmdList : " + myCmdList.toString());
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	public void delete(int offset, int length, String text) throws IOException {
-		cmd = REP_DELETE_CMD;
-		seqid = (byte)offset;
-		sc.write(pack(cmd, sid, eid, seqid, lineno, text));
-		try {
-			myCmdList.add(new Rep_Cmd(cmd, sid, eid, seqid, lineno, length, text));
-			System.out.println("myCmdList : " + myCmdList.toString());
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}*/
-	
-    public ByteBuffer pack(int cmd, int sid, int eid, int seqid, int lineno, String text ) {	
-    	
-    	ByteBuffer buffer = ByteBuffer.allocateDirect(24+text.length()*2);
-    	buffer.clear();  // position = 0 
-    	buffer.putInt(cmd); buffer.putInt(sid); buffer.putInt(eid2);
-    	buffer.putInt(seqid); buffer.putInt(lineno); 
-    	buffer.putInt(text.length()*2); 
-    	//buffer.putString(text);
-    	//System.out.println("pack:" + cmd +", "+ "length="+ text.length() +" "+ sid +", "+ eid +", "+ seqid +", "+ lineno);
-    	
-    	for(int i=0;i<text.length();i++) {
-			buffer.putChar(text.charAt(i));
-		}	
-    	buffer.flip();    // limit = current position, position = 0
-    	return buffer;
-    }
-    
-	public void unpack() {
-		ByteBuffer header = ByteBuffer.allocateDirect(HEADER_SIZE);
-		long len = 0;
-		header.clear();
-		try {
-			len = sc.read(header);
-		} catch (IOException e1) {
-			e1.printStackTrace();
-		}  // limit = read length
-		if (len !=HEADER_SIZE) {
-			System.out.println("てす");
-			// this can't happen
-		}
-		header.rewind();  // position = 0
-		/*for(int i = 0; i < 24; i++){
-			readbyte[i] = header.get();
-			//System.out.println(readbyte[i]);
-		}*/
-		String text = "";
-		cmd = header.getInt();
-		sid = header.getInt();
-		eid = header.getInt();
-		seqid = header.getInt();
-		lineno = header.getInt();
-		textsiz = header.getInt()/2;
-		
-		ByteBuffer textBuffer = ByteBuffer.allocateDirect(textsiz*2);
-		//buffer.limit(textsiz*2);
-		//buffer.rewind();
-		try {
-			len = sc.read(textBuffer);
-		} catch (IOException e1) {
-			e1.printStackTrace();
-		}  // limit = read length
-		if (len !=HEADER_SIZE) {
-			// this can't happen
-		}
-		textBuffer.rewind();
-		for(int i=0;i<textsiz;i++) {
-			text +=textBuffer.getChar();
-		}
-		string = text;
-		try {
-			if(eid2 != eid) othersCmdList.add(new Rep_Cmd(cmd, sid, eid, seqid, lineno, textsiz, text));
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public void addSocketListener(RSocketListener socketListener){
-		Thread th = new Thread(this);
-		th.start();
-		this.socketListener = socketListener;
-	}
-
-	public void run() {
-		while(sc.isConnected()){
-				unpack();
-			System.out.println("read packet:" + cmd +", "+ sid +", "+ eid +", "+ seqid +", "+ lineno +", "+ textsiz +", "+ string);
-			for(Rep_Cmd othersCmd:othersCmdList){
-				socketListener.packetReceived(new RSocketEvent(othersCmd.cmd, othersCmd.sid, othersCmd.eid, othersCmd.seq, othersCmd.lineno, othersCmd.string.length(), othersCmd.string));
-				othersCmdList.remove(othersCmd);
-			}
-			//socketListener.packetReceived(new RSocketEvent(cmd, sid, eid, seqid, lineno, textsiz, string)); //
-		}	
-		
-	}
-	public void rRead(ByteBuffer buffer){
-		try {
-			sc.read(buffer);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	public void rWrite(ByteBuffer buffer){
-		try {
-			sc.write(buffer);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	public void dispose() {
-		try {
-			sc.close();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public void sendCmd(int cmd2, int line, int length, String lineText) {
-		//cmd = REP_INSERT_CMD;
-		//rWrite(pack(cmd2, sid, eid, seqid, line, lineText));
-		try {
-			myCmdList.add(new Rep_Cmd(cmd2, sid, eid, seqid, line, length, lineText));
-			//System.out.println("myCmdList : " + myCmdList.toString());
-			//System.out.println("othersCmdList : " + othersCmdList.toString());
-			//new Translate(myCmdList, othersCmdList);
-			for(Rep_Cmd userCmd:myCmdList){
-				rWrite(pack(userCmd.cmd, userCmd.sid, userCmd.eid, userCmd.seq, userCmd.lineno, userCmd.string));
-				myCmdList.remove(userCmd);
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
+    public static final int REPCMD_INSERT	= 6;
+    public static final int REPCMD_INSERT_ACK	= 7;
+    public static final int REPCMD_DELETE	= 9;
+    public static final int REPCMD_DELETE_ACK	= 10;
+    public static final int REPCMD_CLOSE	= 11;
+    public static final int REPCMD_CLOSE_ACK	= 12;
+    public static final int REPCMD_REPLACE	= 13;
+    public static final int REPCMD_REPLACE_ACK	= 14;
+    public static final int SMCMD_JOIN		= 41;
+    public static final int SMCMD_JOIN_ACK	= 42;
+    public static final int SMCMD_GET		= 43;
+    public static final int SMCMD_GET_ACK	= 44;
+    public static final int SMCMD_PUT		= 45;
+    public static final int SMCMD_PUT_ACK	= 46;
+    public static final int SMCMD_SELECT	= 47;
+    public static final int SMCMD_SELECT_ACK	= 48;
+    public static final int SMCMD_REGISTER	= 49;
+    public static final int SMCMD_REGISTER_ACK	= 50;
+    public static final int SMCMD_DEREGISTER	= 51;
+    public static final int SMCMD_DEREGISTER_ACK= 52;
+    public static final int SMCMD_QUIT		= 53;
+    public static final int SMCMD_QUIT_ACK	= 54;
+    public static final int SMCMD_SESSION   = 60;
+    public static final int SMCMD_SESSION_ACK    = 61;
+	public static final int SMCMD_SM_JOIN   = 62;
+	public static final int SMCMD_SM_JOIN_ACK = 63;
+	public static final int SMCMD_UPDATE = 65;
+	public static final int SMCMD_UPDATE_ACK = 66;
 
 }
--- a/src/remoteeditor/network/REPPacketSend.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/remoteeditor/network/REPPacketSend.java	Fri Nov 02 17:03:17 2007 +0900
@@ -14,6 +14,7 @@
 	}
 	
 	public ByteBuffer pack(REPCommand command){
+		command.setString(command.string + ":temp:123456");	//あとで書き直す
     	System.out.println("send command: " + command.toString());
     	ByteBuffer buffer = ByteBuffer.allocateDirect(24+(command.string).length()*2);
     	buffer.clear();  // position = 0 
@@ -34,4 +35,8 @@
 			e.printStackTrace();
 		}
 	}
+
+	public SocketChannel getChannel() {
+		return socketchannel;		
+	}
 }
--- a/src/remoteeditor/ui/REPSelectWindow.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/remoteeditor/ui/REPSelectWindow.java	Fri Nov 02 17:03:17 2007 +0900
@@ -107,11 +107,11 @@
 	}
 
 	private void select() {
-		repsend.send(new REPCommand(REP.REP_SELECT_CMD, mysid, myeid, myseq, 0, 0, ""));
+		repsend.send(new REPCommand(REP.SMCMD_SELECT, mysid, myeid, myseq, 0, 0, ""));
 	}
 
 	private void put() {
-		repsend.send(new REPCommand(REP.REP_PUT_CMD, mysid, myeid, myseq, 0, filename.length(), filename));
+		repsend.send(new REPCommand(REP.SMCMD_PUT, mysid, myeid, myseq, 0, filename.length(), filename));
 		command = repreceive.unpack();
 		mysid = command.sid;
 	}
@@ -131,7 +131,7 @@
 		repsend = new REPPacketSend(sc);
 	}
 	public void join(){
-		repsend.send(new REPCommand(REP.REP_JOIN_CMD, 0, 0, 0, 0, 0, ""));
+		repsend.send(new REPCommand(REP.SMCMD_JOIN, 0, 0, 0, 0, 0, ""));
 		command = repreceive.unpack();
 		myeid = command.eid;
 		//System.out.println(command.toString());
--- a/src/sample/merge/TestEditor.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/sample/merge/TestEditor.java	Fri Nov 02 17:03:17 2007 +0900
@@ -52,7 +52,7 @@
 		//editorA.send(REP.REP_INSERT_CMD);
 		//editorB.send(REP.REP_INSERT_CMD);
 		
-		Integer[] cmdkind = {REP.REP_INSERT_CMD, REP.REP_DELETE_CMD, REP.REP_REPLACE_CMD};
+		Integer[] cmdkind = {REP.REPCMD_INSERT, REP.REPCMD_DELETE, REP.REPCMD_REPLACE};
 		Enumeration e = new PermEnum(cmdkind);
 		while(e.hasMoreElements()){
 			Integer[] a = (Integer[])e.nextElement();
@@ -97,21 +97,21 @@
 	}
 	
 	public void rep_join(){
-		repsend.send(new REPCommand(REP.REP_JOIN_CMD, 0, 0, myseq, 0, 0, "")); myseq++;
+		repsend.send(new REPCommand(REP.SMCMD_JOIN, 0, 0, myseq, 0, 0, "")); myseq++;
 		REPCommand command = repreceive.unpack();
 		myeid = command.eid; 
 		trans.setMyEID(myeid);
 	}
 	
 	public void put(){
-		repsend.send(new REPCommand(REP.REP_PUT_CMD, 0, myeid, myseq, 0, 4, "afro")); myseq++;
+		repsend.send(new REPCommand(REP.SMCMD_PUT, 0, myeid, myseq, 0, 4, "afro")); myseq++;
 		REPCommand command = repreceive.unpack();
 		mysid = command.sid;
 	}
 	
 	public void select(){
 		mysid = 1;
-		repsend.send(new REPCommand(REP.REP_SELECT_CMD, mysid, myeid, myseq, 0, 0, "")); myseq++;
+		repsend.send(new REPCommand(REP.SMCMD_SELECT, mysid, myeid, myseq, 0, 0, "")); myseq++;
 		REPCommand command = repreceive.unpack();
 		repreceive.addCommandListener(this);
 	}
@@ -188,7 +188,7 @@
 	
 	public void changeText(REPCommand command){
 		switch(command.cmd){
-		case REP.REP_INSERT_CMD:
+		case REP.REPCMD_INSERT:
 			myText.add(command.lineno, command.string);
 			break;
 		}
@@ -203,7 +203,7 @@
 	}
 
 	public synchronized void changeText(int kind, int lineno, String string) {
-		userQueue.add(new REPCommand(REP.REP_INSERT_CMD, mysid, myeid, getMyseq(), lineno, string.length(), string));
+		userQueue.add(new REPCommand(REP.REPCMD_INSERT, mysid, myeid, getMyseq(), lineno, string.length(), string));
 	}
 
 	private int getMyseq() {
--- a/src/sample/merge/TestTranslate.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/sample/merge/TestTranslate.java	Fri Nov 02 17:03:17 2007 +0900
@@ -18,9 +18,9 @@
 		int eidA = 1;
 		int lineno = 10;
 		int sid = 1;
-		REPCommand repcmdA = new REPCommand(REP.REP_INSERT_CMD, sid , eidA, 1, lineno, 3, "AAA");
+		REPCommand repcmdA = new REPCommand(REP.REPCMD_INSERT, sid , eidA, 1, lineno, 3, "AAA");
 		int eidB = 2;
-		REPCommand repcmdB = new REPCommand(REP.REP_INSERT_CMD, sid, eidB, 1, lineno, 3, "BBB");
+		REPCommand repcmdB = new REPCommand(REP.REPCMD_INSERT, sid, eidB, 1, lineno, 3, "BBB");
 		
 		trans.addUserList(repcmdA);
 		trans.addUserList(repcmdA);
--- a/src/sample/merge/TestTranslate2.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/sample/merge/TestTranslate2.java	Fri Nov 02 17:03:17 2007 +0900
@@ -23,14 +23,14 @@
 		
 		/* test */
 		int lineno = 10;
-		editorA.changeText(REP.REP_INSERT_CMD, lineno, "testA");
-		editorA.changeText(REP.REP_INSERT_CMD, lineno, "testA2");
+		editorA.changeText(REP.REPCMD_INSERT, lineno, "testA");
+		editorA.changeText(REP.REPCMD_INSERT, lineno, "testA2");
 
-		editorB.changeText(REP.REP_INSERT_CMD, lineno, "testB");
-		editorB.changeText(REP.REP_INSERT_CMD, lineno, "testB2");
+		editorB.changeText(REP.REPCMD_INSERT, lineno, "testB");
+		editorB.changeText(REP.REPCMD_INSERT, lineno, "testB2");
 		
-		editorA.changeText(REP.REP_INSERT_CMD, lineno, "exit");
-		editorB.changeText(REP.REP_INSERT_CMD, lineno, "exit");
+		editorA.changeText(REP.REPCMD_INSERT, lineno, "exit");
+		editorB.changeText(REP.REPCMD_INSERT, lineno, "exit");
 		
 		try {
 			editorA.join(); // Thread.join() : このスレッドが終了するのを待機します。(REPのjoinとは別)
--- a/src/sample/merge/Translate.java	Fri Oct 19 14:10:05 2007 +0900
+++ b/src/sample/merge/Translate.java	Fri Nov 02 17:03:17 2007 +0900
@@ -62,15 +62,15 @@
 				if(tokenCmd.stat == REP_IGNORE) continue;     /* 削除される(予定)のREPコマンドの比較は無視 */
 				if(userCmd.stat == REP_IGNORE) break;
 				if(userCmd.lineno < tokenCmd.lineno) {     /* UsersLineNumber < TokensLineNumber */
-					if(userCmd.cmd == REP.REP_INSERT_CMD){
+					if(userCmd.cmd == REP.REPCMD_INSERT){
 						tokenCmd.lineno++;
-					}else if(userCmd.cmd == REP.REP_DELETE_CMD){
+					}else if(userCmd.cmd == REP.REPCMD_DELETE){
 						tokenCmd.lineno--;
 					}
 				}else if(userCmd.lineno > tokenCmd.lineno){     /* UsersLineNumber > TokensLineNumber */
-					if(tokenCmd.cmd == REP.REP_INSERT_CMD){
+					if(tokenCmd.cmd == REP.REPCMD_INSERT){
 						userCmd.lineno++;
-					}else if(tokenCmd.cmd == REP.REP_DELETE_CMD){
+					}else if(tokenCmd.cmd == REP.REPCMD_DELETE){
 						userCmd.lineno--;
 					}
 				}else if(userCmd.lineno == tokenCmd.lineno){     /* UsersLineNumber == TokensLineNumber */
@@ -87,29 +87,29 @@
 						h_pricmd = tokenCmd;
 						l_pricmd = userCmd;
 					}
-					if(h_pricmd.cmd == REP.REP_INSERT_CMD){
+					if(h_pricmd.cmd == REP.REPCMD_INSERT){
 						l_pricmd.lineno++;
-					}else if(l_pricmd.cmd == REP.REP_REPLACE_CMD){
-						if(l_pricmd.cmd == REP.REP_INSERT_CMD){
+					}else if(l_pricmd.cmd == REP.REPCMD_REPLACE){
+						if(l_pricmd.cmd == REP.REPCMD_INSERT){
 	                        /* h_pricmd が優先され,l_pricmd は削除(無視に)する */
 							l_pricmd.stat = REP_IGNORE;
-						}else if(l_pricmd.cmd == REP.REP_DELETE_CMD){
+						}else if(l_pricmd.cmd == REP.REPCMD_DELETE){
 							/*
 	                         * l_pricmd 側ではすでにdeleteされているので、
 	                         * h_pricmd を REP_REPLACE_CMD -> REP_INSERT_CMD へ変更。
 	                         */
-							h_pricmd.cmd = REP.REP_INSERT_CMD;
+							h_pricmd.cmd = REP.REPCMD_INSERT;
 							l_pricmd.stat = REP_IGNORE;
 						}
-					}else if(h_pricmd.cmd == REP.REP_DELETE_CMD){
-	                    if (l_pricmd.cmd == REP.REP_INSERT_CMD) {
+					}else if(h_pricmd.cmd == REP.REPCMD_DELETE){
+	                    if (l_pricmd.cmd == REP.REPCMD_INSERT) {
 	                        h_pricmd.lineno++;
-	                    } else if(l_pricmd.cmd == REP.REP_REPLACE_CMD){
+	                    } else if(l_pricmd.cmd == REP.REPCMD_REPLACE){
 	                        /*
 	                         * h_pricmd 側ではすでにdeleteされているので、
 	                         * l_pricmd 側を REP_REPLACE_CMD -> REP_INSERT_CMD へ変更。
 	                         */
-	                        l_pricmd.cmd = REP.REP_INSERT_CMD;
+	                        l_pricmd.cmd = REP.REPCMD_INSERT;
 	                        h_pricmd.stat= REP_IGNORE;
 	                    } else {  /* l_pricmd->cmd == REP_DELETE_LINE_CMD */
 	                        /*