1 5 package org.exoplatform.text.template; 6 7 import java.io.IOException ; 8 import java.io.Writer ; 9 10 15 public class ArrayFormater implements ObjectFormater { 16 private String starItemSeparator_ ; 17 private String endItemSeparator_ ; 18 private ObjectFormater valueFormater_ ; 19 20 public ArrayFormater(String startItemSeparator, String endItemSeparator) { 21 starItemSeparator_ = startItemSeparator ; 22 endItemSeparator_ = endItemSeparator; 23 } 24 25 public void format(Writer w, Object obj) throws IOException { 26 Object [] list = (Object []) obj ; 27 for(int i = 0; i < list.length ; i++) { 28 if(starItemSeparator_ != null) w.write(starItemSeparator_); 29 if(valueFormater_ == null )w.write(list[i].toString()); 30 else valueFormater_.format(w, list[i]) ; 31 if(endItemSeparator_ != null)w.write(endItemSeparator_) ; 32 } 33 } 34 35 public ObjectFormater setValueFormater(ObjectFormater formater) { 36 valueFormater_ = formater ; 37 return this ; 38 } 39 } | Popular Tags |