View Javadoc

1   /*
2    * Copyright 2004-2005 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.morph.transform;
17  
18  import net.sf.composite.util.ObjectUtils;
19  import net.sf.morph.MorphException;
20  
21  /**
22   * @author Matt Sgarlata
23   * @since Nov 26, 2004
24   */
25  public class TransformationException extends MorphException {
26  
27  	public TransformationException() {
28  		super();
29  	}
30  	public TransformationException(String message) {
31  		super(message);
32  	}
33  	public TransformationException(String message, Throwable cause) {
34  		super(message, cause);
35  	}
36  	public TransformationException(Throwable cause) {
37  		super(cause);
38  	}
39  	public TransformationException(Class destinationClass, Object source) {
40  		this(destinationClass, source, null, null);
41  	}
42  	public TransformationException(Class destinationClass, Object source,
43  		Throwable t) {
44  		this(destinationClass, source, t, null);
45  	}
46  	public TransformationException(Class destinationClass, Object source,
47  		Throwable t, String message) {
48  		super("Unable to convert " + ObjectUtils.getObjectDescription(source)
49  				+ " to " + destinationClass
50  				+ (ObjectUtils.isEmpty(message) ? "" : " because " + message),
51  				t);
52  	}
53  	
54  	public TransformationException(Object destination, Object source, Throwable t) {
55  		super("Unable to copy from " + ObjectUtils.getObjectDescription(source)
56  			+ " to " + ObjectUtils.getObjectDescription(destination), t);
57  	}
58  	
59  	public TransformationException(Object destination, Object source) {
60  		this(destination, source, null);
61  	}
62  
63  }