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  
20  package com.commsen.jwebthumb;
21  
22  import java.util.Date;
23  
24  import org.apache.commons.lang.builder.ReflectionToStringBuilder;
25  import org.simpleframework.xml.Attribute;
26  import org.simpleframework.xml.Text;
27  
28  /***
29   * This class represents 'jobStatus/status' part of webthumb's response to "status" API call. See <a
30   * href="http://webthumb.bluga.net/apidoc#status">http://webthumb.bluga.net/apidoc#status</a> for
31   * details
32   * 
33   * @author <a href="mailto:MilenDyankov@gmail.com">Milen Dyankov</a>
34   * @since 0.3
35   * 
36   */
37  public class WebThumbStatus {
38  
39  	@Attribute(required = false)
40  	private String id;
41  
42  	@Attribute(required = false)
43  	private Date submissionTime;
44  
45  	@Attribute(required = false)
46  	private int browserWidth;
47  
48  	@Attribute(required = false)
49  	private int browserHeight;
50  
51  	@Attribute(required = false)
52  	private int inProcess = 0;
53  
54  	@Attribute(name = "pickup", required = false)
55  	private String pickupURL;
56  
57  	@Attribute(required = false)
58  	private Date completionTime;
59  
60  	@Text(required = false)
61  	private String value = null;
62  
63  
64  	/***
65  	 * @return the id
66  	 */
67  	public String getId() {
68  		return this.id;
69  	}
70  
71  
72  	/***
73  	 * @return the submissionTime
74  	 */
75  	public Date getSubmissionTime() {
76  		return this.submissionTime == null ? null : (Date) this.submissionTime.clone();
77  	}
78  
79  
80  	/***
81  	 * @return the browserWidth
82  	 */
83  	public int getBrowserWidth() {
84  		return this.browserWidth;
85  	}
86  
87  
88  	/***
89  	 * @return the browserHeight
90  	 */
91  	public int getBrowserHeight() {
92  		return this.browserHeight;
93  	}
94  
95  
96  	/***
97  	 * @return the inProcess
98  	 */
99  	public boolean isInProcess() {
100 		return inProcess == 1;
101 	}
102 
103 
104 	/***
105 	 * @return the inProcess
106 	 */
107 	public boolean isCompleted() {
108 		return value != null && value.equals("Complete");
109 	}
110 
111 
112 	/***
113 	 * @return the pickupURL
114 	 */
115 	public String getPickupURL() {
116 		return this.pickupURL;
117 	}
118 
119 
120 	/***
121 	 * @return the completionTime
122 	 */
123 	public Date getCompletionTime() {
124 		return this.completionTime == null ? null : (Date) this.completionTime.clone();
125 	}
126 
127 
128 	@Override
129 	public String toString() {
130 		return new ReflectionToStringBuilder(this).toString();
131 	}
132 
133 }