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