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.XmlAnyElement;
9
import javax.xml.bind.annotation.XmlElement;
10
import javax.xml.bind.annotation.XmlRootElement;
11
import javax.xml.bind.annotation.XmlType;
12
import org.w3c.dom.Element;
13
 
14
 
15
/**
16
 * <p>Java class for anonymous complex type.
17
 * 
18
 * <p>The following schema fragment specifies the expected content contained within this class.
19
 * 
20
 * <pre>
21
 * &lt;complexType>
22
 *   &lt;complexContent>
23
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
24
 *       &lt;sequence>
25
 *         &lt;element name="Type">
26
 *           &lt;simpleType>
27
 *             &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
28
 *               &lt;enumeration value="Receiver"/>
29
 *               &lt;enumeration value="Sender"/>
30
 *             &lt;/restriction>
31
 *           &lt;/simpleType>
32
 *         &lt;/element>
33
 *         &lt;element name="Code" type="{http://www.w3.org/2001/XMLSchema}string"/>
34
 *         &lt;element name="Message" type="{http://www.w3.org/2001/XMLSchema}string"/>
35
 *         &lt;element name="Detail">
36
 *           &lt;complexType>
37
 *             &lt;complexContent>
38
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
39
 *                 &lt;sequence>
40
 *                   &lt;any/>
41
 *                 &lt;/sequence>
42
 *               &lt;/restriction>
43
 *             &lt;/complexContent>
44
 *           &lt;/complexType>
45
 *         &lt;/element>
46
 *       &lt;/sequence>
47
 *     &lt;/restriction>
48
 *   &lt;/complexContent>
49
 * &lt;/complexType>
50
 * </pre>
51
 * Generated by AWS Code Generator
52
 * <p/>
53
 * Wed Feb 18 13:28:59 PST 2009
54
 * 
55
 */
56
@XmlAccessorType(XmlAccessType.FIELD)
57
@XmlType(name = "", propOrder = {
58
    "type",
59
    "code",
60
    "message",
61
    "detail"
62
})
63
@XmlRootElement(name = "Error")
64
public class Error {
65
 
66
    @XmlElement(name = "Type", required = true)
67
    protected String type;
68
    @XmlElement(name = "Code", required = true)
69
    protected String code;
70
    @XmlElement(name = "Message", required = true)
71
    protected String message;
72
    @XmlElement(name = "Detail", required = true)
73
    protected Error.Detail detail;
74
 
75
    /**
76
     * Default constructor
77
     * 
78
     */
79
    public Error() {
80
        super();
81
    }
82
 
83
    /**
84
     * Value constructor
85
     * 
86
     */
87
    public Error(final String type, final String code, final String message, final Error.Detail detail) {
88
        this.type = type;
89
        this.code = code;
90
        this.message = message;
91
        this.detail = detail;
92
    }
93
 
94
    /**
95
     * Gets the value of the type property.
96
     * 
97
     * @return
98
     *     possible object is
99
     *     {@link String }
100
     *     
101
     */
102
    public String getType() {
103
        return type;
104
    }
105
 
106
    /**
107
     * Sets the value of the type property.
108
     * 
109
     * @param value
110
     *     allowed object is
111
     *     {@link String }
112
     *     
113
     */
114
    public void setType(String value) {
115
        this.type = value;
116
    }
117
 
118
    public boolean isSetType() {
119
        return (this.type!= null);
120
    }
121
 
122
    /**
123
     * Gets the value of the code property.
124
     * 
125
     * @return
126
     *     possible object is
127
     *     {@link String }
128
     *     
129
     */
130
    public String getCode() {
131
        return code;
132
    }
133
 
134
    /**
135
     * Sets the value of the code property.
136
     * 
137
     * @param value
138
     *     allowed object is
139
     *     {@link String }
140
     *     
141
     */
142
    public void setCode(String value) {
143
        this.code = value;
144
    }
145
 
146
    public boolean isSetCode() {
147
        return (this.code!= null);
148
    }
149
 
150
    /**
151
     * Gets the value of the message property.
152
     * 
153
     * @return
154
     *     possible object is
155
     *     {@link String }
156
     *     
157
     */
158
    public String getMessage() {
159
        return message;
160
    }
161
 
162
    /**
163
     * Sets the value of the message property.
164
     * 
165
     * @param value
166
     *     allowed object is
167
     *     {@link String }
168
     *     
169
     */
170
    public void setMessage(String value) {
171
        this.message = value;
172
    }
173
 
174
    public boolean isSetMessage() {
175
        return (this.message!= null);
176
    }
177
 
178
    /**
179
     * Gets the value of the detail property.
180
     * 
181
     * @return
182
     *     possible object is
183
     *     {@link Error.Detail }
184
     *     
185
     */
186
    public Error.Detail getDetail() {
187
        return detail;
188
    }
189
 
190
    /**
191
     * Sets the value of the detail property.
192
     * 
193
     * @param value
194
     *     allowed object is
195
     *     {@link Error.Detail }
196
     *     
197
     */
198
    public void setDetail(Error.Detail value) {
199
        this.detail = value;
200
    }
201
 
202
    public boolean isSetDetail() {
203
        return (this.detail!= null);
204
    }
205
 
206
    /**
207
     * Sets the value of the Type property.
208
     * 
209
     * @param value
210
     * @return
211
     *     this instance
212
     */
213
    public Error withType(String value) {
214
        setType(value);
215
        return this;
216
    }
217
 
218
    /**
219
     * Sets the value of the Code property.
220
     * 
221
     * @param value
222
     * @return
223
     *     this instance
224
     */
225
    public Error withCode(String value) {
226
        setCode(value);
227
        return this;
228
    }
229
 
230
    /**
231
     * Sets the value of the Message property.
232
     * 
233
     * @param value
234
     * @return
235
     *     this instance
236
     */
237
    public Error withMessage(String value) {
238
        setMessage(value);
239
        return this;
240
    }
241
 
242
    /**
243
     * Sets the value of the Detail property.
244
     * 
245
     * @param value
246
     * @return
247
     *     this instance
248
     */
249
    public Error withDetail(Error.Detail value) {
250
        setDetail(value);
251
        return this;
252
    }
253
 
254
 
255
    /**
256
     * <p>Java class for anonymous complex type.
257
     * 
258
     * <p>The following schema fragment specifies the expected content contained within this class.
259
     * 
260
     * <pre>
261
     * &lt;complexType>
262
     *   &lt;complexContent>
263
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
264
     *       &lt;sequence>
265
     *         &lt;any/>
266
     *       &lt;/sequence>
267
     *     &lt;/restriction>
268
     *   &lt;/complexContent>
269
     * &lt;/complexType>
270
     * </pre>
271
     * Generated by AWS Code Generator
272
     * <p/>
273
     * Wed Feb 18 13:28:59 PST 2009
274
     * 
275
     */
276
    @XmlAccessorType(XmlAccessType.FIELD)
277
    @XmlType(name = "", propOrder = {
278
        "any"
279
    })
280
    public static class Detail {
281
 
282
        @XmlAnyElement(lax = true)
283
        protected List<Object> any;
284
 
285
        /**
286
         * Default constructor
287
         * 
288
         */
289
        public Detail() {
290
            super();
291
        }
292
 
293
        /**
294
         * Value constructor
295
         * 
296
         */
297
        public Detail(final List<Object> any) {
298
            this.any = any;
299
        }
300
 
301
        /**
302
         * Gets the value of the any property.
303
         * 
304
         * <p>
305
         * This accessor method returns a reference to the live list,
306
         * not a snapshot. Therefore any modification you make to the
307
         * returned list will be present inside the JAXB object.
308
         * This is why there is not a <CODE>set</CODE> method for the any property.
309
         * 
310
         * <p>
311
         * For example, to add a new item, do as follows:
312
         * <pre>
313
         *    getAny().add(newItem);
314
         * </pre>
315
         * 
316
         * 
317
         * <p>
318
         * Objects of the following type(s) are allowed in the list
319
         * {@link Element }
320
         * {@link Object }
321
         * 
322
         * 
323
         */
324
        public List<Object> getAny() {
325
            if (any == null) {
326
                any = new ArrayList<Object>();
327
            }
328
            return this.any;
329
        }
330
 
331
        public boolean isSetAny() {
332
            return ((this.any!= null)&&(!this.any.isEmpty()));
333
        }
334
 
335
        public void unsetAny() {
336
            this.any = null;
337
        }
338
 
339
        /**
340
         * Sets the value of the Any property.
341
         * 
342
         * @param values
343
         * @return
344
         *     this instance
345
         */
346
        public Error.Detail withAny(Object... values) {
347
            for (Object value: values) {
348
                getAny().add(value);
349
            }
350
            return this;
351
        }
352
 
353
        /**
354
         * Sets the value of the any property.
355
         * 
356
         * @param any
357
         *     allowed object is
358
         *     {@link Element }
359
         *     {@link Object }
360
         *     
361
         */
362
        public void setAny(List<Object> any) {
363
            this.any = any;
364
        }
365
 
366
    }
367
 
368
 
369
    /**
370
     * 
371
     * XML fragment representation of this object
372
     * 
373
     * @return XML fragment for this object. Name for outer
374
     * tag expected to be set by calling method. This fragment
375
     * returns inner properties representation only
376
     */
377
    protected String toXMLFragment() {
378
        StringBuffer xml = new StringBuffer();
379
        if (isSetType()) {
380
            xml.append("<Type>");
381
            xml.append(getType() + "");
382
            xml.append("</Type>");
383
        }
384
        if (isSetCode()) {
385
            xml.append("<Code>");
386
            xml.append(escapeXML(getCode()));
387
            xml.append("</Code>");
388
        }
389
        if (isSetMessage()) {
390
            xml.append("<Message>");
391
            xml.append(escapeXML(getMessage()));
392
            xml.append("</Message>");
393
        }
394
        if (isSetDetail()) {
395
            Error.Detail  detail = getDetail();
396
            xml.append("<Detail>");
397
            xml.append(detail.toString());
398
 
399
            xml.append("</Detail>");
400
        } 
401
        return xml.toString();
402
    }
403
 
404
    /**
405
     * 
406
     * Escape XML special characters
407
     */
408
    private String escapeXML(String string) {
409
        StringBuffer sb = new StringBuffer();
410
        int length = string.length();
411
        for (int i = 0; i < length; ++i) {
412
            char c = string.charAt(i);
413
            switch (c) {
414
            case '&':
415
                sb.append("&amp;");
416
                break;
417
            case '<':
418
                sb.append("&lt;");
419
                break;
420
            case '>':
421
                sb.append("&gt;");
422
                break;
423
            case '\'':
424
                sb.append("&#039;");
425
                break;
426
            case '"':
427
                sb.append("&quot;");
428
                break;
429
            default:
430
                sb.append(c);
431
            }
432
        }
433
        return sb.toString();
434
    }
435
 
436
 
437
 
438
    /**
439
     *
440
     * JSON fragment representation of this object
441
     *
442
     * @return JSON fragment for this object. Name for outer
443
     * object expected to be set by calling method. This fragment
444
     * returns inner properties representation only
445
     *
446
     */
447
    protected String toJSONFragment() {
448
        StringBuffer json = new StringBuffer();
449
        boolean first = true;
450
        if (isSetType()) {
451
            if (!first) json.append(", ");
452
            json.append(quoteJSON("Type"));
453
            json.append(" : ");
454
            json.append(quoteJSON(getType() + ""));
455
            first = false;
456
        }
457
        if (isSetCode()) {
458
            if (!first) json.append(", ");
459
            json.append(quoteJSON("Code"));
460
            json.append(" : ");
461
            json.append(quoteJSON(getCode()));
462
            first = false;
463
        }
464
        if (isSetMessage()) {
465
            if (!first) json.append(", ");
466
            json.append(quoteJSON("Message"));
467
            json.append(" : ");
468
            json.append(quoteJSON(getMessage()));
469
            first = false;
470
        }
471
        if (isSetDetail()) {
472
            if (!first) json.append(", ");
473
            json.append("\"Detail\" : {");
474
            Error.Detail  detail = getDetail();
475
 
476
 
477
            json.append(detail.toString());
478
 
479
            json.append("}");
480
            first = false;
481
        }
482
        return json.toString();
483
    }
484
 
485
    /**
486
     *
487
     * Quote JSON string
488
     */
489
    private String quoteJSON(String string) {
490
        StringBuffer sb = new StringBuffer();
491
        sb.append("\"");
492
        int length = string.length();
493
        for (int i = 0; i < length; ++i) {
494
            char c = string.charAt(i);
495
            switch (c) {
496
            case '"':
497
                sb.append("\\\"");
498
                break;
499
            case '\\':
500
                sb.append("\\\\");
501
                break;
502
            case '/':
503
                sb.append("\\/");
504
                break;
505
            case '\b':
506
                sb.append("\\b");
507
                break;
508
            case '\f':
509
                sb.append("\\f");
510
                break;
511
            case '\n':
512
                sb.append("\\n");
513
                break;
514
            case '\r':
515
                sb.append("\\r");
516
                break;
517
            case '\t':
518
                sb.append("\\t");
519
                break;
520
            default:
521
                if (c <  ' ') {
522
                    sb.append("\\u" + String.format("%03x", Integer.valueOf(c)));
523
                } else {
524
                sb.append(c);
525
            }
526
        }
527
        }
528
        sb.append("\"");
529
        return sb.toString();
530
    }
531
 
532
 
533
}