001 package railo.runtime.tag; 002 003 import java.io.Serializable; 004 import java.util.Date; 005 import java.util.TimeZone; 006 007 import railo.runtime.PageContext; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.op.Caster; 010 011 public class ChartDataBean implements Serializable,Comparable { 012 013 private Object item; 014 private String strItem; 015 private double value; 016 /** 017 * @return the item 018 */ 019 public Object getItem() { 020 return item; 021 } 022 public String getItemAsString() { 023 return strItem; 024 } 025 /** 026 * @param item the item to set 027 * @throws PageException 028 */ 029 public void setItem(PageContext pc,Object obj) throws PageException { 030 this.strItem = itemToString(pc, obj); 031 this.item=obj; 032 } 033 public void setItem(String str) { 034 this.strItem = str; 035 this.item=str; 036 } 037 /** 038 * @return the value 039 */ 040 public double getValue() { 041 return value; 042 } 043 /** 044 * @param value the value to set 045 */ 046 public void setValue(double value) { 047 this.value = value; 048 } 049 050 @Override 051 public String toString() { 052 return "item:"+item+";"+"value;"+value+";"; 053 } 054 public int compareTo(Object o) { 055 if(!(o instanceof ChartDataBean)) return 0; 056 ChartDataBean other=(ChartDataBean) o; 057 return getItemAsString().compareTo(other.getItemAsString()); 058 } 059 060 061 private String itemToString(PageContext pc,Object obj) throws PageException { 062 if(obj instanceof Date) { 063 TimeZone tz = pc.getTimeZone(); 064 return new railo.runtime.format.DateFormat(pc.getLocale()).format(Caster.toDate(obj, tz),"short",tz)+" "+ 065 new railo.runtime.format.TimeFormat(pc.getLocale()).format(Caster.toDate(obj, tz),"short",tz); 066 } 067 return Caster.toString(obj); 068 } 069 }