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