View Javadoc
1 /*** 2 * CurrencyFunction.java 3 * 4 * $Author: mballesteros $ 5 * $Date: 2003/11/28 19:18:04 $ 6 * $Revision: 1.1 $ 7 */ 8 package net.sf.jec.functions; 9 10 import net.sf.jec.Function; 11 import net.sf.jec.ObjectConverter; 12 13 /*** 14 * 15 * @author mballesteros 16 */ 17 public class CurrencyFunction extends Function { 18 19 private CurrencyFormat cf; 20 21 /*** Creates a new instance of CurrencyFunction */ 22 public CurrencyFunction() { 23 this.cf = CurrencyFormat.getDefaultInstance(); 24 } 25 26 public CurrencyFunction(CurrencyFormat cf) { 27 this.cf = cf; 28 } 29 30 /*** Inverse map: the inverse conversion 31 * @param object The source object array 32 * @return The result object after applying the inverse map 33 */ 34 public Object inverseMap(Object object[]) { 35 if (object.length == 3) { 36 return new Double( cf.parseString(object[0].toString(), 37 object[2].toString(), 38 object[1].toString()) ); 39 } else { 40 return new Double( cf.parseString(object[0].toString(),null, null) ); 41 } 42 } 43 44 /*** Direct map: the direct conversion 45 * @param object The source object array 46 * @return The result object after applying the map 47 */ 48 public Object directMap(Object object[]) { 49 try { 50 if (object.length == 3) { 51 return cf.toString( 52 ObjectConverter.toDouble(object[0].toString()), 53 object[1].toString(), 54 object[2].toString()); 55 } else { 56 return cf.toString( 57 ObjectConverter.toDouble(object[0].toString()), null, null); 58 } 59 } catch (Exception ex) { 60 return null; 61 } 62 } 63 }

This page was automatically generated by Maven