1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.axis.message.addressing;
19
20 import org.apache.axis.encoding.AnyContentType;
21 import org.apache.axis.message.MessageElement;
22 import org.apache.axis.utils.XMLUtils;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.w3c.dom.Document;
26 import org.w3c.dom.Element;
27
28 import javax.xml.namespace.QName;
29 import java.io.Serializable;
30
31 /***
32 * Java content class for ReferenceParametersType complex type.
33 * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at http://schemas.xmlsoap.org/ws/2004/08/addressing line 62)
34 * <p>
35 * <pre>
36 * <complexType name="ReferenceParametersType">
37 * <complexContent>
38 * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
39 * <sequence>
40 * <any/>
41 * </sequence>
42 * </restriction>
43 * </complexContent>
44 * </complexType>
45 * </pre>
46 *
47 * @author Davanum Srinivas (dims@yahoo.com)
48 */
49 public class ReferenceParametersType implements Serializable, AnyContentType {
50
51 private static Log log =
52 LogFactory.getLog(ReferenceParametersType.class.getName());
53
54 private MessageElement [] _any;
55
56 /***
57 * Constructor ReferenceParameters
58 */
59 public ReferenceParametersType() {
60 }
61
62 /***
63 * Constructor ReferenceParameters
64 */
65 public ReferenceParametersType(java.lang.Object element) {
66 add(element);
67 }
68
69 /***
70 * Constructor ReferenceParameters (performs shallow copy)
71 *
72 * @param properties
73 */
74 public ReferenceParametersType(ReferenceParametersType properties) {
75 this(properties, false);
76 }
77
78 /***
79 * Constructor ReferenceParameters
80 *
81 * @param properties
82 * @param deepCopy
83 */
84 public ReferenceParametersType(ReferenceParametersType properties,
85 boolean deepCopy) {
86 if (properties == null) {
87 throw new IllegalArgumentException();
88 }
89 MessageElement elem = null;
90 for (int i = 0; i < properties.size(); i++) {
91 elem = properties._any[i];
92 if (deepCopy) {
93
94 try {
95 add(new MessageElement(elem.getAsDOM()));
96 } catch (Exception e) {
97
98 add(elem);
99 }
100 } else {
101
102 add(elem);
103 }
104 }
105 }
106
107 public int size() {
108 return (this._any == null) ? 0 : this._any.length;
109 }
110
111 public Object get(int index) {
112 return this._any[index];
113 }
114
115 /***
116 * Get a (single) MessageElement matching the passed QName
117 * @param qname
118 * @return
119 */
120 public MessageElement get(QName qname) {
121 for (int i = 0; i < _any.length; i++) {
122 MessageElement messageElement = _any[i];
123 if (messageElement.getQName().equals(qname))
124 return messageElement;
125 }
126 return null;
127 }
128
129 public void add(Object element) {
130 MessageElement value = null;
131 if (element instanceof MessageElement) {
132 value = (MessageElement)element;
133 } else if (element instanceof Element) {
134 value = new MessageElement((Element)element);
135 } else {
136 throw new IllegalArgumentException();
137 }
138
139 if (this._any == null) {
140 this._any = new MessageElement[] {value};
141 } else {
142 MessageElement [] any = null;
143 any = new MessageElement[this._any.length + 1];
144 System.arraycopy(this._any, 0,
145 any, 0,
146 this._any.length);
147 any[this._any.length] = value;
148 this._any = any;
149 }
150 }
151
152 /***
153 * append DOM node to parent
154 *
155 * @param parent
156 */
157 public void append(Element parent, String elementName) {
158 Document doc = parent.getOwnerDocument();
159 Element refProp = doc.createElementNS(Constants.NS_URI_ADDRESSING_DEFAULT,
160 elementName);
161 MessageElement [] any = get_any();
162 if (any != null) {
163 try {
164 for (int i=0;i<any.length;i++) {
165 refProp.appendChild(doc.importNode(any[i].getAsDOM(),
166 true));
167 }
168 } catch (Exception e) {
169 log.debug("", e);
170 }
171 }
172 parent.appendChild(refProp);
173 }
174
175 /***
176 * Gets the _any value for this ReferenceParametersType.
177 *
178 * @return _any
179 */
180 public MessageElement [] get_any() {
181 return _any;
182 }
183
184 /***
185 * Sets the _any value for this ReferenceParametersType.
186 *
187 * @param _any
188 */
189 public void set_any(MessageElement [] _any) {
190 this._any = _any;
191 }
192
193 public String toString() {
194 if (this._any == null) {
195 return "";
196 }
197 StringBuffer buf = new StringBuffer();
198 for (int i=0;i<this._any.length;i++) {
199 buf.append("Reference property[" + i + "]:\n");
200 try {
201 buf.append(XMLUtils.ElementToString(this._any[i].getAsDOM()));
202 } catch (Exception e) {
203 buf.append("<error converting: " + e.getMessage() + ">");
204 }
205 buf.append("\n");
206 }
207 return buf.toString();
208 }
209
210
211 private static org.apache.axis.description.TypeDesc typeDesc =
212 new org.apache.axis.description.TypeDesc(ReferenceParametersType.class, true);
213
214 static {
215 typeDesc.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ReferenceParametersType"));
216 }
217
218 /***
219 * Return type metadata object
220 */
221 public static org.apache.axis.description.TypeDesc getTypeDesc() {
222 return typeDesc;
223 }
224
225
226 /***
227 * Get Custom Serializer
228 */
229 public static org.apache.axis.encoding.Serializer getSerializer(
230 java.lang.String mechType,
231 java.lang.Class _javaType,
232 javax.xml.namespace.QName _xmlType) {
233 return
234 new org.apache.axis.encoding.ser.BeanSerializer(
235 _javaType, _xmlType, typeDesc);
236 }
237
238 /***
239 * Get Custom Deserializer
240 */
241 public static org.apache.axis.encoding.Deserializer getDeserializer(
242 java.lang.String mechType,
243 java.lang.Class _javaType,
244 javax.xml.namespace.QName _xmlType) {
245 return
246 new org.apache.axis.encoding.ser.BeanDeserializer(
247 _javaType, _xmlType, typeDesc);
248 }
249
250 }
251
252