1 2 3 package org.quilt.runner; 4 5 10 public class Msg { 11 12 private String baseName; 13 private static final int DEFAULT_WIDTH = 60; 14 private static final char DEFAULT_BIG = '='; 15 private static final char DEFAULT_SMALL = '-'; 16 17 18 private boolean talking = true; 19 20 private int bannerWidth; 21 22 private char bigChar = '='; 23 24 private char smallChar = '-'; 25 26 private String myBigBanner; 27 28 private String myBanner; 29 30 33 34 public Msg (final String base) { 35 this(base, DEFAULT_WIDTH, DEFAULT_BIG, DEFAULT_SMALL); 36 } 37 41 public Msg (final String base, final int width) { 42 this(base, width, DEFAULT_BIG, DEFAULT_SMALL); 43 } 44 49 public Msg (final String base, final int width, final char big) { 50 this(base, width, big, DEFAULT_SMALL); 51 } 52 58 public Msg (final String base, final int width, final char big, 59 final char small) { 60 baseName = base; 61 bannerWidth = width; 63 bigChar = big; 64 smallChar = small; 65 66 StringBuffer bigUn = new StringBuffer (width + 1); 68 StringBuffer smallUn = new StringBuffer (width + 1); 69 for (int i = 0; i < width; i++) { 70 bigUn.append(big); 71 smallUn.append(big); 72 } 73 bigUn.append('\n'); 74 myBigBanner = bigUn.toString(); 75 76 smallUn.append('\n'); 77 myBanner = smallUn.toString(); 78 } 79 84 public void talk (final boolean b) { 85 talking = b; 86 } 87 public void trace(final String where) { 88 if (talking) { 89 System.out.println ("---> " + baseName + where ); 90 } 91 } 92 public void banner (final String where) { 93 if (talking) { 94 System.out.print ( 95 myBanner + baseName + where + "\n" + myBanner ); 96 } 97 } 98 public void bannerAnd (final String where, final String stuff) { 99 if (talking) { 100 System.out.print ( myBanner + baseName + where 101 + "\n" + myBanner + stuff + "\n"); 102 } 103 } 104 public void bigBanner (final String where) { 105 if (talking) { 106 System.out.print ( myBigBanner + baseName + where 107 + "\n" + myBigBanner ); 108 } 109 } 110 public boolean isTalking() { 111 return talking; 112 } 113 } 114 | Popular Tags |