1 package net.sf.jga.fn.string; 33 34 import java.text.Format ; 35 import net.sf.jga.fn.UnaryFunctor; 36 37 44 45 public class FormatValue<T> extends UnaryFunctor<T,String > { 46 47 static final long serialVersionUID = -6545061527457884949L; 48 49 private Format _format; 50 51 public FormatValue (Format format){ 52 if (format == null) { 53 String msg = "Format must be specified"; 54 throw new IllegalArgumentException (msg); 55 } 56 57 _format = format; 58 } 59 60 64 65 public Format getFormat() { 66 return _format; 67 } 68 69 71 77 78 public String fn(T arg) { 79 return _format.format(arg); 80 } 81 82 86 public void accept(net.sf.jga.fn.Visitor v) { 87 if (v instanceof FormatValue.Visitor) 88 ((FormatValue.Visitor)v).visit(this); 89 else 90 v.visit(this); 91 } 92 93 95 public String toString() { 96 return "FormatValue["+_format+"]"; 97 } 98 99 101 105 public interface Visitor extends net.sf.jga.fn.Visitor { 106 public void visit(FormatValue host); 107 } 108 } 109 | Popular Tags |