Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / images / OutputSettings.java
blob4e054e442c84e01380d721c627e7b4fb8768e8ef
1 // Copyright 2010 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.images;
5 import com.google.appengine.api.images.ImagesService.OutputEncoding;
7 /**
8 * {@code OutputSettings} represents the different settings to specify how
9 * a particular transform or composite will return an {@link Image}.
12 public class OutputSettings {
13 /**
14 * The output encoding of the image.
16 private OutputEncoding outputEncoding;
18 /**
19 * The quality of the returned image. The number should be between 1 and 100
20 * when set. This value should only be set for
21 * JPEG encoding and will not be honored for other encodings.
23 private int quality = -1;
25 public OutputSettings(OutputEncoding outputEncoding) {
26 this.outputEncoding = outputEncoding;
29 /**
30 * Gets the output encoding.
31 * @return The output encoding.
33 public OutputEncoding getOutputEncoding() {
34 return outputEncoding;
37 /**
38 * Sets the output encoding.
39 * @param outputEncoding The encoding to set.
41 public void setOutputEncoding(OutputEncoding outputEncoding) {
42 this.outputEncoding = outputEncoding;
45 /**
46 * Gets the quality.
47 * @return If the quality has been set, a value between 1 and 100.
48 * Otherwise, it returns -1.
50 public int getQuality() {
51 return quality;
54 /**
55 * Sets the quality of the returned image. Value must be between
56 * 1 and 100.
57 * @param quality The quality to set.
58 * @throws IllegalArgumentException if quality is not between 1 and 100.
60 public void setQuality(int quality) {
61 if (quality >= 1 && quality <= 100) {
62 this.quality = quality;
63 } else {
64 throw new IllegalArgumentException("Trying to set an invalid quality: " +
65 quality + ". Value must be between 1 and 100.");
69 /**
70 * Checks if the quality value has been set.
71 * @return If the quality has been set, true. Otherwise, false.
73 public boolean hasQuality() {
74 return this.quality != -1;