1 28 29 package com.idaremedia.antx.ownhelpers; 30 31 import java.util.Iterator ; 32 import java.util.Map ; 33 import java.util.Properties ; 34 35 import org.apache.tools.ant.Project; 36 37 import com.idaremedia.antx.helpers.GenericParameters; 38 import com.idaremedia.antx.helpers.InnerNameValuePair; 39 import com.idaremedia.antx.parameters.Conditional; 40 41 52 53 public final class ConditionalParameters extends GenericParameters 54 { 55 58 public ConditionalParameters() 59 { 60 } 61 62 63 64 69 public ConditionalParameters(Project project) 70 { 71 setProject(project); 72 } 73 74 75 76 83 public Map copyOfParameterObjects(Project P) 84 { 85 if (P==null) { 86 P = getProject(); 87 } 88 Map copy = super.copyOfParameterObjects(); 89 if (!copy.isEmpty()) { 90 Iterator itr = copy.values().iterator(); 91 while (itr.hasNext()) { 92 InnerNameValuePair pair = (InnerNameValuePair)itr.next(); 93 if (pair instanceof Conditional) { 94 if (!OptionalExecuteHelper.include(P,(Conditional)pair)) { 95 itr.remove(); 96 } 97 } 98 } 99 } 100 return copy; 101 } 102 103 104 105 110 public Map copyOfParameterObjects() 111 { 112 return copyOfParameterObjects(null); 113 } 114 115 116 117 126 public Properties copyOfSimpleKeyValues(final Project P, boolean altForm) 127 { 128 Properties copy = new Properties (); 129 if (!isEmpty()) { 130 Iterator itr= values().iterator(); 131 while (itr.hasNext()) { 132 InnerNameValuePair pair = (InnerNameValuePair)itr.next(); 133 if (pair instanceof Conditional) { 134 if (OptionalExecuteHelper.include(P,(Conditional)pair)) { 135 copy.put(pair.getName(),pair.getValue(P,altForm)); 136 } 137 } else { 138 copy.put(pair.getName(),pair.getValue(P,altForm)); 139 } 140 } 141 } 142 return copy; 143 } 144 145 146 147 151 protected InnerNameValuePair newNVPair() 152 { 153 return new ConditionalInnerNameValuePair(); 154 } 155 } 156 157 | Popular Tags |