View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 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.panels.request.components.editor.support;
    14
    15  import org.apache.xmlbeans.SchemaTypeSystem;
    16  import org.apache.xmlbeans.XmlBeans;
    17  import org.apache.xmlbeans.XmlObject;
    18
    19  /***
    20   * Default XmlDocument that works on a standard xml string
    21   *
    22   * @author ole.matzura
    23   */
    24
    25  public class DefaultXmlDocument extends AbstractXmlDocument
    26  {
    27  	private String xml;
    28  	private SchemaTypeSystem typeSystem;
    29
    30  	public DefaultXmlDocument( String xml )
    31  	{
    32  		this.xml = xml;
    33  	}
    34
    35  	public void setTypeSystem( SchemaTypeSystem typeSystem )
    36  	{
    37  		this.typeSystem = typeSystem;
    38  	}
    39
    40  	public SchemaTypeSystem getTypeSystem()
    41  	{
    42  		if( typeSystem != null )
    43  			return typeSystem;
    44
    45  		try
    46  		{
    47  			typeSystem = XmlObject.Factory.parse( xml ).schemaType().getTypeSystem();
    48  			return typeSystem;
    49  		}
    50  		catch (Exception e)
    51  		{
    52  			return XmlBeans.getBuiltinTypeSystem();
    53  		}
    54  	}
    55
    56  	public String getXml()
    57  	{
    58  		return xml;
    59  	}
    60
    61  	public void setXml(String xml)
    62  	{
    63  		String oldXml = this.xml;
    64  		this.xml = xml;
    65  		typeSystem = null;
    66
    67  		fireXmlChanged( oldXml, xml );
    68  	}
    69
    70  	public void release()
    71  	{
    72  		typeSystem = null;
    73  	}
    74  }