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.StringKey; 22 23 import org.apache.turbine.services.intake.IntakeException; 24 import org.apache.turbine.services.intake.validator.StringValidator; 25 import org.apache.turbine.services.intake.xmlmodel.XmlField; 26 27 34 public class StringKeyField 35 extends Field 36 { 37 38 45 public StringKeyField(XmlField field, Group group) 46 throws IntakeException 47 { 48 super(field, group); 49 } 50 51 56 protected String getDefaultValidator() 57 { 58 return StringValidator.class.getName(); 59 } 60 61 66 public void setDefaultValue(String prop) 67 { 68 if (prop == null) 69 { 70 return; 71 } 72 73 defaultValue = new StringKey(prop); 74 } 75 76 84 public void setEmptyValue(String prop) 85 { 86 if (prop == null) 87 { 88 return; 89 } 90 91 emptyValue = new StringKey(prop); 92 } 93 94 97 protected void doSetValue() 98 { 99 if (isMultiValued) 100 { 101 String [] ss = parser.getStrings(getKey()); 102 StringKey[] ival = new StringKey[ss.length]; 103 for (int i = 0; i < ss.length; i++) 104 { 105 ival[i] = (StringUtils.isNotEmpty(ss[i])) 106 ? new StringKey(ss[i]) : (StringKey) getEmptyValue(); 107 } 108 setTestValue(ival); 109 } 110 else 111 { 112 String val = parser.getString(getKey()); 113 setTestValue((StringUtils.isNotEmpty(val)) 114 ? new StringKey(val) : (StringKey) getEmptyValue()); 115 } 116 } 117 } 118 | Popular Tags |