Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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