1 package org
.argeo
.slc
.ant
.test
;
3 import java
.util
.Collection
;
6 import java
.util
.Vector
;
8 import org
.apache
.tools
.ant
.types
.DataType
;
10 import org
.argeo
.slc
.ant
.spring
.MapArg
;
11 import org
.argeo
.slc
.core
.SlcException
;
12 import org
.argeo
.slc
.core
.test
.context
.ContextAware
;
13 import org
.argeo
.slc
.core
.test
.context
.ContextUtils
;
14 import org
.argeo
.slc
.core
.test
.context
.ParentContextAware
;
16 public class ParentContextType
extends DataType
implements ParentContextAware
{
17 private MapArg values
= null;
18 private MapArg expectedValues
= null;
20 private String contextAnyFlag
= DEFAULT_ANY_FLAG
;
21 private String contextSkipFlag
= DEFAULT_SKIP_FLAG
;
23 private String basedon
= null;
25 private List
<ContextAware
> children
= new Vector
<ContextAware
>();
27 public MapArg
createValues() {
28 values
= new MapArg();
32 public MapArg
createExpectedValues() {
33 expectedValues
= new MapArg();
34 return expectedValues
;
37 public void addChildContext(ContextAware contextAware
) {
38 children
.add(contextAware
);
41 public Collection
<ContextAware
> getChildContexts() {
45 public String
getContextAnyFlag() {
46 return contextAnyFlag
;
49 public void setContextAnyFlag(String contextAnyFlag
) {
50 this.contextAnyFlag
= contextAnyFlag
;
53 public String
getContextSkipFlag() {
54 return contextSkipFlag
;
57 public void setContextSkipFlag(String contextSkipFlag
) {
58 this.contextSkipFlag
= contextSkipFlag
;
61 public Map
<String
, Object
> getExpectedValues() {
62 if (expectedValues
== null)
63 expectedValues
= new MapArg();
64 if (basedon
!= null) {
65 Map
<String
, Object
> map
= getBaseContext().getExpectedValues();
66 ContextUtils
.putNotContained(expectedValues
.getMap(), map
);
68 return expectedValues
.getMap();
71 public Map
<String
, Object
> getValues() {
73 values
= new MapArg();
74 if (basedon
!= null) {
75 Map
<String
, Object
> map
= getBaseContext().getValues();
76 ContextUtils
.putNotContained(values
.getMap(), map
);
78 return values
.getMap();
81 private ParentContextType
getBaseContext() {
82 return (ParentContextType
) getProject().getReference(basedon
);
85 public void setValues(Map
<String
, Object
> values
) {
86 throw new SlcException("Cannot override values map.");
89 public void setUpdateValues(Map
<String
, Object
> overrideValues
) {
90 getValues().putAll(overrideValues
);
93 public void setUpdateExpectedValues(
94 Map
<String
, Object
> overrideExpectedValues
) {
95 getExpectedValues().putAll(overrideExpectedValues
);
98 public void setBasedon(String basedon
) {
99 this.basedon
= basedon
;