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 import org.apache.torque.om.StringKey; 60 61 66 public class StringKeyField 67 extends Field 68 { 69 70 Category category = Category.getInstance(getClass().getName()); 71 72 public StringKeyField(XmlField field, Group group) 73 throws Exception 74 { 75 super(field, group); 76 } 77 78 83 protected void setDefaultValue(String prop) 84 { 85 if (prop == null) 86 { 87 return; 88 } 89 90 try 91 { 92 defaultValue = new StringKey(prop); 93 } 94 catch (RuntimeException e) 95 { 96 category.error("Could not convert " 97 + prop + " into a StringKey. (" 98 + name + ")"); 99 } 100 } 101 102 107 protected String getDefaultValidator() 108 { 109 return "org.apache.fulcrum.intake.validator.DefaultValidator"; 110 } 111 112 115 protected void doSetValue() 116 { 117 if ( isMultiValued ) 118 { 119 String [] ss = pp.getStrings(getKey()); 120 StringKey[] ival = new StringKey[ss.length]; 121 for (int i=0; i<ss.length; i++) 122 { 123 ival[i] = new StringKey(ss[i]); 124 } 125 setTestValue(ival); 126 } 127 else 128 { 129 setTestValue( new StringKey(pp.getString(getKey())) ); 130 } 131 } 132 } 133 | Popular Tags |