1 package org.apache.turbine.services.intake.model; 2 3 18 19 import org.apache.commons.lang.StringUtils; 20 21 import org.apache.torque.om.ComboKey; 22 23 import org.apache.turbine.services.intake.IntakeException; 24 import org.apache.turbine.services.intake.xmlmodel.XmlField; 25 26 32 public class ComboKeyField 33 extends Field 34 { 35 42 public ComboKeyField(XmlField field, Group group) 43 throws IntakeException 44 { 45 super(field, group); 46 } 47 48 53 public void setDefaultValue(String prop) 54 { 55 defaultValue = null; 56 57 if (prop == null) 58 { 59 return; 60 } 61 62 defaultValue = new ComboKey(prop); 63 } 64 65 73 public void setEmptyValue(String prop) 74 { 75 emptyValue = null; 76 77 if (prop == null) 78 { 79 return; 80 } 81 82 emptyValue = new ComboKey(prop); 83 } 84 85 88 protected void doSetValue() 89 { 90 if (isMultiValued) 91 { 92 String [] inputs = parser.getStrings(getKey()); 93 ComboKey[] values = new ComboKey[inputs.length]; 94 for (int i = 0; i < inputs.length; i++) 95 { 96 values[i] = StringUtils.isNotEmpty(inputs[i]) 97 ? new ComboKey(inputs[i]) : (ComboKey) getEmptyValue(); 98 } 99 setTestValue(values); 100 } 101 else 102 { 103 String val = parser.getString(getKey()); 104 setTestValue(StringUtils.isNotEmpty(val) ? new ComboKey(val) : (ComboKey) getEmptyValue()); 105 } 106 } 107 } 108 | Popular Tags |