1 package org.catacomb.interlish.version; 2 3 import org.catacomb.about.AboutBase; 4 import org.catacomb.interlish.util.JUtil; 5 import org.catacomb.report.E; 6 7 8 public class BuildInfo { 9 10 public String name; 11 public String num; 12 public String time; 13 public String date; 14 15 16 17 public static BuildInfo getInfo() { 18 return new BuildInfo(); 19 } 20 21 22 public BuildInfo() { 23 String s = JUtil.getRelativeResource(new AboutBase(), "version.xml"); 24 time = "unknown"; 25 date = "unknown"; 26 name = "unknown"; 27 num = "0"; 28 29 if (s != null && s.length() > 0) { 30 time = getQuotedText(s, "time="); 31 date = getQuotedText(s, "date="); 32 num = getQuotedText(s, "num="); 33 name = getQuotedText(s, "name="); 34 } 35 } 36 37 38 public void setName(String s) { 39 name = s; 40 } 41 42 public void setNum(String s) { 43 num = s; 44 } 45 46 47 private String getQuotedText(String src, String start) { 48 String ret = ""; 49 if (src.indexOf(start) >= 0) { 50 String rest = src.substring(src.indexOf(start) + start.length() + 1, src.length()); 51 if (rest.indexOf("\"") > 0) { 52 ret = rest.substring(0, rest.indexOf("\"")); 53 } else { 54 E.warning("no closing quote? - seeking " + start + " in " + src); 55 } 56 57 } else { 58 E.warning("cant find " + start + " in " + src); 59 } 60 return ret; 61 } 62 63 64 public void printIntro() { 65 System.out.println(getIntro()); 66 } 67 68 public String getTitleDate() { 69 return "[" + date + ", " + time + "]"; 70 } 71 72 public String getIntro() { 73 return name + " " + num + " [" + date + ", " + time + "]"; 74 } 75 76 77 public String getFrameTitle() { 78 return getIntro(); 79 } 80 81 }