1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.model.propertyexpansion.resolvers;
14
15 import com.eviware.soapui.model.propertyexpansion.PropertyExpander;
16 import com.eviware.soapui.model.propertyexpansion.PropertyExpansion;
17 import com.eviware.soapui.model.propertyexpansion.PropertyExpansionContext;
18 import com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils;
19
20 public class ContextPropertyResolver implements PropertyResolver
21 {
22 public String resolveProperty( PropertyExpansionContext context, String propertyName, boolean globalOverride )
23 {
24 Object property = null;
25 String xpath = null;
26
27 int sepIx = propertyName.indexOf( PropertyExpansion.PROPERTY_SEPARATOR );
28 if( sepIx == 0 )
29 {
30 propertyName = propertyName.substring( 1 );
31 sepIx = propertyName.indexOf( PropertyExpansion.PROPERTY_SEPARATOR );
32 }
33
34 if( sepIx > 0 )
35 {
36 xpath = propertyName.substring( sepIx + 1 );
37 propertyName = propertyName.substring( 0, sepIx );
38 }
39
40 if( globalOverride )
41 property = PropertyExpansionUtils.getGlobalProperty( propertyName );
42
43 if( property == null )
44 property = context.getProperty( propertyName );
45
46 if( property != null && xpath != null )
47 {
48 property = ResolverUtils.extractXPathPropertyValue( property, PropertyExpander.expandProperties( context,
49 xpath ) );
50 }
51
52 return property == null ? null : property.toString();
53 }
54
55 }