View Javadoc

1   /*
2    * Copyright (c) 2010 Commsen International. All rights reserved.
3    * 
4    * This file is part of JWebThumb library.
5    *	
6    * JWebThumb library is free software: you can redistribute it and/or modify 
7    * it under the terms of the GNU Lesser General Public License as published by
8    * the Free Software Foundation, either version 2 of the License, or
9    * (at your option) any later version.
10   * 
11   * JWebThumb library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JWebThumb library.  If not, see <http://www.gnu.org/licenses/lgpl.html>.
18   */
19  package com.commsen.jwebthumb;
20  
21  import java.util.List;
22  
23  import org.apache.commons.lang.builder.ToStringBuilder;
24  import org.simpleframework.xml.Element;
25  import org.simpleframework.xml.ElementList;
26  import org.simpleframework.xml.Root;
27  
28  /***
29   * This class represent webthumb's general response object. It will contain different values for
30   * different requests ("credits", "request", "status").
31   * 
32   * <ul>
33   * <li>
34   * For "requests" it will contain list of {@link WebThumbJob} in {@link #jobs} field. In this case
35   * {@link #credits} and {@link #jobStatuses} will be null;
36   * <li>
37   * For "credits" is will have {@link #credits} initialized with {@link WebThumbCredits} object. In
38   * this case {@link #jobs} and {@link #jobStatuses} will be null.
39   * <li>
40   * For "status" is will contain list of {@link WebThumbJobStatus} in {@link #jobStatuses} field. In
41   * this case {@link #credits} and {@link #jobs} will be null.
42   * </ul>
43   * 
44   * @author <a href="mailto:MilenDyankov@gmail.com">Milen Dyankov</a>
45   * @see http://webthumb.bluga.net/apidoc#credits
46   * @see http://webthumb.bluga.net/apidoc#requests
47   * @see http://webthumb.bluga.net/apidoc#status
48   * 
49   */
50  @Root(name = "webthumb")
51  public class WebThumbResponse {
52  
53  	@ElementList(required = false, name = "jobs", entry = "job", type = WebThumbJob.class)
54  	private List<WebThumbJob> jobs;
55  
56  	@Element(required = false, name = "jobStatus")
57  	private WebThumbJobStatus jobStatus;
58  
59  	@Element(required = false)
60  	private WebThumbCredits credits;
61  
62  	@Element(required = false)
63  	private WebThumbError error;
64  
65  	@ElementList(required = false, name = "errors", entry = "error", type = WebThumbError.class)
66  	private List<WebThumbError> errors;
67  
68  
69  	/***
70  	 * @return the jobs
71  	 */
72  	public List<WebThumbJob> getJobs() {
73  		return this.jobs;
74  	}
75  
76  
77  	/***
78  	 * @return the credits
79  	 */
80  	public WebThumbCredits getCredits() {
81  		return this.credits;
82  	}
83  
84  
85  	/***
86  	 * @return the error
87  	 */
88  	public WebThumbError getError() {
89  		return this.error;
90  	}
91  
92  
93  	/***
94  	 * @return the error
95  	 */
96  	public List<WebThumbError> getErrors() {
97  		return this.errors;
98  	}
99  
100 
101 	/*
102 	 * (non-Javadoc)
103 	 * @see java.lang.Object#toString()
104 	 */
105 	@Override
106 	public String toString() {
107 		ToStringBuilder toStringBuilder = new ToStringBuilder(this);
108 		if (credits != null) {
109 			toStringBuilder.append("credits", credits);
110 		}
111 		if (jobs != null) {
112 			toStringBuilder.append("jobs", jobs);
113 		}
114 		if (jobStatus != null) {
115 			toStringBuilder.append("jobStatus", jobStatus);
116 		}
117 		if (error != null) {
118 			toStringBuilder.append("error", error);
119 		}
120 		if (errors != null) {
121 			toStringBuilder.append("errors", errors);
122 		}
123 		return toStringBuilder.toString();
124 	}
125 
126 
127 	/***
128 	 * @return the jobStatus
129 	 */
130 	public WebThumbJobStatus getJobStatus() {
131 		return this.jobStatus;
132 	}
133 }