Subversion Repositories SmartDukaan

Rev

Rev 12573 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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