1 18 19 package org.apache.tools.ant.util.facade; 20 21 import java.util.Enumeration ; 22 import java.util.Vector ; 23 24 32 public class FacadeTaskHelper { 33 34 37 private Vector args = new Vector (); 38 39 42 private String userChoice; 43 44 47 private String magicValue; 48 49 52 private String defaultValue; 53 54 58 public FacadeTaskHelper(String defaultValue) { 59 this(defaultValue, null); 60 } 61 62 68 public FacadeTaskHelper(String defaultValue, String magicValue) { 69 this.defaultValue = defaultValue; 70 this.magicValue = magicValue; 71 } 72 73 77 public void setMagicValue(String magicValue) { 78 this.magicValue = magicValue; 79 } 80 81 85 public void setImplementation(String userChoice) { 86 this.userChoice = userChoice; 87 } 88 89 93 public String getImplementation() { 94 return userChoice != null ? userChoice 95 : (magicValue != null ? magicValue 96 : defaultValue); 97 } 98 99 103 public String getExplicitChoice() { 104 return userChoice; 105 } 106 107 111 public void addImplementationArgument(ImplementationSpecificArgument arg) { 112 args.addElement(arg); 113 } 114 115 120 public String [] getArgs() { 121 Vector tmp = new Vector (args.size()); 122 for (Enumeration e = args.elements(); e.hasMoreElements();) { 123 ImplementationSpecificArgument arg = 124 ((ImplementationSpecificArgument) e.nextElement()); 125 String [] curr = arg.getParts(getImplementation()); 126 for (int i = 0; i < curr.length; i++) { 127 tmp.addElement(curr[i]); 128 } 129 } 130 String [] res = new String [tmp.size()]; 131 tmp.copyInto(res); 132 return res; 133 } 134 135 141 public boolean hasBeenSet() { 142 return userChoice != null || magicValue != null; 143 } 144 } 145 | Popular Tags |