private void writeDestinationValue(Object destObj, Object destFieldValue, FieldMap fieldMap, Object srcObj) { boolean bypass = false; // don't map null to dest field if map-null="false" if (destFieldValue == null && !fieldMap.isDestMapNull()) { bypass = true; } // don't map "" to dest field if map-empty-string="false" if (destFieldValue != null && !fieldMap.isDestMapEmptyString() && destFieldValue.getClass().equals(String.class) && StringUtils.isEmpty((String) destFieldValue)) { bypass = true; } // trim string value if trim-strings="true" if (destFieldValue != null && fieldMap.isTrimStrings() && destFieldValue.getClass().equals(String.class)) { destFieldValue = ((String) destFieldValue).trim(); } if (!bypass) { eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_PRE_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap, srcObj, destObj, destFieldValue)); fieldMap.writeDestValue(destObj, destFieldValue); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_POST_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap, srcObj, destObj, destFieldValue)); } }
@Override public String toString() { StringBuffer sb = new StringBuffer(); if (getClassMap() != null) { sb.append("Type:").append(type).append("\n"); } if (getClassMap() != null) { sb.append("ClassMap:").append(getClassMap().toString()).append("\n"); } if (getFieldMap() != null) { sb.append("FieldMap:").append(getFieldMap().toString()).append("\n"); } if (getSourceObject() != null) { sb.append("SourceObject:").append(getSourceObject().toString()).append("\n"); } if (getDestinationObject() != null) { sb.append("DestinationObject:").append(getDestinationObject().toString()).append("\n"); } if (getDestinationValue() != null) { sb.append("DestinationValue:").append(getDestinationValue().toString()).append("\n"); } return sb.toString(); } }
public void fireEvent(DozerEvent event) { // If no listeners were specified, then just return. if (eventListeners == null) { return; } DozerEventType eventType = event.getType(); for (DozerEventListener listener : eventListeners) { switch (eventType) { case MAPPING_STARTED: listener.mappingStarted(event); break; case MAPPING_PRE_WRITING_DEST_VALUE: listener.preWritingDestinationValue(event); break; case MAPPING_POST_WRITING_DEST_VALUE: listener.postWritingDestinationValue(event); break; case MAPPING_FINISHED: listener.mappingFinished(event); break; default: MappingUtils.throwMappingException("Unsupported event type: " + eventType); break; } } }
public void fireEvent(DozerEvent event) { // If no listeners were specified, then just return. if (eventListeners == null) { return; } DozerEventType eventType = event.getType(); for (DozerEventListener listener : eventListeners) { switch (eventType) { case MAPPING_STARTED: listener.mappingStarted(event); break; case MAPPING_PRE_WRITING_DEST_VALUE: listener.preWritingDestinationValue(event); break; case MAPPING_POST_WRITING_DEST_VALUE: listener.postWritingDestinationValue(event); break; case MAPPING_FINISHED: listener.mappingFinished(event); break; default: MappingUtils.throwMappingException("Unsupported event type: " + eventType); break; } } }
@Override public String toString() { StringBuffer sb = new StringBuffer(); if (getClassMap() != null) { sb.append("Type:").append(type).append("\n"); } if (getClassMap() != null) { sb.append("ClassMap:").append(getClassMap().toString()).append("\n"); } if (getFieldMap() != null) { sb.append("FieldMap:").append(getFieldMap().toString()).append("\n"); } if (getSourceObject() != null) { sb.append("SourceObject:").append(getSourceObject().toString()).append("\n"); } if (getDestinationObject() != null) { sb.append("DestinationObject:").append(getDestinationObject().toString()).append("\n"); } if (getDestinationValue() != null) { sb.append("DestinationValue:").append(getDestinationValue().toString()).append("\n"); } return sb.toString(); } }
eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_PRE_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap, srcObj, destObj, destFieldValue)); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_POST_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap, srcObj, destObj, destFieldValue));
eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_PRE_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap, eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_POST_WRITING_DEST_VALUE, fieldMap.getClassMap(), fieldMap,
classMap = getClassMap(srcObj.getClass(), destType, mapId); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_STARTED, classMap, null, srcObj, result, null)); MappingUtils.throwMappingException(e); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_FINISHED, classMap, null, srcObj, result, null));
eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_STARTED, classMap, null, srcObj, result, null)); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_FINISHED, classMap, null, srcObj, result, null));
eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_STARTED, classMap, null, srcObj, result, null)); eventMgr.fireEvent(new DozerEvent(DozerEventType.MAPPING_FINISHED, classMap, null, srcObj, result, null));