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 PaymentMethodList complex type.
14
 * 
15
 * <p>The following schema fragment specifies the expected content contained within this class.
16
 * 
17
 * <pre>
18
 * &lt;complexType name="PaymentMethodList">
19
 *   &lt;complexContent>
20
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
21
 *       &lt;sequence>
22
 *         &lt;element name="Method" type="{https://mws.amazonservices.com/Orders/2011-01-01}PaymentMethodEnum" maxOccurs="50"/>
23
 *       &lt;/sequence>
24
 *     &lt;/restriction>
25
 *   &lt;/complexContent>
26
 * &lt;/complexType>
27
 * </pre>
28
 * 
29
 * 
30
 */
31
@XmlAccessorType(XmlAccessType.FIELD)
32
@XmlType(name = "PaymentMethodList", propOrder = {
33
    "method"
34
})
35
public class PaymentMethodList {
36
 
37
    @XmlElement(name = "Method", required = true)
38
    protected List<PaymentMethodEnum> method;
39
 
40
    /**
41
     * Default constructor
42
     * 
43
     */
44
    public PaymentMethodList() {
45
        super();
46
    }
47
 
48
    /**
49
     * Value constructor
50
     * 
51
     */
52
    public PaymentMethodList(final List<PaymentMethodEnum> method) {
53
        this.method = method;
54
    }
55
 
56
    /**
57
     * Gets the value of the method 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 method property.
64
     * 
65
     * <p>
66
     * For example, to add a new item, do as follows:
67
     * <pre>
68
     *    getMethod().add(newItem);
69
     * </pre>
70
     * 
71
     * 
72
     * <p>
73
     * Objects of the following type(s) are allowed in the list
74
     * {@link PaymentMethodEnum }
75
     * 
76
     * 
77
     */
78
    public List<PaymentMethodEnum> getMethod() {
79
        if (method == null) {
80
            method = new ArrayList<PaymentMethodEnum>();
81
        }
82
        return this.method;
83
    }
84
 
85
    public boolean isSetMethod() {
86
        return ((this.method!= null)&&(!this.method.isEmpty()));
87
    }
88
 
89
    public void unsetMethod() {
90
        this.method = null;
91
    }
92
 
93
    /**
94
     * Sets the value of the Method property.
95
     * 
96
     * @param values
97
     * @return
98
     *     this instance
99
     */
100
    public PaymentMethodList withMethod(PaymentMethodEnum... values) {
101
        for (PaymentMethodEnum value: values) {
102
            getMethod().add(value);
103
        }
104
        return this;
105
    }
106
 
107
    /**
108
     * Sets the value of the method property.
109
     * 
110
     * @param method
111
     *     allowed object is
112
     *     {@link PaymentMethodEnum }
113
     *     
114
     */
115
    public void setMethod(List<PaymentMethodEnum> method) {
116
        this.method = method;
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<PaymentMethodEnum> methodList  =  getMethod();
132
        for (PaymentMethodEnum method : methodList) { 
133
            xml.append("<Method>");
134
            xml.append(method.value());
135
            xml.append("</Method>");
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 (isSetMethod()) {
189
            if (!first) json.append(", ");
190
            json.append("\"Method\" : [");
191
            java.util.List<PaymentMethodEnum> methodList  =  getMethod();
192
            int methodListIndex  =  0;
193
            for (PaymentMethodEnum method : methodList) {
194
                if (methodListIndex > 0) json.append(", ");
195
                    json.append(method.value());
196
                ++methodListIndex;
197
            }
198
            json.append("]");
199
            first = false;
200
        }
201
        return json.toString();
202
    }
203
 
204
    /**
205
     *
206
     * Quote JSON string
207
     */
208
    private String quoteJSON(String string) {
209
        if (string == null)
210
            return "null";
211
        StringBuffer sb = new StringBuffer();
212
        sb.append("\"");
213
        int length = string.length();
214
        for (int i = 0; i < length; ++i) {
215
            char c = string.charAt(i);
216
            switch (c) {
217
            case '"':
218
                sb.append("\\\"");
219
                break;
220
            case '\\':
221
                sb.append("\\\\");
222
                break;
223
            case '/':
224
                sb.append("\\/");
225
                break;
226
            case '\b':
227
                sb.append("\\b");
228
                break;
229
            case '\f':
230
                sb.append("\\f");
231
                break;
232
            case '\n':
233
                sb.append("\\n");
234
                break;
235
            case '\r':
236
                sb.append("\\r");
237
                break;
238
            case '\t':
239
                sb.append("\\t");
240
                break;
241
            default:
242
                if (c <  ' ') {
243
                    sb.append("\\u" + String.format("%03x", Integer.valueOf(c)));
244
                } else {
245
                sb.append(c);
246
            }
247
        }
248
        }
249
        sb.append("\"");
250
        return sb.toString();
251
    }
252
 
253
 
254
}