View Javadoc

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