1 3 5 22 23 package edu.neu.ccs.jmk; 24 25 31 public class CvsInfo 32 { 33 private CvsInfo() { 34 } 35 36 41 public static String getEntry(String text) { 42 if (text == null) 43 return null; 44 int first = text.indexOf('$'); 45 int last = text.lastIndexOf('$'); 46 if (last <= first) 47 return null; 48 return text.substring(first + 1, last).trim(); 49 } 50 51 57 public static String getValue(String text) { 58 text = getEntry(text); 59 if (text == null) 60 return null; 61 int first = text.indexOf(':'); 62 if (first < 0) 63 return ""; 64 return text.substring(first + 1).trim(); 65 } 66 67 73 public static String getTag(String text) { 74 text = getValue(text); 75 if (text == null) 76 return null; 77 return text.replace('_', '.').replace('-', ' ').trim(); 78 } 79 80 86 public static String getKey(String text) { 87 text = getEntry(text); 88 if (text == null) 89 return null; 90 int first = text.indexOf(':'); 91 if (first < 0) 92 return text; 93 return text.substring(0, first).trim(); 94 } 95 96 100 public static void main(String [] args) { 101 for (int i = 0; i < args.length; i++) { 102 System.out.println("args[" + i + "] = \"" + args[i] + "\""); 103 System.out.println("getEntry(args[" + i + "]) = \"" 104 + getEntry(args[i]) + "\""); 105 System.out.println("getValue(args[" + i + "]) = \"" 106 + getValue(args[i]) + "\""); 107 System.out.println("getKey(args[" + i + "]) = \"" 108 + getKey(args[i]) + "\""); 109 System.out.println(); 110 } 111 } 112 } 113 | Popular Tags |