private String rewriteValue(UrlRewriter rewriter, String value, String rule) {
   try {
     Template input = Parser.parse(value);
     Template output = rewriter.rewrite(this, input, UrlRewriter.Direction.IN, rule);
     value = output.toString();
   } catch (URISyntaxException e) {
     LOG.failedToParseValueForUrlRewrite(value);
   }
   return value;
 }
 private Template getSourceUrl() {
   Template urlTemplate = null;
   StringBuffer urlString = super.getRequestURL();
   String queryString = super.getQueryString();
   if (queryString != null) {
     urlString.append('?');
     urlString.append(queryString);
   }
   try {
     urlTemplate = Parser.parse(urlString.toString());
   } catch (URISyntaxException e) {
     LOG.failedToParseValueForUrlRewrite(urlString.toString());
     // Shouldn't be possible given that the URL is constructed from parts of an existing URL.
     urlTemplate = null;
   }
   return urlTemplate;
 }