Mercurial > hg > RemoteEditor > Eclipse
view src/pathfinder/BlockingQnoSeMa/Text.java @ 83:3db21fae825a
pathfinder simulation without SessionManager
author | kent |
---|---|
date | Mon, 12 Nov 2007 17:53:48 +0900 |
parents | |
children |
line wrap: on
line source
package pathfinder.BlockingQnoSeMa; import java.util.Arrays; import java.util.LinkedList; import remoteeditor.command.REPCommand; import remoteeditor.network.REP; public class Text { static private String[] text0 = { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm", "nnn", "ooo", "ppp", "qqq", "rrr", "sss", "ttt", "uuu", "vvv", "www", "xxx", "yyy", "zzz" }; LinkedList<String> strList; public Text(){ this(Text.text0); } public Text(String[] _strings){ strList = new LinkedList<String>(Arrays.asList(_strings)); } synchronized public void insert(int i, String str){ assert 0<i && i<strList.size(); strList.add(i, str); } synchronized public void delete(int i){ assert 0<i && i<strList.size(); strList.remove(i); } synchronized public void replace(int i, String str){ assert 0<i && i<strList.size(); strList.set(i, str); } public String get(int i){ assert 0<i && i<strList.size(); return strList.get(i); } public void edit(REPCommand cmd){ if (cmd.cmd==REP.REPCMD_INSERT) insert(cmd.lineno, cmd.string); else if (cmd.cmd==REP.REPCMD_REPLACE) replace(cmd.lineno, cmd.string); else if (cmd.cmd==REP.REPCMD_DELETE) delete(cmd.lineno); //else assert false; } public int size(){ return strList.size(); } public void printAllText(){ for( String str: strList){ System.out.println(str); } } public boolean equals(Text _target){ return strList.equals(_target.strList); } }