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.mock;
14  
15  import java.util.Collection;
16  import java.util.Map;
17  import java.util.Set;
18  
19  import com.eviware.soapui.model.mock.MockRunContext;
20  import com.eviware.soapui.model.mock.MockService;
21  import com.eviware.soapui.support.types.StringToObjectMap;
22  import com.eviware.soapui.support.types.StringToStringMap;
23  
24  public class WsdlMockRunContext implements MockRunContext, Map<String,Object>
25  {
26  	private StringToObjectMap properties = new StringToObjectMap();
27  	private final WsdlMockService mockService; 
28  	
29  	public WsdlMockRunContext( WsdlMockService mockService )
30  	{
31  		this.mockService = mockService;
32  	}
33  
34  	public MockService getMockService()
35  	{
36  		return mockService;
37  	}
38  
39  	public Object getProperty( String name )
40  	{
41  		return properties.get( name );
42  	}
43  
44  	public boolean hasProperty( String name )
45  	{
46  		return properties.containsKey( name );
47  	}
48  
49  	public Object removeProperty( String name )
50  	{
51  		return properties.remove( name );
52  	}
53  
54  	public void setProperty( String name, Object value )
55  	{
56  		properties.put( name, value );
57  	}
58  
59  	public StringToStringMap toStringToStringMap()
60  	{
61  		StringToStringMap result = new StringToStringMap();
62  		
63  		for( String key : properties.keySet() )
64  		{
65  			Object value = properties.get( key );
66  			if( value != null )
67  				result.put( key, value.toString() );
68  		}
69  		
70  		return result;
71  	}
72  
73  	public void clear()
74  	{
75  		properties.clear();
76  	}
77  
78  	public Object clone()
79  	{
80  		return properties.clone();
81  	}
82  
83  	public boolean containsKey( Object arg0 )
84  	{
85  		return properties.containsKey( arg0 );
86  	}
87  
88  	public boolean containsValue( Object arg0 )
89  	{
90  		return properties.containsValue( arg0 );
91  	}
92  
93  	public Set<Entry<String, Object>> entrySet()
94  	{
95  		return properties.entrySet();
96  	}
97  
98  	public boolean equals( Object arg0 )
99  	{
100 		return properties.equals( arg0 );
101 	}
102 
103 	public Object get( Object arg0 )
104 	{
105 		return properties.get( arg0 );
106 	}
107 
108 	public int hashCode()
109 	{
110 		return properties.hashCode();
111 	}
112 
113 	public boolean isEmpty()
114 	{
115 		return properties.isEmpty();
116 	}
117 
118 	public Set<String> keySet()
119 	{
120 		return properties.keySet();
121 	}
122 
123 	public Object put( String arg0, Object arg1 )
124 	{
125 		return properties.put( arg0, arg1 );
126 	}
127 
128 	public void putAll( Map<? extends String, ? extends Object> arg0 )
129 	{
130 		properties.putAll( arg0 );
131 	}
132 
133 	public Object remove( Object arg0 )
134 	{
135 		return properties.remove( arg0 );
136 	}
137 
138 	public int size()
139 	{
140 		return properties.size();
141 	}
142 
143 	public String toString()
144 	{
145 		return properties.toString();
146 	}
147 
148 	public Collection<Object> values()
149 	{
150 		return properties.values();
151 	}
152 	
153 	
154 }