View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.support.definition.support;
14  
15  import org.w3c.dom.Node;
16  
17  import com.eviware.soapui.config.DefinitionCacheTypeConfig;
18  import com.eviware.soapui.config.DefintionPartConfig;
19  import com.eviware.soapui.impl.support.definition.InterfaceDefinitionPart;
20  import com.eviware.soapui.support.xml.XmlUtils;
21  
22  public class ConfigInterfaceDefinitionPart implements InterfaceDefinitionPart
23  {
24  	private DefintionPartConfig config;
25  	private boolean isRoot;
26  	private DefinitionCacheTypeConfig.Enum type;
27  
28  	public ConfigInterfaceDefinitionPart( DefintionPartConfig config, boolean isRoot, DefinitionCacheTypeConfig.Enum type )
29  	{
30  		this.config = config;
31  		this.isRoot = isRoot;
32  		this.type = type;
33  	}
34  
35  	public String getUrl()
36  	{
37  		return config.getUrl();
38  	}
39  
40  	public String getType()
41  	{
42  		return config.getType();
43  	}
44  
45  	public String getContent()
46  	{
47  		if( type == DefinitionCacheTypeConfig.TEXT )
48  		{
49  			Node domNode = config.getContent().getDomNode();
50  			return XmlUtils.getNodeValue( domNode );
51  		}
52  		else
53  		{
54  			return config.getContent().toString();
55  		}
56  	}
57  
58  	public boolean isRootPart()
59  	{
60  		return isRoot;
61  	}
62  }