1 13 14 package mondrian.rolap; 15 import mondrian.olap.Util; 16 17 24 class StringList 25 { 26 private final StringBuilder buf; 27 private final String first, mid, last; 28 private int count; 29 30 StringList(String first, String mid) 31 { 32 this.buf = new StringBuilder (first); 33 this.count = 0; 34 this.first = first; 35 this.mid = mid; 36 this.last = ""; 37 } 38 StringList(String first) 39 { 40 this(first, ", "); 41 } 42 int getCount() 43 { 44 return count; 45 } 46 boolean isEmpty() 47 { 48 return count == 0; 49 } 50 51 void newItem(String s) 52 { 53 if (count++ > 0) { 54 buf.append(mid); 55 } 56 buf.append(s); 57 } 58 59 void append(String s) 60 { 61 Util.assertTrue(count > 0); 62 buf.append(s); 63 } 64 public String toString() 66 { 67 buf.append(last); 68 return buf.toString(); 69 } 70 }; 71 72 73 | Popular Tags |