View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.support;
14  
15  import javax.wsdl.BindingOperation;
16  import javax.wsdl.Part;
17  
18  import org.apache.xmlbeans.SchemaType;
19  import org.apache.xmlbeans.XmlCursor;
20  import org.apache.xmlbeans.XmlObject;
21  
22  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlUtils;
23  
24  public class MessageXmlPart
25  {
26  	private XmlObject partXmlObject;
27  	private final XmlObject sourceXmlObject;
28  	private final Part part;
29  	private final BindingOperation bindingOperation;
30  	private final boolean isRequest;
31  
32  	public MessageXmlPart(XmlObject sourceXmlObject, SchemaType type, Part part, BindingOperation bindingOperation, boolean isRequest)
33  	{
34  		this.sourceXmlObject = sourceXmlObject;
35  		this.part = part;
36  		this.bindingOperation = bindingOperation;
37  		this.isRequest = isRequest;
38  		partXmlObject = type == null ? sourceXmlObject.copy() : sourceXmlObject.copy().changeType( type );
39  	}
40  
41  	public void update()
42  	{
43  		sourceXmlObject.set( partXmlObject );
44  	}
45  
46  	public XmlCursor newCursor()
47  	{
48  		return partXmlObject.newCursor();
49  	}
50  
51  	public boolean isAttachmentPart()
52  	{
53  		return isRequest ? WsdlUtils.isAttachmentInputPart( part, bindingOperation ) : 
54  			WsdlUtils.isAttachmentOutputPart( part, bindingOperation );
55  	}
56  
57  	public Part getPart()
58  	{
59  		return part;
60  	}
61  }