Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7473 vikram.rag 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.XmlType;
10
 
11
 
12
/**
13
 * <p>Java class for MessageList complex type.
14
 * 
15
 * <p>The following schema fragment specifies the expected content contained within this class.
16
 * 
17
 * <pre>
18
 * &lt;complexType name="MessageList">
19
 *   &lt;complexContent>
20
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21
 *       &lt;sequence>
22
 *         &lt;element name="Message" type="{https://mws.amazonservices.com/Orders/2011-01-01}Message" maxOccurs="unbounded"/>
23
 *       &lt;/sequence>
24
 *     &lt;/restriction>
25
 *   &lt;/complexContent>
26
 * &lt;/complexType>
27
 * </pre>
28
 * 
29
 * 
30
 */
31
@XmlAccessorType(XmlAccessType.FIELD)
32
@XmlType(name = "MessageList", propOrder = {
33
    "message"
34
})
35
public class MessageList {
36
 
37
    @XmlElement(name = "Message", required = true)
38
    protected List<Message> message;
39
 
40
    /**
41
     * Default constructor
42
     * 
43
     */
44
    public MessageList() {
45
        super();
46
    }
47
 
48
    /**
49
     * Value constructor
50
     * 
51
     */
52
    public MessageList(final List<Message> message) {
53
        this.message = message;
54
    }
55
 
56
    /**
57
     * Gets the value of the message property.
58
     * 
59
     * <p>
60
     * This accessor method returns a reference to the live list,
61
     * not a snapshot. Therefore any modification you make to the
62
     * returned list will be present inside the JAXB object.
63
     * This is why there is not a <CODE>set</CODE> method for the message property.
64
     * 
65
     * <p>
66
     * For example, to add a new item, do as follows:
67
     * <pre>
68
     *    getMessage().add(newItem);
69
     * </pre>
70
     * 
71
     * 
72
     * <p>
73
     * Objects of the following type(s) are allowed in the list
74
     * {@link Message }
75
     * 
76
     * 
77
     */
78
    public List<Message> getMessage() {
79
        if (message == null) {
80
            message = new ArrayList<Message>();
81
        }
82
        return this.message;
83
    }
84
 
85
    public boolean isSetMessage() {
86
        return ((this.message!= null)&&(!this.message.isEmpty()));
87
    }
88
 
89
    public void unsetMessage() {
90
        this.message = null;
91
    }
92
 
93
    /**
94
     * Sets the value of the Message property.
95
     * 
96
     * @param values
97
     * @return
98
     *     this instance
99
     */
100
    public MessageList withMessage(Message... values) {
101
        for (Message value: values) {
102
            getMessage().add(value);
103
        }
104
        return this;
105
    }
106
 
107
    /**
108
     * Sets the value of the message property.
109
     * 
110
     * @param message
111
     *     allowed object is
112
     *     {@link Message }
113
     *     
114
     */
115
    public void setMessage(List<Message> message) {
116
        this.message = message;
117
    }
118
 
119
 
120
 
121
    /**
122
     * 
123
     * XML fragment representation of this object
124
     * 
125
     * @return XML fragment for this object. Name for outer
126
     * tag expected to be set by calling method. This fragment
127
     * returns inner properties representation only
128
     */
129
    public String toXMLFragment() {
130
        StringBuffer xml = new StringBuffer();
131
        java.util.List<Message> messageList = getMessage();
132
        for (Message message : messageList) {
133
            xml.append("<Message>");
134
            xml.append(message.toXMLFragment());
135
            xml.append("</Message>");
136
        }
137
        return xml.toString();
138
    }
139
 
140
    /**
141
     * 
142
     * Escape XML special characters
143
     */
144
    private String escapeXML(String string) {
145
        if (string == null)
146
            return "null";
147
        StringBuffer sb = new StringBuffer();
148
        int length = string.length();
149
        for (int i = 0; i < length; ++i) {
150
            char c = string.charAt(i);
151
            switch (c) {
152
            case '&':
153
                sb.append("&amp;");
154
                break;
155
            case '<':
156
                sb.append("&lt;");
157
                break;
158
            case '>':
159
                sb.append("&gt;");
160
                break;
161
            case '\'':
162
                sb.append("&#039;");
163
                break;
164
            case '"':
165
                sb.append("&quot;");
166
                break;
167
            default:
168
                sb.append(c);
169
            }
170
        }
171
        return sb.toString();
172
    }
173
 
174
 
175
 
176
    /**
177
     *
178
     * JSON fragment representation of this object
179
     *
180
     * @return JSON fragment for this object. Name for outer
181
     * object expected to be set by calling method. This fragment
182
     * returns inner properties representation only
183
     *
184
     */
185
    protected String toJSONFragment() {
186
        StringBuffer json = new StringBuffer();
187
        boolean first = true;
188
        if (isSetMessage()) {
189
            if (!first) json.append(", ");
190
            json.append("\"Message\" : [");
191
            java.util.List<Message> messageList = getMessage();
192
            int messageListIndex = 0;
193
            for (Message message : messageList) {
194
                if (messageListIndex > 0) json.append(", ");
195
                json.append("{");
196
                json.append("");
197
                json.append(message.toJSONFragment());
198
                json.append("}");
199
                first = false;
200
                ++messageListIndex;
201
            }
202
            json.append("]");
203
        }
204
        return json.toString();
205
    }
206
 
207
    /**
208
     *
209
     * Quote JSON string
210
     */
211
    private String quoteJSON(String string) {
212
        if (string == null)
213
            return "null";
214
        StringBuffer sb = new StringBuffer();
215
        sb.append("\"");
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("\\\"");
222
                break;
223
            case '\\':
224
                sb.append("\\\\");
225
                break;
226
            case '/':
227
                sb.append("\\/");
228
                break;
229
            case '\b':
230
                sb.append("\\b");
231
                break;
232
            case '\f':
233
                sb.append("\\f");
234
                break;
235
            case '\n':
236
                sb.append("\\n");
237
                break;
238
            case '\r':
239
                sb.append("\\r");
240
                break;
241
            case '\t':
242
                sb.append("\\t");
243
                break;
244
            default:
245
                if (c <  ' ') {
246
                    sb.append("\\u" + String.format("%03x", Integer.valueOf(c)));
247
                } else {
248
                sb.append(c);
249
            }
250
        }
251
        }
252
        sb.append("\"");
253
        return sb.toString();
254
    }
255
 
256
 
257
}