public function prepare(Location $location)
    {
        if (!$this->formatter) {
            throw new BuildException("No formatter specified (use type or classname attribute)", $location);
        }

        $out = $this->getOutputWriter();

        $this->parentTask->log("Setting output writer to: " . get_class($out), Project::MSG_VERBOSE);
        $this->formatter->setOutput($out);

        if ($this->formatter instanceof PlainPDOResultFormatter) {
            // set any options that apply to the plain formatter
            $this->formatter->setShowheaders($this->showheaders);
            $this->formatter->setRowdelim($this->rowdelimiter);
            $this->formatter->setColdelim($this->coldelimiter);
        } elseif ($this->formatter instanceof XMLPDOResultFormatter) {
            // set any options that apply to the xml formatter
            $this->formatter->setEncoding($this->encoding);
            $this->formatter->setFormatOutput($this->formatoutput);
        }

        foreach ($this->formatterParams as $param) {
            $param = new Parameter();
            $method = 'set' . $param->getName();
            if (!method_exists($this->formatter, $param->getName())) {
                throw new BuildException(
                    "Formatter " . get_class(
                        $this->formatter
                    ) . " does not have a $method method.",
                    $location
                );
            }
            call_user_func([$this->formatter, $method], $param->getValue());
        }
    }