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 javax.xml.bind.annotation.XmlAccessType;
5
import javax.xml.bind.annotation.XmlAccessorType;
6
import javax.xml.bind.annotation.XmlElement;
7
import javax.xml.bind.annotation.XmlType;
8
 
9
 
10
/**
11
 * <p>Java class for Message complex type.
12
 * 
13
 * <p>The following schema fragment specifies the expected content contained within this class.
14
 * 
15
 * <pre>
16
 * &lt;complexType name="Message">
17
 *   &lt;complexContent>
18
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
19
 *       &lt;sequence>
20
 *         &lt;element name="Locale" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
21
 *         &lt;element name="Text" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
22
 *       &lt;/sequence>
23
 *     &lt;/restriction>
24
 *   &lt;/complexContent>
25
 * &lt;/complexType>
26
 * </pre>
27
 * 
28
 * 
29
 */
30
@XmlAccessorType(XmlAccessType.FIELD)
31
@XmlType(name = "Message", propOrder = {
32
    "locale",
33
    "text"
34
})
35
public class Message {
36
 
37
    @XmlElement(name = "Locale")
38
    protected String locale;
39
    @XmlElement(name = "Text")
40
    protected String text;
41
 
42
    /**
43
     * Default constructor
44
     * 
45
     */
46
    public Message() {
47
        super();
48
    }
49
 
50
    /**
51
     * Value constructor
52
     * 
53
     */
54
    public Message(final String locale, final String text) {
55
        this.locale = locale;
56
        this.text = text;
57
    }
58
 
59
    /**
60
     * Gets the value of the locale property.
61
     * 
62
     * @return
63
     *     possible object is
64
     *     {@link String }
65
     *     
66
     */
67
    public String getLocale() {
68
        return locale;
69
    }
70
 
71
    /**
72
     * Sets the value of the locale property.
73
     * 
74
     * @param value
75
     *     allowed object is
76
     *     {@link String }
77
     *     
78
     */
79
    public void setLocale(String value) {
80
        this.locale = value;
81
    }
82
 
83
    public boolean isSetLocale() {
84
        return (this.locale!= null);
85
    }
86
 
87
    /**
88
     * Gets the value of the text property.
89
     * 
90
     * @return
91
     *     possible object is
92
     *     {@link String }
93
     *     
94
     */
95
    public String getText() {
96
        return text;
97
    }
98
 
99
    /**
100
     * Sets the value of the text property.
101
     * 
102
     * @param value
103
     *     allowed object is
104
     *     {@link String }
105
     *     
106
     */
107
    public void setText(String value) {
108
        this.text = value;
109
    }
110
 
111
    public boolean isSetText() {
112
        return (this.text!= null);
113
    }
114
 
115
    /**
116
     * Sets the value of the Locale property.
117
     * 
118
     * @param value
119
     * @return
120
     *     this instance
121
     */
122
    public Message withLocale(String value) {
123
        setLocale(value);
124
        return this;
125
    }
126
 
127
    /**
128
     * Sets the value of the Text property.
129
     * 
130
     * @param value
131
     * @return
132
     *     this instance
133
     */
134
    public Message withText(String value) {
135
        setText(value);
136
        return this;
137
    }
138
 
139
 
140
 
141
    /**
142
     * 
143
     * XML fragment representation of this object
144
     * 
145
     * @return XML fragment for this object. Name for outer
146
     * tag expected to be set by calling method. This fragment
147
     * returns inner properties representation only
148
     */
149
    public String toXMLFragment() {
150
        StringBuffer xml = new StringBuffer();
151
        if (isSetLocale()) {
152
            xml.append("<Locale>");
153
            xml.append(escapeXML(getLocale()));
154
            xml.append("</Locale>");
155
        }
156
        if (isSetText()) {
157
            xml.append("<Text>");
158
            xml.append(escapeXML(getText()));
159
            xml.append("</Text>");
160
        }
161
        return xml.toString();
162
    }
163
 
164
    /**
165
     * 
166
     * Escape XML special characters
167
     */
168
    private String escapeXML(String string) {
169
        if (string == null)
170
            return "null";
171
        StringBuffer sb = new StringBuffer();
172
        int length = string.length();
173
        for (int i = 0; i < length; ++i) {
174
            char c = string.charAt(i);
175
            switch (c) {
176
            case '&':
177
                sb.append("&amp;");
178
                break;
179
            case '<':
180
                sb.append("&lt;");
181
                break;
182
            case '>':
183
                sb.append("&gt;");
184
                break;
185
            case '\'':
186
                sb.append("&#039;");
187
                break;
188
            case '"':
189
                sb.append("&quot;");
190
                break;
191
            default:
192
                sb.append(c);
193
            }
194
        }
195
        return sb.toString();
196
    }
197
 
198
 
199
 
200
    /**
201
     *
202
     * JSON fragment representation of this object
203
     *
204
     * @return JSON fragment for this object. Name for outer
205
     * object expected to be set by calling method. This fragment
206
     * returns inner properties representation only
207
     *
208
     */
209
    protected String toJSONFragment() {
210
        StringBuffer json = new StringBuffer();
211
        boolean first = true;
212
        if (isSetLocale()) {
213
            if (!first) json.append(", ");
214
            json.append(quoteJSON("Locale"));
215
            json.append(" : ");
216
            json.append(quoteJSON(getLocale()));
217
            first = false;
218
        }
219
        if (isSetText()) {
220
            if (!first) json.append(", ");
221
            json.append(quoteJSON("Text"));
222
            json.append(" : ");
223
            json.append(quoteJSON(getText()));
224
            first = false;
225
        }
226
        return json.toString();
227
    }
228
 
229
    /**
230
     *
231
     * Quote JSON string
232
     */
233
    private String quoteJSON(String string) {
234
        if (string == null)
235
            return "null";
236
        StringBuffer sb = new StringBuffer();
237
        sb.append("\"");
238
        int length = string.length();
239
        for (int i = 0; i < length; ++i) {
240
            char c = string.charAt(i);
241
            switch (c) {
242
            case '"':
243
                sb.append("\\\"");
244
                break;
245
            case '\\':
246
                sb.append("\\\\");
247
                break;
248
            case '/':
249
                sb.append("\\/");
250
                break;
251
            case '\b':
252
                sb.append("\\b");
253
                break;
254
            case '\f':
255
                sb.append("\\f");
256
                break;
257
            case '\n':
258
                sb.append("\\n");
259
                break;
260
            case '\r':
261
                sb.append("\\r");
262
                break;
263
            case '\t':
264
                sb.append("\\t");
265
                break;
266
            default:
267
                if (c <  ' ') {
268
                    sb.append("\\u" + String.format("%03x", Integer.valueOf(c)));
269
                } else {
270
                sb.append(c);
271
            }
272
        }
273
        }
274
        sb.append("\"");
275
        return sb.toString();
276
    }
277
 
278
 
279
}