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 org.apache.commons.lang.Validate;
22  import org.apache.commons.lang.builder.ToStringBuilder;
23  import org.simpleframework.xml.Element;
24  
25  /***
26   * This class represents the payload of webthumb's 'fetch' API call. See <a
27   * href="http://webthumb.bluga.net/apidoc#fetch">http://webthumb.bluga.net/apidoc#fetch</a> for
28   * details
29   * 
30   * @author <a href="mailto:MilenDyankov@gmail.com">Milen Dyankov</a>
31   * @see http://webthumb.bluga.net/apidoc#fetch
32   * 
33   */
34  public class WebThumbFetchRequest {
35  
36  	/***
37  	 * Enumeration contains all sizes acceptable by webthumb's fetch method For more details check
38  	 * webthumb API at http://webthumb.bluga.net/apidoc#fetch
39  	 * 
40  	 * @author <a href="mailto:MilenDyankov@gmail.com">Milen Dyankov</a>
41  	 * 
42  	 */
43  	public static enum Size {
44  		small, medium, medium2, large, full, excerpt, effect, custom, zip
45  	};
46  
47  	@Element
48  	private String job;
49  
50  	@Element
51  	private Size size;
52  
53  
54  	/***
55  	 * Constructs new fetch request to webthumb.bluga.net
56  	 * 
57  	 * @param job - the job id
58  	 * @param size - the size of the file
59  	 */
60  	public WebThumbFetchRequest(String job, Size size) {
61  		Validate.notNull(job, "job is null!");
62  		Validate.notNull(size, "size is null!");
63  		this.job = job;
64  		this.size = size;
65  	}
66  
67  
68  	@Override
69  	public String toString() {
70  		return new ToStringBuilder(this).append("job", job).append("size", size).toString();
71  	}
72  
73  }