Mercurial > hg > RemoteEditor > REPSessionManager
view test/Text.java @ 442:3819dec4641e
command waiting during merge
author | one |
---|---|
date | Sun, 12 Sep 2010 22:23:53 +0900 |
parents | de4ef4313adc |
children |
line wrap: on
line source
package test; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import rep.REPCommand; public class Text extends LinkedList<String> { /** * */ private static final long serialVersionUID = 1L; public Text(String[] _strings){ super(Arrays.asList(_strings)); } public Text(List<String> _strings){ super(_strings); } public String insert(int i, String str){ while (i>size()) add(""); assert 0<=i && i<=size(); add(i, str); return null; } public String delete(int i){ if (i>=size()) return ""; // assert 0<=i && i<size(); return remove(i); } public String replace(int i, String str){ //assert 0<=i && i<size(); String replaced ; if (i<size()) { replaced = get(i); } else { replaced = ""; } set(i, str); return replaced; } public String edit(REPCommand cmd){ switch(cmd.cmd) { case REPCMD_INSERT_USER: case REPCMD_INSERT: return insert(cmd.lineno, cmd.string); case REPCMD_DELETE_USER: case REPCMD_DELETE: return delete(cmd.lineno); } return null; } public void edit(List<REPCommand> cmdlist){ for (REPCommand cmd: cmdlist){ edit(cmd); } } public void printAllText(){ for( String str: this){ System.out.println(str); } } }