Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12451 kshitij.so 1
 
2
package com.amazonaws.mws.model;
3
 
4
import java.util.ArrayList;
5
import java.util.List;
6
import javax.xml.bind.annotation.XmlAccessType;
7
import javax.xml.bind.annotation.XmlAccessorType;
8
import javax.xml.bind.annotation.XmlElement;
9
import javax.xml.bind.annotation.XmlRootElement;
10
import javax.xml.bind.annotation.XmlType;
11
 
12
 
13
/**
14
 * <p>Java class for anonymous complex type.
15
 * 
16
 * <p>The following schema fragment specifies the expected content contained within this class.
17
 * 
18
 * <pre>
19
 * &lt;complexType>
20
 *   &lt;complexContent>
21
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
22
 *       &lt;sequence>
23
 *         &lt;element ref="{http://mws.amazonaws.com/doc/2009-01-01/}Error" maxOccurs="unbounded"/>
24
 *         &lt;element name="RequestID" type="{http://www.w3.org/2001/XMLSchema}string"/>
25
 *       &lt;/sequence>
26
 *     &lt;/restriction>
27
 *   &lt;/complexContent>
28
 * &lt;/complexType>
29
 * </pre>
30
 * Generated by AWS Code Generator
31
 * <p/>
32
 * Wed Feb 18 13:28:59 PST 2009
33
 * 
34
 */
35
@XmlAccessorType(XmlAccessType.FIELD)
36
@XmlType(name = "", propOrder = {
37
    "error",
38
    "requestId"
39
})
40
@XmlRootElement(name = "ErrorResponse")
41
public class ErrorResponse {
42
 
43
    @XmlElement(name = "Error", required = true)
44
    protected List<Error> error;
45
    @XmlElement(name = "RequestID", required = true)
46
    protected String requestId;
47
 
48
    /**
49
     * Default constructor
50
     * 
51
     */
52
    public ErrorResponse() {
53
        super();
54
    }
55
 
56
    /**
57
     * Value constructor
58
     * 
59
     */
60
    public ErrorResponse(final List<Error> error, final String requestId) {
61
        this.error = error;
62
        this.requestId = requestId;
63
    }
64
 
65
    /**
66
     * Gets the value of the error property.
67
     * 
68
     * <p>
69
     * This accessor method returns a reference to the live list,
70
     * not a snapshot. Therefore any modification you make to the
71
     * returned list will be present inside the JAXB object.
72
     * This is why there is not a <CODE>set</CODE> method for the error property.
73
     * 
74
     * <p>
75
     * For example, to add a new item, do as follows:
76
     * <pre>
77
     *    getError().add(newItem);
78
     * </pre>
79
     * 
80
     * 
81
     * <p>
82
     * Objects of the following type(s) are allowed in the list
83
     * {@link Error }
84
     * 
85
     * 
86
     */
87
    public List<Error> getError() {
88
        if (error == null) {
89
            error = new ArrayList<Error>();
90
        }
91
        return this.error;
92
    }
93
 
94
    public boolean isSetError() {
95
        return ((this.error!= null)&&(!this.error.isEmpty()));
96
    }
97
 
98
    public void unsetError() {
99
        this.error = null;
100
    }
101
 
102
    /**
103
     * Gets the value of the requestId property.
104
     * 
105
     * @return
106
     *     possible object is
107
     *     {@link String }
108
     *     
109
     */
110
    public String getRequestId() {
111
        return requestId;
112
    }
113
 
114
    /**
115
     * Sets the value of the requestId property.
116
     * 
117
     * @param value
118
     *     allowed object is
119
     *     {@link String }
120
     *     
121
     */
122
    public void setRequestId(String value) {
123
        this.requestId = value;
124
    }
125
 
126
    public boolean isSetRequestId() {
127
        return (this.requestId!= null);
128
    }
129
 
130
    /**
131
     * Sets the value of the Error property.
132
     * 
133
     * @param values
134
     * @return
135
     *     this instance
136
     */
137
    public ErrorResponse withError(Error... values) {
138
        for (Error value: values) {
139
            getError().add(value);
140
        }
141
        return this;
142
    }
143
 
144
    /**
145
     * Sets the value of the RequestId property.
146
     * 
147
     * @param value
148
     * @return
149
     *     this instance
150
     */
151
    public ErrorResponse withRequestId(String value) {
152
        setRequestId(value);
153
        return this;
154
    }
155
 
156
    /**
157
     * Sets the value of the error property.
158
     * 
159
     * @param error
160
     *     allowed object is
161
     *     {@link Error }
162
     *     
163
     */
164
    public void setError(List<Error> error) {
165
        this.error = error;
166
    }
167
 
168
    @javax.xml.bind.annotation.XmlTransient
169
    private ResponseHeaderMetadata responseHeaderMetadata;
170
 
171
 
172
    public boolean isSetResponseHeaderMetadata() { 
173
        return this.responseHeaderMetadata != null;
174
    }  
175
 
176
 
177
    public void setResponseHeaderMetadata(ResponseHeaderMetadata responseHeaderMetadata) { 
178
        this.responseHeaderMetadata = responseHeaderMetadata;
179
    } 
180
 
181
 
182
    public ResponseHeaderMetadata getResponseHeaderMetadata() {  
183
        return responseHeaderMetadata;
184
    }
185
 
186
    /**
187
     * 
188
     * XML string representation of this object
189
     * 
190
     * @return XML String
191
     */
192
    public String toXML() {
193
        StringBuffer xml = new StringBuffer();
194
        xml.append("<ErrorResponse xmlns=\"http://mws.amazonaws.com/doc/2009-01-01/\">");
195
        java.util.List<Error> errorList = getError();
196
        for (Error error : errorList) {
197
            xml.append("<Error>");
198
            xml.append(error.toXMLFragment());
199
            xml.append("</Error>");
200
        }
201
        if (isSetRequestId()) {
202
            xml.append("<RequestID>");
203
            xml.append(escapeXML(getRequestId()));
204
            xml.append("</RequestID>");
205
        }
206
        xml.append("</ErrorResponse>");
207
        return xml.toString();
208
    }
209
 
210
    /**
211
     * 
212
     * Escape XML special characters
213
     */
214
    private String escapeXML(String string) {
215
        StringBuffer sb = new StringBuffer();
216
        int length = string.length();
217
        for (int i = 0; i < length; ++i) {
218
            char c = string.charAt(i);
219
            switch (c) {
220
            case '&':
221
                sb.append("&amp;");
222
                break;
223
            case '<':
224
                sb.append("&lt;");
225
                break;
226
            case '>':
227
                sb.append("&gt;");
228
                break;
229
            case '\'':
230
                sb.append("&#039;");
231
                break;
232
            case '"':
233
                sb.append("&quot;");
234
                break;
235
            default:
236
                sb.append(c);
237
            }
238
        }
239
        return sb.toString();
240
    }
241
 
242
 
243
 
244
    /**
245
     * 
246
     * JSON string representation of this object
247
     * 
248
     * @return JSON String
249
     */
250
    public String toJSON() {
251
        StringBuffer json = new StringBuffer();
252
        json.append("{\"ErrorResponse\" : {");
253
        json.append(quoteJSON("@xmlns"));
254
        json.append(" : ");
255
        json.append(quoteJSON("http://mws.amazonaws.com/doc/2009-01-01/"));
256
        boolean first = true;
257
        json.append(", ");
258
        if (isSetError()) {
259
            if (!first) json.append(", ");
260
            json.append("\"Error\" : [");
261
            java.util.List<Error> errorList = getError();
262
            for (Error error : errorList) {
263
                if (errorList.indexOf(error) > 0) json.append(", ");
264
                json.append("{");
265
                json.append("");
266
                json.append(error.toJSONFragment());
267
                json.append("}");
268
                first = false;
269
            }
270
            json.append("]");
271
        }
272
        if (isSetRequestId()) {
273
            if (!first) json.append(", ");
274
            json.append(quoteJSON("RequestID"));
275
            json.append(" : ");
276
            json.append(quoteJSON(getRequestId()));
277
            first = false;
278
        }
279
        json.append("}");
280
        json.append("}");
281
        return json.toString();
282
    }
283
 
284
    /**
285
     * 
286
     * Quote JSON string
287
     */
288
    private String quoteJSON(String string) {
289
        StringBuffer sb = new StringBuffer();
290
        sb.append("\"");
291
        int length = string.length();
292
        for (int i = 0; i < length; ++i) {
293
            char c = string.charAt(i);
294
            switch (c) {
295
            case '"':
296
                sb.append("\\\"");
297
                break;
298
            case '\\':
299
                sb.append("\\\\");
300
                break;
301
            case '/':
302
                sb.append("\\/");
303
                break;
304
            case '\b':
305
                sb.append("\\b");
306
                break;
307
            case '\f':
308
                sb.append("\\f");
309
                break;
310
            case '\n':
311
                sb.append("\\n");
312
                break;
313
            case '\r':
314
                sb.append("\\r");
315
                break;
316
            case '\t':
317
                sb.append("\\t");
318
                break;
319
            default:
320
                if (c <  ' ') {
321
                    sb.append("\\u" + String.format("%03x", Integer.valueOf(c)));
322
                } else {
323
                sb.append(c);
324
                }
325
            }
326
        }
327
        sb.append("\"");
328
        return sb.toString();
329
    }
330
 
331
 
332
}