View Javadoc

1   package org.apache.torque.mojo;
2   
3   import java.util.Properties;
4   
5   import org.apache.commons.lang.StringUtils;
6   
7   public class ImpexError {
8   	Throwable throwable;
9   	String message;
10  	Properties info;
11  	String url;
12  	String driver;
13  	boolean showPassword;
14  
15  	public Throwable getThrowable() {
16  		return throwable;
17  	}
18  
19  	public void setThrowable(Throwable throwable) {
20  		this.throwable = throwable;
21  	}
22  
23  	public String getMessage() {
24  		return message;
25  	}
26  
27  	public void setMessage(String message) {
28  		this.message = message;
29  	}
30  
31  	public Properties getInfo() {
32  		return info;
33  	}
34  
35  	public void setInfo(Properties info) {
36  		this.info = info;
37  	}
38  
39  	public String toString() {
40  		StringBuffer sb = new StringBuffer();
41  		sb.append("\n\n");
42  		if (!StringUtils.isEmpty(message)) {
43  			sb.append(message + "\n\n");
44  		}
45  		if (getThrowable() != null) {
46  			sb.append("------------------------------------------------------\n");
47  			String emsg = getThrowable().getMessage();
48  			sb.append(emsg);
49  			if (!emsg.endsWith("\n")) {
50  				sb.append("\n");
51  			}
52  		}
53  		sb.append(toString(getInfo()));
54  		return sb.toString();
55  	}
56  
57  	public String toString(Properties info) {
58  		StringBuffer sb = new StringBuffer();
59  		sb.append("------------------------------------------------------\n\n");
60  		sb.append("The following information was provided to JDBC:\n");
61  		sb.append("------------------------------------------------------\n");
62  		sb.append("URL: " + getUrl() + "\n");
63  		sb.append("Driver: " + getDriver() + "\n");
64  		String username = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_USER);
65  		if (StringUtils.isEmpty(username)) {
66  			sb.append("Username: [No username was supplied]\n");
67  		} else {
68  			sb.append("Username: " + username + "\n");
69  		}
70  		String password = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_PASSWORD);
71  		if (isShowPassword()) {
72  			sb.append("Password: " + password + "\n");
73  		} else {
74  			if (StringUtils.isEmpty(password)) {
75  				sb.append("Password: [No password was supplied]\n");
76  			} else {
77  				sb.append("Password: *******\n");
78  			}
79  		}
80  		sb.append("------------------------------------------------------\n");
81  		sb.append("\n");
82  		return sb.toString();
83  
84  	}
85  
86  	public String getUrl() {
87  		return url;
88  	}
89  
90  	public void setUrl(String url) {
91  		this.url = url;
92  	}
93  
94  	public String getDriver() {
95  		return driver;
96  	}
97  
98  	public void setDriver(String driver) {
99  		this.driver = driver;
100 	}
101 
102 	public boolean isShowPassword() {
103 		return showPassword;
104 	}
105 
106 	public void setShowPassword(boolean showPassword) {
107 		this.showPassword = showPassword;
108 	}
109 
110 }