1 package org.apache.fulcrum.intake.model; 2 3 56 57 import java.math.BigDecimal ; 58 59 import org.apache.fulcrum.intake.xmlmodel.XmlField; 60 import org.apache.log4j.Category; 61 import org.apache.torque.om.NumberKey; 62 63 69 public class NumberKeyField 70 extends BigDecimalField 71 { 72 73 Category category = Category.getInstance(getClass().getName()); 74 75 public NumberKeyField(XmlField field, Group group) 76 throws Exception 77 { 78 super(field, group); 79 80 } 81 82 87 protected void setDefaultValue(String prop) 88 { 89 if (prop == null) 90 { 91 return; 92 } 93 94 try 95 { 96 defaultValue = new NumberKey(prop); 97 } 98 catch (RuntimeException e) 99 { 100 category.error("Could not convert " 101 + prop + " into a NumberKey. (" 102 + name + ")"); 103 } 104 } 105 106 111 protected String getDefaultValidator() 112 { 113 return "org.apache.fulcrum.intake.validator.NumberKeyValidator"; 114 } 115 116 119 protected void doSetValue() 120 { 121 if ( isMultiValued ) 122 { 123 String [] inputs = pp.getStrings(getKey()); 124 NumberKey[] values = new NumberKey[inputs.length]; 125 for (int i = 0; i < inputs.length; i++) 126 { 127 if (inputs[i] != null && inputs[i].length() > 0) 128 { 129 values[i] = new NumberKey( 130 canonicalizeDecimalInput(inputs[i])); 131 } 132 } 133 setTestValue(values); 134 } 135 else 136 { 137 String s = pp.getString(getKey()); 138 if (s != null && s.length() > 0) 139 { 140 BigDecimal bd = canonicalizeDecimalInput(s); 141 setTestValue( new NumberKey(bd) ); 142 } 143 else 144 { 145 set_flag = false; 146 } 147 } 148 } 149 } 150 | Popular Tags |