private function buildUrlPatternFromPattern($pattern, array $parameters)
    {
        foreach ($parameters as $p) {
            $pattern = str_replace('{' . $p->name . '}', $p->matchPattern, $pattern, $rcount);
            if ($rcount < 1) {
                throw new RestException(sprintf('Missing parameter "%s" for "%s" method in the rest.url definition.',
                    $p->name, $this->method->getName()));
            }
        }

        return rtrim($pattern, '/') . '/';
    }