1 23 package org.mdarad.framework.util.struts.criteria; 24 25 import java.util.Currency ; 26 import java.util.Locale ; 27 28 import org.dataisland.primitives.datatype.Money; 29 30 36 public class MoneyCriterion extends NumericCriterion { 37 38 49 public MoneyCriterion(String name, Class associatedEntity, CriterionProperty property, String bundleName, Locale locale) { 50 super(name, associatedEntity, property, bundleName, locale); 51 } 52 53 61 public MoneyCriterion(MoneyCriterion criterion) { 62 super(criterion); 63 } 64 65 66 72 public void setPropertyValue(String value) { 73 if (value != null && value.trim().length() > 0) { 74 String [] values = value.split(" "); 76 77 Money money = new Money(); 78 Double amount = new Double (0.0d); 79 80 Currency currency = Currency.getInstance(Locale.getDefault()); 82 if(values.length == 2) { 83 amount = new Double (values[0]); 84 currency = Currency.getInstance(values[1]); 85 } else if(value.trim().length() != 0) { 86 amount = new Double (value); 87 } 88 money.setAmount(amount); 89 money.setCurrency(currency); 90 setValue(money); 91 } 92 } 93 94 98 public String getPropertyValue() { 99 if (getValue() != null) { 100 Money money = (Money) getValue(); 101 return money.getAmount() + " " + money.getCurrency(); 102 } 103 104 return ""; 105 } 106 107 112 public Class getObjectType() { 113 return Money.class; 114 } 115 } | Popular Tags |