FileDocCategorySizeDatePackage
MapperResult.javaAPI DocApache Ant 1.703249Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.mappers

MapperResult

public class MapperResult extends org.apache.tools.ant.Task
This is a test task to show the result of a mapper on a specific input. (Test is not in the name of the class, to make sure that it is not treated as a unit test.

Fields Summary
private String
failMessage
private String
input
private String
output
private org.apache.tools.ant.util.FileNameMapper
fileNameMapper
private static final String
NULL_MAPPER_RESULT
The output on an empty string array
Constructors Summary
Methods Summary
public voidadd(org.apache.tools.ant.util.FileNameMapper fileNameMapper)

        if (this.fileNameMapper != null) {
            throw new BuildException("Only one mapper type nested element allowed");
        }
        this.fileNameMapper = fileNameMapper;
    
public voidaddConfiguredMapper(org.apache.tools.ant.types.Mapper mapper)

        add(mapper.getImplementation());
    
public voidexecute()

        if (input == null) {
            throw new BuildException("Missing attribute 'input'");
        }
        if (output == null) {
            throw new BuildException("Missing attribute 'output'");
        }
        if (fileNameMapper == null) {
            throw new BuildException("Missing a nested file name mapper type element");
        }
        String[] result = fileNameMapper.mapFileName(input);
        String flattened;
        if (result == null) {
            flattened = NULL_MAPPER_RESULT;
        } else {
            StringBuffer b = new StringBuffer();
            for (int i = 0; i < result.length; ++i) {
                if (i != 0) {
                    b.append("|");
                }
                b.append(result[i]);
            }
            flattened = b.toString();
        }
        if (!flattened.equals(output)) {
            throw new BuildException(
                failMessage
                + " "
                + "got "
                + flattened
                + " "
                + "expected "
                + output);
        }
    
public voidsetFailMessage(java.lang.String failMessage)


        
        this.failMessage = failMessage;
    
public voidsetInput(java.lang.String input)

        this.input = input;
    
public voidsetOutput(java.lang.String output)

        this.output = output;