1 23 package org.mdarad.framework.util.struts.criteria; 24 25 import java.util.Locale ; 26 27 import org.mdarad.framework.expr.Criterion; 28 import org.mdarad.framework.expr.OperatorTypes; 29 import org.mdarad.framework.util.ClassUtils; 30 import org.mdarad.framework.util.ClassUtilsException; 31 32 40 public class MultipleListCriterion extends ListCriterion { 41 42 53 public MultipleListCriterion(String name, Class associatedEntity, CriterionProperty property, String bundleName, Locale locale, Class elementType) { 54 super(name, associatedEntity, property, bundleName, locale); 55 this.elementType = elementType; 56 } 57 58 66 public MultipleListCriterion(MultipleListCriterion criterion) { 67 super(criterion); 68 setList(criterion.getList()); 69 this.elementType = criterion.getElementType(); 70 } 71 72 78 public void setPropertyValues(String [] values) { 79 80 if (values != null) { 81 Object [] objValues = new Object [values.length]; 82 for (int i = 0; i < objValues.length; i++) { 84 Class [] argTypes = new Class [] { String .class }; 85 try { 86 objValues[i] = ClassUtils.getInstance( 87 getElementType(), 88 argTypes, 89 new Object [] { values[i] } 90 ); 91 } catch (ClassUtilsException cue) { 92 throw new CriterionException(cue); 93 } 94 } 95 setValues(objValues); 96 } 97 } 98 99 105 public String [] getPropertyValues() { 106 return (String []) getValue(); 107 } 108 109 113 public void setValues(Object [] values) { 114 if (values != null) { 116 setValue(values); 117 } 118 } 119 120 125 private Class objectType = Object [].class; 126 127 131 private void setObjectType(Class type) { 132 this.objectType = type; 133 } 134 135 140 public Class getObjectType() { 141 return objectType; 142 } 143 144 149 public void setPropertyValue(String object) { 150 throw new UnsupportedOperationException ("The setPropertyValue with String argument is not supported"); 151 } 152 153 160 public Criterion getExprCriterion() { 161 Criterion crit = 162 new Criterion(getAssociatedEntity(), 163 getProperty().getName(), 164 OperatorTypes.IN, 165 (Object []) getValue()); 166 return crit; 167 } 168 169 174 public CriterionFormPattern getFormPattern() { 175 return CriterionFormPatterns.NO_OPERATOR_MULTIPLE_LIST; 176 } 177 178 181 private Class elementType = String .class; 182 183 public Class getElementType() { 184 return elementType; 185 } 186 187 public void setElementType(Class type) { 188 elementType = type; 189 } 190 } | Popular Tags |