1 37 38 package net.sourceforge.cobertura.javancss; 39 40 import java.util.Vector ; 41 42 65 public class Util 66 { 67 68 public static final Object CONSTANT_OBJECT = new Object (); 69 70 74 private Util() 75 { 76 super(); 77 } 78 79 83 87 static void panicIf(boolean bPanic_) 88 { 89 if (bPanic_) 90 { 91 throw (new RuntimeException ()); 92 } 93 } 94 95 101 static void panicIf(boolean bPanic_, String sMessage_) 102 { 103 if (bPanic_) 104 { 105 throw (new RuntimeException (sMessage_)); 106 } 107 } 108 109 112 public static boolean isEmpty(String sTest_) 113 { 114 if (sTest_ == null || sTest_.equals("")) 115 { 116 return true; 117 } 118 119 return false; 120 } 121 122 134 private static Vector stringToLines(int lines_, String pString_, char cCutter_) 135 { 136 int maxLines = Integer.MAX_VALUE; 137 if (lines_ > 0) 138 { 139 maxLines = lines_; 140 } 141 142 Vector vRetVal = new Vector (); 143 if (pString_ == null) 144 { 145 return vRetVal; 146 } 147 148 int startIndex = 0; 149 for (; maxLines > 0; maxLines--) 150 { 151 int endIndex = pString_.indexOf(cCutter_, startIndex); 152 if (endIndex == -1) 153 { 154 if (startIndex < pString_.length()) 155 { 156 endIndex = pString_.length(); 157 } 158 else 159 { 160 break; 161 } 162 } 163 String sLine = pString_.substring(startIndex, endIndex); 164 vRetVal.addElement(sLine); 165 startIndex = endIndex + 1; 166 } 167 168 return vRetVal; 169 } 170 171 181 private static Vector stringToLines(String pString_, char cCutter_) 182 { 183 return stringToLines(0, pString_, cCutter_); 184 } 185 186 194 public static Vector stringToLines(String pString_) 195 { 196 return stringToLines(pString_, '\n'); 197 } 198 199 202 private static void sleep(int seconds_) 203 { 204 try 205 { 206 Thread.sleep(seconds_ * 1000); 207 } 208 catch (Exception pException) 209 { 210 } 211 } 212 213 } 214 | Popular Tags |