From: Stefan F. <ste...@us...> - 2010-03-23 18:46:02
|
Update of /cvsroot/rails/18xx/rails/util In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10916/rails/util Modified Files: LocalText.java Added Files: SequenceUtil.java Log Message: Implementation of Rails junit testing. More details see mail to the develop list. Index: LocalText.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/util/LocalText.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LocalText.java 11 Jan 2009 17:23:21 -0000 1.6 --- LocalText.java 23 Mar 2010 18:45:16 -0000 1.7 *************** *** 38,42 **** if (key == null || key.length() == 0) return ""; ! /* Load the texts */ if (localisedText == null) { --- 38,42 ---- if (key == null || key.length() == 0) return ""; ! /* Load the texts */ if (localisedText == null) { *************** *** 83,86 **** --- 83,96 ---- } } + + // special treatment for test + if (localeCode.equals("te_st0")) { + StringBuffer s = new StringBuffer(key); + if (parameters != null) + for (Object o:parameters) + s.append("," + o.toString()); + return s.toString(); + } + /* Find the text */ try { --- NEW FILE: SequenceUtil.java --- package rails.util; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import rails.game.Bank; import rails.game.CashHolder; import rails.game.Player; import rails.game.PublicCompany; public class SequenceUtil { // private constructor private SequenceUtil() {}; private static <E extends CashHolder> List<E> selectCashHolders(Class<E> clazz, Collection<CashHolder> coll) { // select all cashholders of that type List<E> list = new ArrayList<E>(); for (CashHolder c:coll) { if (clazz.isAssignableFrom(c.getClass())) { @SuppressWarnings("unchecked") E cast = (E) c; list.add(cast); } } return list; } /** * Defines a sorting on cashHolders * @return sorted list of cashholders */ public static List<CashHolder> sortCashHolders(Collection<CashHolder> coll) { List<CashHolder> sortedList = new ArrayList<CashHolder>(); // first add players List<Player> players = selectCashHolders(Player.class, coll); Collections.sort(players); sortedList.addAll(players); // then public companies List<PublicCompany> PublicCompanys = selectCashHolders(PublicCompany.class, coll); Collections.sort(PublicCompanys); sortedList.addAll(PublicCompanys); // last add the bank sortedList.addAll(selectCashHolders(Bank.class, coll)); return sortedList; } } |