1 19 22 package org.tanesha.replacer; 23 24 31 public class SimplePrintf { 32 33 41 public static String jprintf(String inputFormat, Object [] objs) throws FormatterException { 42 ReplacerFormat format = ReplacerFormat.createFormat(inputFormat); 43 44 return jprintf(format, objs); 45 } 46 47 public static String jprintf(String inputFormat, ReplacerEnvironment env) throws FormatterException { 48 ReplacerFormat format = ReplacerFormat.createFormat(inputFormat); 49 50 return jprintf(format, env); 51 } 52 53 61 public static String jprintf(ReplacerFormat format, Object [] objs) throws FormatterException { 62 63 ReplacerEnvironment env = new ReplacerEnvironment(); 65 for (int i = 0; i < objs.length; i++) 66 env.add(String.valueOf(i), objs[i]); 67 68 return jprintf(format, env); 69 } 70 71 79 public static String jprintf(ReplacerFormat format, ReplacerEnvironment env) throws FormatterException { 80 return format.format(env); 81 } 82 83 } 84 | Popular Tags |