1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.propertyexpansion;
14
15 import com.eviware.soapui.model.ModelItem;
16 import com.eviware.soapui.support.StringUtils;
17 import com.eviware.soapui.support.types.StringToObjectMap;
18
19 public class DefaultPropertyExpansionContext extends StringToObjectMap implements PropertyExpansionContext
20 {
21 private ModelItem modelItem;
22
23 public DefaultPropertyExpansionContext( ModelItem modelItem )
24 {
25 this.modelItem = modelItem;
26 }
27
28 public String expand( String content )
29 {
30 return PropertyExpansionUtils.expandProperties( this, content );
31 }
32
33 public ModelItem getModelItem()
34 {
35 return modelItem;
36 }
37
38 public Object getProperty( String name )
39 {
40 return super.get( name );
41 }
42
43 public String[] getPropertyNames()
44 {
45 return keySet().toArray( new String[size()] );
46 }
47
48 @Override
49 public Object get( Object key )
50 {
51 Object result = super.get( key );
52
53 if( result == null )
54 {
55 result = expand( ( String ) key );
56 if( key.equals( result ))
57 {
58 result = expand( "${" + key + "}" );
59 if( StringUtils.isNullOrEmpty( (String)result ))
60 result = null;
61 }
62 }
63
64 return result;
65 }
66
67 public boolean hasProperty( String name )
68 {
69 return containsKey( name );
70 }
71
72 public Object removeProperty( String name )
73 {
74 return remove( name );
75 }
76
77 public void setProperty( String name, Object value )
78 {
79 put( name, value );
80 }
81 }