1 3 package jodd.format; 4 5 8 public class Printf { 9 10 12 public static String str(String format, byte value) { 13 return new PrintfFormat(format).form(value); 14 } 15 public static void out(String format, byte value) { 16 System.out.println(str(format, value)); 17 } 18 19 20 public static String str(String format, char value) { 21 return new PrintfFormat(format).form(value); 22 } 23 public static void out(String format, char value) { 24 System.out.println(str(format, value)); 25 } 26 27 28 public static String str(String format, short value) { 29 return new PrintfFormat(format).form(value); 30 } 31 public static void out(String format, short value) { 32 System.out.println(str(format, value)); 33 } 34 35 36 public static String str(String format, int value) { 37 return new PrintfFormat(format).form(value); 38 } 39 public static void out(String format, int value) { 40 System.out.println(str(format, value)); 41 } 42 43 44 public static String str(String format, long value) { 45 return new PrintfFormat(format).form(value); 46 } 47 public static void out(String format, long value) { 48 System.out.println(str(format, value)); 49 } 50 51 52 public static String str(String format, float value) { 53 return new PrintfFormat(format).form(value); 54 } 55 public static void out(String format, float value) { 56 System.out.println(str(format, value)); 57 } 58 59 60 public static String str(String format, double value) { 61 return new PrintfFormat(format).form(value); 62 } 63 public static void out(String format, double value) { 64 System.out.println(str(format, value)); 65 } 66 67 68 public static String str(String format, boolean value) { 69 return new PrintfFormat(format).form(value); 70 } 71 public static void out(String format, boolean value) { 72 System.out.println(str(format, value)); 73 } 74 75 76 public static String str(String format, String value) { 77 return new PrintfFormat(format).form(value); 78 } 79 public static void out(String format, String value) { 80 System.out.println(str(format, value)); 81 } 82 83 84 85 87 public static String str(String format, Byte value) { 88 return new PrintfFormat(format).form(value.byteValue()); 89 } 90 public static void out(String format, Byte value) { 91 System.out.println(str(format, value)); 92 } 93 94 95 public static String str(String format, Character value) { 96 return new PrintfFormat(format).form(value.charValue()); 97 } 98 public static void out(String format, Character value) { 99 System.out.println(str(format, value)); 100 } 101 102 103 public static String str(String format, Short value) { 104 return new PrintfFormat(format).form(value.shortValue()); 105 } 106 public static void out(String format, Short value) { 107 System.out.println(str(format, value)); 108 } 109 110 111 public static String str(String format, Integer value) { 112 return new PrintfFormat(format).form(value.intValue()); 113 } 114 public static void out(String format, Integer value) { 115 System.out.println(str(format, value)); 116 } 117 118 119 public static String str(String format, Long value) { 120 return new PrintfFormat(format).form(value.longValue()); 121 } 122 public static void out(String format, Long value) { 123 System.out.println(str(format, value)); 124 } 125 126 127 public static String str(String format, Float value) { 128 return new PrintfFormat(format).form(value.floatValue()); 129 } 130 public static void out(String format, Float value) { 131 System.out.println(str(format, value)); 132 } 133 134 135 public static String str(String format, Double value) { 136 return new PrintfFormat(format).form(value.doubleValue()); 137 } 138 public static void out(String format, Double value) { 139 System.out.println(str(format, value)); 140 } 141 142 143 public static String str(String format, Boolean value) { 144 return new PrintfFormat(format).form(value.booleanValue()); 145 } 146 public static void out(String format, Boolean value) { 147 System.out.println(str(format, value)); 148 } 149 150 151 152 154 public static String str(String format, byte[] params) { 155 PrintfFormat pf = new PrintfFormat(); 156 for (int i = 0; i < params.length; i++) { 157 format = pf.reinit(format).form(params[i]); 158 } 159 return format; 160 } 161 public static void out(String format, byte[] params) { 162 System.out.println(str(format, params)); 163 } 164 165 166 public static String str(String format, char[] params) { 167 PrintfFormat pf = new PrintfFormat(); 168 for (int i = 0; i < params.length; i++) { 169 format = pf.reinit(format).form(params[i]); 170 } 171 return format; 172 } 173 public static void out(String format, char[] params) { 174 System.out.println(str(format, params)); 175 } 176 177 178 public static String str(String format, short[] params) { 179 PrintfFormat pf = new PrintfFormat(); 180 for (int i = 0; i < params.length; i++) { 181 format = pf.reinit(format).form(params[i]); 182 } 183 return format; 184 } 185 public static void out(String format, short[] params) { 186 System.out.println(str(format, params)); 187 } 188 189 190 public static String str(String format, int[] params) { 191 PrintfFormat pf = new PrintfFormat(); 192 for (int i = 0; i < params.length; i++) { 193 format = pf.reinit(format).form(params[i]); 194 } 195 return format; 196 } 197 public static void out(String format, int[] params) { 198 System.out.println(str(format, params)); 199 } 200 201 202 public static String str(String format, long[] params) { 203 PrintfFormat pf = new PrintfFormat(); 204 for (int i = 0; i < params.length; i++) { 205 format = pf.reinit(format).form(params[i]); 206 } 207 return format; 208 } 209 public static void out(String format, long[] params) { 210 System.out.println(str(format, params)); 211 } 212 213 214 public static String str(String format, float[] params) { 215 PrintfFormat pf = new PrintfFormat(); 216 for (int i = 0; i < params.length; i++) { 217 format = pf.reinit(format).form(params[i]); 218 } 219 return format; 220 } 221 public static void out(String format, float[] params) { 222 System.out.println(str(format, params)); 223 } 224 225 226 public static String str(String format, double[] params) { 227 PrintfFormat pf = new PrintfFormat(); 228 for (int i = 0; i < params.length; i++) { 229 format = pf.reinit(format).form(params[i]); 230 } 231 return format; 232 } 233 public static void out(String format, double[] params) { 234 System.out.println(str(format, params)); 235 } 236 237 238 public static String str(String format, boolean[] params) { 239 PrintfFormat pf = new PrintfFormat(); 240 for (int i = 0; i < params.length; i++) { 241 format = pf.reinit(format).form(params[i]); 242 } 243 return format; 244 } 245 public static void out(String format, boolean[] params) { 246 System.out.println(str(format, params)); 247 } 248 249 250 public static String str(String format, String [] params) { 251 PrintfFormat pf = new PrintfFormat(); 252 for (int i = 0; i < params.length; i++) { 253 format = pf.reinit(format).form(params[i]); 254 } 255 return format; 256 } 257 public static void out(String format, String [] params) { 258 System.out.println(str(format, params)); 259 } 260 261 262 263 265 public static String str(String format, Byte [] params) { 266 PrintfFormat pf = new PrintfFormat(); 267 for (int i = 0; i < params.length; i++) { 268 byte param = params[i].byteValue(); 269 format = pf.reinit(format).form(param); 270 } 271 return format; 272 } 273 public static void out(String format, Byte [] params) { 274 System.out.println(str(format, params)); 275 } 276 277 public static String str(String format, Character [] params) { 278 PrintfFormat pf = new PrintfFormat(); 279 for (int i = 0; i < params.length; i++) { 280 char param = params[i].charValue(); 281 format = pf.reinit(format).form(param); 282 } 283 return format; 284 } 285 public static void out(String format, Character [] params) { 286 System.out.println(str(format, params)); 287 } 288 289 public static String str(String format, Short [] params) { 290 PrintfFormat pf = new PrintfFormat(); 291 for (int i = 0; i < params.length; i++) { 292 short param = params[i].shortValue(); 293 format = pf.reinit(format).form(param); 294 } 295 return format; 296 } 297 public static void out(String format, Short [] params) { 298 System.out.println(str(format, params)); 299 } 300 301 public static String str(String format, Integer [] params) { 302 PrintfFormat pf = new PrintfFormat(); 303 for (int i = 0; i < params.length; i++) { 304 int param = params[i].intValue(); 305 format = pf.reinit(format).form(param); 306 } 307 return format; 308 } 309 public static void out(String format, Integer [] params) { 310 System.out.println(str(format, params)); 311 } 312 313 public static String str(String format, Long [] params) { 314 PrintfFormat pf = new PrintfFormat(); 315 for (int i = 0; i < params.length; i++) { 316 long param = params[i].longValue(); 317 format = pf.reinit(format).form(param); 318 } 319 return format; 320 } 321 public static void out(String format, Long [] params) { 322 System.out.println(str(format, params)); 323 } 324 325 public static String str(String format, Float [] params) { 326 PrintfFormat pf = new PrintfFormat(); 327 for (int i = 0; i < params.length; i++) { 328 float param = params[i].floatValue(); 329 format = pf.reinit(format).form(param); 330 } 331 return format; 332 } 333 public static void out(String format, Float [] params) { 334 System.out.println(str(format, params)); 335 } 336 337 public static String str(String format, Double [] params) { 338 PrintfFormat pf = new PrintfFormat(); 339 for (int i = 0; i < params.length; i++) { 340 double param = params[i].doubleValue(); 341 format = pf.reinit(format).form(param); 342 } 343 return format; 344 } 345 public static void out(String format, Double [] params) { 346 System.out.println(str(format, params)); 347 } 348 349 public static String str(String format, Boolean [] params) { 350 PrintfFormat pf = new PrintfFormat(); 351 for (int i = 0; i < params.length; i++) { 352 boolean param = params[i].booleanValue(); 353 format = pf.reinit(format).form(param); 354 } 355 return format; 356 } 357 public static void out(String format, Boolean [] params) { 358 System.out.println(str(format, params)); 359 } 360 361 362 364 public static String str(String format, Object [] params) { 365 PrintfFormat pf = new PrintfFormat(); 366 for (int i = 0; i < params.length; i++) { 367 pf.reinit(format); 368 369 Object param = params[i]; 370 if (param instanceof Integer ) { 371 format = pf.form(((Integer ) param).intValue()); 372 } else if (param instanceof Long ) { 373 format = pf.form(((Long ) param).longValue()); 374 } else if (param instanceof Character ) { 375 format = pf.form(((Character ) param).charValue()); 376 } else if (param instanceof Double ) { 377 format = pf.form(((Double ) param).doubleValue()); 378 } else if (param instanceof Float ) { 379 format = pf.form(((Float ) param).floatValue()); 380 } else { 381 format = pf.form(param.toString()); 382 } 383 } 384 return format; 385 } 386 public static void out(String format, Object [] params) { 387 System.out.println(str(format, params)); 388 } 389 390 } | Popular Tags |