FileDocCategorySizeDatePackage
FacadeTaskHelper.javaAPI DocApache Ant 1.704263Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.util.facade

FacadeTaskHelper

public class FacadeTaskHelper extends Object
Helper class for facade implementations - encapsulates treatment of explicit implementation choices, magic properties and implementation specific command line arguments.
since
Ant 1.5

Fields Summary
private Vector
args
Command line arguments.
private String
userChoice
The explicitly chosen implementation.
private String
magicValue
The magic property to consult.
private String
defaultValue
The default value.
Constructors Summary
public FacadeTaskHelper(String defaultValue)

param
defaultValue The default value for the implementation. Must not be null.


                     
       
        this(defaultValue, null);
    
public FacadeTaskHelper(String defaultValue, String magicValue)

param
defaultValue The default value for the implementation. Must not be null.
param
magicValue the value of a magic property that may hold a user. choice. May be null.

        this.defaultValue = defaultValue;
        this.magicValue = magicValue;
    
Methods Summary
public voidaddImplementationArgument(ImplementationSpecificArgument arg)
Command line argument.

param
arg an argument to add.

        args.addElement(arg);
    
public java.lang.String[]getArgs()
Retrieves the command line arguments enabled for the current facade implementation.

return
an array of command line arguements.

        Vector tmp = new Vector(args.size());
        for (Enumeration e = args.elements(); e.hasMoreElements();) {
            ImplementationSpecificArgument arg =
                ((ImplementationSpecificArgument) e.nextElement());
            String[] curr = arg.getParts(getImplementation());
            for (int i = 0; i < curr.length; i++) {
                tmp.addElement(curr[i]);
            }
        }
        String[] res = new String[tmp.size()];
        tmp.copyInto(res);
        return res;
    
public java.lang.StringgetExplicitChoice()
Retrieves the explicit user choice.

return
the explicit user choice.

        return userChoice;
    
public java.lang.StringgetImplementation()
Retrieves the implementation.

return
the implementation.

        return userChoice != null ? userChoice
                                  : (magicValue != null ? magicValue
                                                        : defaultValue);
    
public booleanhasBeenSet()
Tests whether the implementation has been chosen by the user (either via a magic property or explicitly.

return
true if magic or user choice has be set.
since
Ant 1.5.2

        return userChoice != null || magicValue != null;
    
public voidsetImplementation(java.lang.String userChoice)
Used for explicit user choices.

param
userChoice the explicitly chosen implementation.

        this.userChoice = userChoice;
    
public voidsetMagicValue(java.lang.String magicValue)
Used to set the value of the magic property.

param
magicValue the value of a magic property that may hold a user.

        this.magicValue = magicValue;