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.XmlObject;
    17
    18  import com.eviware.soapui.SoapUI;
    19
    20  /***
    21   * Default XmlDocument that works on an existing XmlObject
    22   *
    23   * @author ole.matzura
    24   */
    25
    26  public class XmlObjectXmlDocument extends AbstractXmlDocument
    27  {
    28  	private XmlObject xmlObject;
    29
    30  	public XmlObjectXmlDocument( XmlObject xmlObject )
    31  	{
    32  		this.xmlObject = xmlObject;}
    33
    34  	public SchemaTypeSystem getTypeSystem()
    35  	{
    36  		return xmlObject == null ? null : xmlObject.schemaType().getTypeSystem();
    37  	}
    38
    39  	public String getXml()
    40  	{
    41  		return xmlObject.toString();
    42  	}
    43
    44  	public void setXml(String xml)
    45  	{
    46  		try
    47  		{
    48  			String old = getXml();
    49  			xmlObject = XmlObject.Factory.parse( xml );
    50  			fireXmlChanged( old, getXml() );
    51  		}
    52  		catch (Exception e)
    53  		{
    54  			SoapUI.logError( e );
    55  		}
    56  	}
    57
    58  	public void release()
    59  	{
    60  		xmlObject = null;
    61  	}
    62  }