View Javadoc

1   package eu.scape_project.watch.utils;
2   
3   import javax.xml.bind.annotation.XmlTransient;
4   
5   @javax.xml.bind.annotation.XmlRootElement
6   public class ApiResponse {
7   	public static final int ERROR = 1;
8   	public static final int WARNING = 2;
9   	public static final int INFO = 3;
10  	public static final int OK = 4;
11  	public static final int TOO_BUSY = 5;
12  
13  	private int code;
14  	private String type;
15  	private String message;
16  
17  	public ApiResponse() {
18  	}
19  
20  	public ApiResponse(int code, String message) {
21  		this.code = code;
22  		switch (code) {
23  		case ERROR:
24  			setType("error");
25  			break;
26  		case WARNING:
27  			setType("warning");
28  			break;
29  		case INFO:
30  			setType("info");
31  			break;
32  		case OK:
33  			setType("ok");
34  			break;
35  		case TOO_BUSY:
36  			setType("too busy");
37  			break;
38  		default:
39  			setType("unknown");
40  			break;
41  		}
42  		this.message = message;
43  	}
44  
45  	@XmlTransient
46  	public int getCode() {
47  		return code;
48  	}
49  
50  	public void setCode(int code) {
51  		this.code = code;
52  	}
53  
54  	public String getType() {
55  		return type;
56  	}
57  
58  	public final void setType(String type) {
59  		this.type = type;
60  	}
61  
62  	public String getMessage() {
63  		return message;
64  	}
65  
66  	public void setMessage(String message) {
67  		this.message = message;
68  	}
69  }