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.panels.request.components.editor.support;
14  
15  import org.apache.xmlbeans.SchemaTypeSystem;
16  import org.apache.xmlbeans.XmlBeans;
17  import org.apache.xmlbeans.XmlException;
18  import org.apache.xmlbeans.XmlObject;
19  
20  
21  public class DefaultXmlDocument extends AbstractXmlDocument
22  {
23  	private String xml;
24  	private SchemaTypeSystem typeSystem;
25  
26  	public DefaultXmlDocument( String xml )
27  	{
28  		this.xml = xml;
29  	}
30  	
31  	public void setTypeSystem( SchemaTypeSystem typeSystem )
32  	{
33  		this.typeSystem = typeSystem;
34  	}
35  
36  	public SchemaTypeSystem getTypeSystem()
37  	{
38  		if( typeSystem != null )
39  			return typeSystem;
40  		
41  		try
42  		{
43  			typeSystem = XmlObject.Factory.parse( xml ).schemaType().getTypeSystem();
44  			return typeSystem;
45  		}
46  		catch (XmlException e)
47  		{
48  			return XmlBeans.getBuiltinTypeSystem();
49  		}
50  	}
51  
52  	public String getXml()
53  	{
54  		return xml;
55  	}
56  
57  	public void setXml(String xml)
58  	{
59  		String oldXml = this.xml;
60  		this.xml = xml;
61  		typeSystem = null;
62  		
63  		fireXmlChanged( oldXml, xml );
64  	}
65  }