Package org.apache.wiki.url

# Interface URLConstructor

All Superinterfaces:
  `Initializable`

All Known Implementing Classes:
  `DefaultURLConstructor`, `ShortURLConstructor`, `ShortViewURLConstructor`

public interface URLConstructor extends Initializable
Provides an interface through which JSPWiki constructs URLs. JSPWiki calls the methods of this interface whenever an URL that points to any JSPWiki internals is required. For example, if you need to find an URL to the editor page for page "TextFormattingRules", you would call makeURL( WikiContext.EDIT, "TextFormattingRules", false, null );

Since:
  2.2

## Method Summary

Modifier and Type
Method
Description
`String`
`getForwardPage(javax.servlet.http.HttpServletRequest request)`
Returns information which JSP page should continue handling this type of request.
`String`
`makeURL(String context, String name, String parameters)`
Constructs the URL with a bunch of parameters.
`String`
`parsePage(String context, javax.servlet.http.HttpServletRequest request, Charset encoding)`
Should parse the "page" parameter from the actual request.
`static String`
`parsePageFromURL(javax.servlet.http.HttpServletRequest request, Charset encoding)`
Takes the name of the page from the request URI.

### Methods inherited from interface org.apache.wiki.api.engine.Initializable

`initialize`

## Method Details

### makeURL

String makeURL(String context, String name, String parameters)
Constructs the URL with a bunch of parameters.

Parameters:
  `context` - The request context (@see WikiContext) that you want the URL for
  `name` - The page name (or in case of WikiContext.NONE, the auxiliary JSP page or resource you want to point at). This must be URL encoded. Null is NOT safe.
  `parameters` - An URL parameter string (these must be URL-encoded, and separated with &amp;)
Returns:
  An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong.

### parsePage

String parsePage(String context, javax.servlet.http.HttpServletRequest request, Charset encoding) throws IOException
Should parse the "page" parameter from the actual request. This is essentially the reverse of makeURL() - whenever a request constructed by calls to makeURL() is passed to this routine, it MUST be able to parse the resource name (WikiPage, Attachment, other resource) from the request.

Parameters:
  `context` - In which request context the request was made (this should help in parsing)
  `request` - The HTTP request that was used when coming here
  `encoding` - The encoding with which the request was made (UTF-8 or ISO-8859-1).
Returns:
  This method must return the name of the resource.
Throws:
  `IOException` - If parsing failes

### getForwardPage

String getForwardPage(javax.servlet.http.HttpServletRequest request)
Returns information which JSP page should continue handling this type of request.

Parameters:
  `request` - The HTTP Request that was used to end up in this page.
Returns:
  "Wiki.jsp", "PageInfo.jsp", etc. Just return the name, JSPWiki will figure out the page.

### parsePageFromURL

static String parsePageFromURL(javax.servlet.http.HttpServletRequest request, Charset encoding)
Takes the name of the page from the request URI. The initial slash is also removed. If there is no page, returns null.

Parameters:
  `request` - The request to parse
  `encoding` - The encoding to use
Returns:
  a parsed page name, or null, if it cannot be found