|
From: Brendan M. <mc...@us...> - 2006-09-11 15:05:28
|
Update of /cvsroot/jigs/jigs/src/edu/whitman/halfway/util In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv29584/src/edu/whitman/halfway/util Modified Files: MiscUtil.java PropProvider.java StringUtil.java FileUtil.java TimingTree.java Log Message: Index: MiscUtil.java =================================================================== RCS file: /cvsroot/jigs/jigs/src/edu/whitman/halfway/util/MiscUtil.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** MiscUtil.java 29 Aug 2006 19:29:56 -0000 1.23 --- MiscUtil.java 11 Sep 2006 15:05:22 -0000 1.24 *************** *** 16,19 **** --- 16,29 ---- private static Random rand = new Random(); + + public static final boolean isAssertEnabled(){ + try{ + assert false; + }catch(AssertionError e){ + return true; + } + return false; + } + public static final void fill(int[][] a, int v){ int n = a.length; *************** *** 741,746 **** } - - public static final long[] packRowMajor(long[][] data){ int nr = data.length; --- 751,754 ---- Index: PropProvider.java =================================================================== RCS file: /cvsroot/jigs/jigs/src/edu/whitman/halfway/util/PropProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PropProvider.java 2 Mar 2005 17:54:58 -0000 1.4 --- PropProvider.java 11 Sep 2006 15:05:22 -0000 1.5 *************** *** 9,12 **** --- 9,16 ---- static Logger log = Logger.getLogger(PropProvider.class.getName()); + public String toString(){ + return getProps().toString(); + } + public Properties getProps(){ return getProps(""); Index: StringUtil.java =================================================================== RCS file: /cvsroot/jigs/jigs/src/edu/whitman/halfway/util/StringUtil.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** StringUtil.java 29 Aug 2006 19:29:56 -0000 1.13 --- StringUtil.java 11 Sep 2006 15:05:22 -0000 1.14 *************** *** 180,183 **** --- 180,199 ---- } + + /** + * + * @param input A string, possibly with multiple lines. + * @param pad Padding string to be prefixed to the start of each line. + * @return A padded version of input. + */ + public static String padLines(String input, String pad){ + //System.out.printf("input:%n%s%n", input); + java.util.regex.Pattern p = java.util.regex.Pattern.compile("^", java.util.regex.Pattern.MULTILINE); + java.util.regex.Matcher m = p.matcher(input); + String output = m.replaceAll(pad); + //System.out.printf("output:%n%s%n", output); + return output; + } + /** Prefixes the string input with enough copies of pad that it has length equal to length. Returns null and logs an error if *************** *** 321,324 **** --- 337,348 ---- public static void main(String[] args) { + test(); + } + + public static void test(){ + String test = String.format("foo%nadlfkja34%nad3%n hllow now%n"); + System.out.println(padLines(test, " ")); + + long[] times = { 100, 13011, 60 * 60 * 1000 * 59 + 60 * 1000 * 32 + 1000 * 49 + 333, Index: FileUtil.java =================================================================== RCS file: /cvsroot/jigs/jigs/src/edu/whitman/halfway/util/FileUtil.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** FileUtil.java 29 Aug 2006 19:29:56 -0000 1.14 --- FileUtil.java 11 Sep 2006 15:05:22 -0000 1.15 *************** *** 38,41 **** --- 38,42 ---- } + public static File makeNumFilename(String prefix, String suffix, File dir){ return makeNumFilename(prefix, suffix, dir, false); Index: TimingTree.java =================================================================== RCS file: /cvsroot/jigs/jigs/src/edu/whitman/halfway/util/TimingTree.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TimingTree.java 29 Aug 2006 19:29:56 -0000 1.1 --- TimingTree.java 11 Sep 2006 15:05:22 -0000 1.2 *************** *** 30,36 **** --- 30,55 ---- public void start(String name){ + if(nameIsBelow(name)){ + log.warn(String.format("Possible error: A timer of name \"%s\" is already running.", + name)); + } activeNode = activeNode.start(name); } + public boolean nameIsBelow(String name){ + if (name.equals(activeNode.name)){ + return true; + } + + Node node = activeNode; + while(node.parent != null){ + node = node.parent; + if(name.equals(node.name)){ + return true; + } + } + return false; + } + public ExecutionTimer getTimer(String dottedName){ String[] name = dottedName.split("."); |