View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
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  /***
25   * Wrapper for WSDL parts
26   * 
27   * @author ole.matzura
28   */
29  
30  public class MessageXmlPart
31  {
32  	private XmlObject partXmlObject;
33  	private final XmlObject sourceXmlObject;
34  	private final Part part;
35  	private final BindingOperation bindingOperation;
36  	private final boolean isRequest;
37  	private final SchemaType type;
38  
39  	public MessageXmlPart( XmlObject sourceXmlObject, SchemaType type, Part part, BindingOperation bindingOperation,
40  			boolean isRequest )
41  	{
42  		this.sourceXmlObject = sourceXmlObject;
43  		this.type = type;
44  		this.part = part;
45  		this.bindingOperation = bindingOperation;
46  		this.isRequest = isRequest;
47  		partXmlObject = type == null ? sourceXmlObject.copy() : sourceXmlObject.copy().changeType( type );
48  	}
49  
50  	public void update()
51  	{
52  		sourceXmlObject.set( partXmlObject );
53  	}
54  
55  	public XmlCursor newCursor()
56  	{
57  		return partXmlObject.newCursor();
58  	}
59  
60  	public boolean isAttachmentPart()
61  	{
62  		return isRequest ? WsdlUtils.isAttachmentInputPart( part, bindingOperation ) : WsdlUtils.isAttachmentOutputPart(
63  				part, bindingOperation );
64  	}
65  
66  	public Part getPart()
67  	{
68  		return part;
69  	}
70  
71  	public SchemaType getSchemaType()
72  	{
73  		return type;
74  	}
75  }