1 23 24 package customFormatters; 25 26 import java.util.Locale ; 27 import org.dbforms.util.ICustomFormat; 28 29 30 31 38 public class DashifyFormatter implements ICustomFormat { 39 Locale locale = null; 40 String dashStr = null; 41 42 public void setArg(String fmtArg) throws IllegalArgumentException { 43 dashStr = fmtArg; 44 } 45 46 47 public void setLocale(Locale locale) { 48 this.locale = locale; 49 } 50 51 52 public Locale getLocale() { 53 return locale; 54 } 55 56 57 public String sprintf(String s) { 58 String r = ""; 59 if (s != null) { 60 for (int i = 0; i != s.length(); i++) { 61 if (i > 0) { 62 r += this.dashStr; 63 } 64 r += s.charAt(i); 65 } 66 } 67 return r; 68 } 69 } 70 | Popular Tags |