1 5 package org.exoplatform.text.template.xhtml; 6 7 import java.io.IOException ; 8 import java.io.Writer ; 9 import org.exoplatform.text.template.ObjectFormater; 10 15 public class LongTextPopupFormater implements ObjectFormater { 16 private int maxLength_ ; 17 18 public LongTextPopupFormater(int textSize) { 19 maxLength_ = textSize ; 20 } 21 22 public void format(Writer w, Object obj) throws IOException { 23 String value = obj.toString() ; 24 if(value.length() < maxLength_) { 25 w.write(value) ; 26 } else { 27 w.write("<span title='"); 28 w.write(value.toString()) ; 29 w.write("'>") ; 30 w.write(value.substring(0 , maxLength_)) ; 31 w.write(".....") ; 32 w.write("</span>") ; 33 } 34 } 35 } | Popular Tags |