Class DefaultMappingContext

java.lang.Object
org.springframework.binding.mapping.impl.DefaultMappingContext

public class DefaultMappingContext extends Object
Default mapping context implementation.
Author:
Keith Donald, Scott Andrews
  • Constructor Details

    • DefaultMappingContext

      public DefaultMappingContext(Object source, Object target)
  • Method Details

    • getSource

      public Object getSource()
      The object being mapped from.
    • getTarget

      public Object getTarget()
      The object being mapped to.
    • getCurrentMapping

      public Mapping getCurrentMapping()
      Returns the current mapping.
      Returns:
      the current mapping
    • setCurrentMapping

      public void setCurrentMapping(Mapping mapping)
      Sets the current mapping. Called when a single mapping operation is about to begin. This updates progress of the overall mapping transaction.
      Parameters:
      mapping - the mapping to make the current mapping
    • setSuccessResult

      public void setSuccessResult(Object originalValue, Object mappedValue)
      Indicates the current mapping completed successfully.
      Parameters:
      originalValue - the original value from the source of the mapping
      mappedValue - the successfully mapped value, which may be different from the original if a type conversion was performed
    • setRequiredErrorResult

      public void setRequiredErrorResult(Object originalValue)
      Indicates the current mapping ended with a 'required' error. This means the value obtained from the source was empty, and the mapping could not be completed as a result.
      Parameters:
      originalValue - the original source value that is empty (null or an empty string, typically)
    • setTypeConversionErrorResult

      public void setTypeConversionErrorResult(Object originalValue, Exception cause)
      Indicates the current mapping ended with a 'type conversion' error. This means the value obtained from the source could not be converted to a type that could be assigned to the target expression.
      Parameters:
      originalValue - the original source value that is empty (null or an empty string, typically)
      cause - the actual type conversion exception that occurred
    • setSourceAccessError

      public void setSourceAccessError(EvaluationException error)
      Indicates a error occurred accessing the source mapping expression.
      Parameters:
      error - the error that occurred
    • setTargetAccessError

      public void setTargetAccessError(Object originalValue, EvaluationException error)
      Indicates a error occurred accessing the target mapping expression.
      Parameters:
      error - the error that occurred
    • getMappingResults

      public MappingResults getMappingResults()
      Returns the mapping results recorded in this context.
      Returns:
      the mapping results