| 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 CompetitivePriceList complex type.
|
|
|
14 |
*
|
|
|
15 |
* <p>The following schema fragment specifies the expected content contained within this class.
|
|
|
16 |
*
|
|
|
17 |
* <pre>
|
|
|
18 |
* <complexType name="CompetitivePriceList">
|
|
|
19 |
* <complexContent>
|
|
|
20 |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
|
|
21 |
* <sequence>
|
|
|
22 |
* <element name="CompetitivePrice" type="{http://mws.amazonservices.com/schema/Products/2011-10-01}CompetitivePriceType" maxOccurs="unbounded"/>
|
|
|
23 |
* </sequence>
|
|
|
24 |
* </restriction>
|
|
|
25 |
* </complexContent>
|
|
|
26 |
* </complexType>
|
|
|
27 |
* </pre>
|
|
|
28 |
*
|
|
|
29 |
*
|
|
|
30 |
*/
|
|
|
31 |
@XmlAccessorType(XmlAccessType.FIELD)
|
|
|
32 |
@XmlType(name = "CompetitivePriceList", propOrder = {
|
|
|
33 |
"competitivePrice"
|
|
|
34 |
})
|
|
|
35 |
public class CompetitivePriceList {
|
|
|
36 |
|
|
|
37 |
@XmlElement(name = "CompetitivePrice", required = true)
|
|
|
38 |
protected List<CompetitivePriceType> competitivePrice;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Default constructor
|
|
|
42 |
*
|
|
|
43 |
*/
|
|
|
44 |
public CompetitivePriceList() {
|
|
|
45 |
super();
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Value constructor
|
|
|
50 |
*
|
|
|
51 |
*/
|
|
|
52 |
public CompetitivePriceList(final List<CompetitivePriceType> competitivePrice) {
|
|
|
53 |
this.competitivePrice = competitivePrice;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Gets the value of the competitivePrice 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 competitivePrice property.
|
|
|
64 |
*
|
|
|
65 |
* <p>
|
|
|
66 |
* For example, to add a new item, do as follows:
|
|
|
67 |
* <pre>
|
|
|
68 |
* getCompetitivePrice().add(newItem);
|
|
|
69 |
* </pre>
|
|
|
70 |
*
|
|
|
71 |
*
|
|
|
72 |
* <p>
|
|
|
73 |
* Objects of the following type(s) are allowed in the list
|
|
|
74 |
* {@link CompetitivePriceType }
|
|
|
75 |
*
|
|
|
76 |
*
|
|
|
77 |
*/
|
|
|
78 |
public List<CompetitivePriceType> getCompetitivePrice() {
|
|
|
79 |
if (competitivePrice == null) {
|
|
|
80 |
competitivePrice = new ArrayList<CompetitivePriceType>();
|
|
|
81 |
}
|
|
|
82 |
return this.competitivePrice;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
public boolean isSetCompetitivePrice() {
|
|
|
86 |
return ((this.competitivePrice!= null)&&(!this.competitivePrice.isEmpty()));
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
public void unsetCompetitivePrice() {
|
|
|
90 |
this.competitivePrice = null;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* Sets the value of the CompetitivePrice property.
|
|
|
95 |
*
|
|
|
96 |
* @param values
|
|
|
97 |
* @return
|
|
|
98 |
* this instance
|
|
|
99 |
*/
|
|
|
100 |
public CompetitivePriceList withCompetitivePrice(CompetitivePriceType... values) {
|
|
|
101 |
for (CompetitivePriceType value: values) {
|
|
|
102 |
getCompetitivePrice().add(value);
|
|
|
103 |
}
|
|
|
104 |
return this;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* Sets the value of the competitivePrice property.
|
|
|
109 |
*
|
|
|
110 |
* @param competitivePrice
|
|
|
111 |
* allowed object is
|
|
|
112 |
* {@link CompetitivePriceType }
|
|
|
113 |
*
|
|
|
114 |
*/
|
|
|
115 |
public void setCompetitivePrice(List<CompetitivePriceType> competitivePrice) {
|
|
|
116 |
this.competitivePrice = competitivePrice;
|
|
|
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<CompetitivePriceType> competitivePriceList = getCompetitivePrice();
|
|
|
132 |
for (CompetitivePriceType competitivePrice : competitivePriceList) {
|
|
|
133 |
xml.append("<CompetitivePrice " + (competitivePrice.isSetCondition() ? " condition=" + "\"" + escapeXML(competitivePrice.getCondition()) + "\"" : "") + " " + (competitivePrice.isSetSubcondition() ? " subcondition=" + "\"" + escapeXML(competitivePrice.getSubcondition()) + "\"" : "") + " " + (competitivePrice.isSetBelongsToRequester() ? " belongsToRequester=" + "\"" + competitivePrice.isBelongsToRequester() + "\"" : "") + ">");
|
|
|
134 |
xml.append(competitivePrice.toXMLFragment());
|
|
|
135 |
xml.append("</CompetitivePrice>");
|
|
|
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("&");
|
|
|
154 |
break;
|
|
|
155 |
case '<':
|
|
|
156 |
sb.append("<");
|
|
|
157 |
break;
|
|
|
158 |
case '>':
|
|
|
159 |
sb.append(">");
|
|
|
160 |
break;
|
|
|
161 |
case '\'':
|
|
|
162 |
sb.append("'");
|
|
|
163 |
break;
|
|
|
164 |
case '"':
|
|
|
165 |
sb.append(""");
|
|
|
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 (isSetCompetitivePrice()) {
|
|
|
189 |
if (!first) json.append(", ");
|
|
|
190 |
json.append("\"CompetitivePrice\" : [");
|
|
|
191 |
java.util.List<CompetitivePriceType> competitivePriceList = getCompetitivePrice();
|
|
|
192 |
int competitivePriceListIndex = 0;
|
|
|
193 |
for (CompetitivePriceType competitivePrice : competitivePriceList) {
|
|
|
194 |
if (competitivePriceListIndex > 0) json.append(", ");
|
|
|
195 |
json.append("{");
|
|
|
196 |
json.append("");
|
|
|
197 |
json.append(competitivePrice.toJSONFragment());
|
|
|
198 |
json.append("}");
|
|
|
199 |
first = false;
|
|
|
200 |
++competitivePriceListIndex;
|
|
|
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 |
}
|