1 16 package net.sf.dozer.util.mapping.fieldmap; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 import net.sf.dozer.util.mapping.util.MapperConstants; 22 23 29 public class ClassMap { 30 31 private DozerClass sourceClass; 32 private DozerClass destClass; 33 private List fieldMaps = new ArrayList (); 34 private List allowedExceptions = new ArrayList (); 35 private String type; 36 private String dateFormat; 37 private String beanFactory; 38 private boolean mapNull = MapperConstants.DEFAULT_MAP_NULL_POLICY; 39 private boolean mapEmptyString = MapperConstants.DEFAULT_MAP_EMPTY_STRING_POLICY; 40 private boolean wildcard = MapperConstants.DEFAULT_WILDCARD_POLICY; 41 private boolean stopOnErrors = MapperConstants.DEFAULT_ERROR_POLICY; 42 private boolean wildcardOveridden = false; 43 private boolean stopOnErrorsOveridden = false; 44 private boolean isAccessible; 45 private boolean isAccessibleOverriden; 46 private Configuration configuration = new Configuration(); 47 private String mapId; 48 49 public List getFieldMaps() { 50 return fieldMaps; 51 } 52 53 public boolean getStopOnErrors() { 54 return stopOnErrors; 55 } 56 57 public void setStopOnErrors(boolean stopOnErrors) { 58 this.stopOnErrors = stopOnErrors; 59 this.setStopOnErrorsOveridden(true); 60 } 61 public List getAllowedExceptions() { 62 return allowedExceptions; 63 } 64 65 public void setAllowedExceptions(List allowedExceptions) { 66 this.allowedExceptions = allowedExceptions; 67 } 68 69 public FieldMap getFieldMapUsingDest(String destFieldName) { 70 FieldMap result = null; 71 72 if (fieldMaps != null) { 73 int size = fieldMaps.size(); 74 for (int i = 0; i < size; i++) { 75 FieldMap fieldMap = (FieldMap) fieldMaps.get(i); 76 String fieldName = fieldMap.getDestField().getName(); 77 78 if ((fieldName != null) && fieldName.equals(destFieldName)) { 79 result = fieldMap; 80 break; 81 } 82 } 83 } 84 return result; 85 } 86 87 public FieldMap getFieldMapUsingSource(String sourceFieldName) { 88 FieldMap result = null; 89 90 if (fieldMaps != null) { 91 for (int i = 0; i < fieldMaps.size(); i++) { 92 FieldMap fieldMap = (FieldMap) fieldMaps.get(i); 93 String fieldName = fieldMap.getSourceField().getName(); 94 95 if ((fieldName != null) && fieldName.equals(sourceFieldName)) { 96 result = fieldMap; 97 break; 98 } 99 } 100 } 101 return result; 102 } 103 104 public void setFieldMaps(List fieldMaps) { 105 this.fieldMaps = fieldMaps; 106 } 107 108 public void addFieldMapping(FieldMap fieldMap) { 109 fieldMaps.add(fieldMap); 110 } 111 112 public void removeFieldMapping(FieldMap fieldMap) { 113 fieldMaps.remove(fieldMap); 114 } 115 116 public boolean isWildcard() { 117 return wildcard; 118 } 119 120 public boolean getWildcard() { 121 return wildcard; 122 } 123 124 public void setWildcard(boolean wildcardPolicy) { 125 this.wildcard = wildcardPolicy; 126 this.setWildcardOveridden(true); 127 } 128 129 public String getType() { 130 return type; 131 } 132 133 public void setType(String type) { 134 this.type = type; 135 } 136 137 public String getDateFormat() { 138 return dateFormat; 139 } 140 141 public void setDateFormat(String dateFormat) { 142 this.dateFormat = dateFormat; 143 } 144 145 public boolean getStopOnErrorsOveridden() { 146 return stopOnErrorsOveridden; 147 } 148 149 public void setStopOnErrorsOveridden(boolean stopOnErrorsOveridden) { 150 this.stopOnErrorsOveridden = stopOnErrorsOveridden; 151 } 152 153 public boolean getWildcardOveridden() { 154 return wildcardOveridden; 155 } 156 157 public void setWildcardOveridden(boolean wildcardOveridden) { 158 this.wildcardOveridden = wildcardOveridden; 159 } 160 161 public Configuration getConfiguration() { 162 return configuration; 163 } 164 165 public void setConfiguration(Configuration configuration) { 166 this.configuration = configuration; 167 } 168 169 public DozerClass getSourceClass() { 170 return sourceClass; 171 } 172 173 public void setSourceClass(DozerClass sourceClass) { 174 this.sourceClass = sourceClass; 175 } 176 177 public DozerClass getDestClass() { 178 return destClass; 179 } 180 181 public void setDestClass(DozerClass destClass) { 182 this.destClass = destClass; 183 } 184 185 public String getBeanFactory() { 186 return beanFactory; 187 } 188 189 public void setBeanFactory(String beanFactory) { 190 this.beanFactory = beanFactory; 191 } 192 193 public String getMapId() { 194 return mapId; 195 } 196 197 public void setMapId(String mapId) { 198 this.mapId = mapId; 199 } 200 201 public boolean isAccessible() { 202 return isAccessible; 203 } 204 205 public void setAccessible(boolean isAccessible) { 206 this.isAccessible = isAccessible; 207 this.isAccessibleOverriden = true; 208 } 209 210 public boolean isAccessibleOverriden() { 211 return isAccessibleOverriden; 212 } 213 214 public void setAccessibleOverriden(boolean isAccessibleOverriden) { 215 this.isAccessibleOverriden = isAccessibleOverriden; 216 } 217 218 public boolean getMapNull() { 219 return mapNull; 220 } 221 222 public void setMapNull(boolean mapNull) { 223 this.mapNull = mapNull; 224 } 225 226 public boolean getMapEmptyString() { 227 return mapEmptyString; 228 } 229 230 public void setMapEmptyString(boolean mapEmptyString) { 231 this.mapEmptyString = mapEmptyString; 232 } 233 } 234 | Popular Tags |