Package org.apache.wiki.url

# Class ShortURLConstructor

java.lang.Object
org.apache.wiki.url.DefaultURLConstructor
org.apache.wiki.url.ShortURLConstructor

All Implemented Interfaces:
  `org.apache.wiki.api.engine.Initializable`, `URLConstructor`

Direct Known Subclasses:
  `ShortViewURLConstructor`

public class ShortURLConstructor extends DefaultURLConstructor
Provides a way to do short URLs of the form /wiki/PageName.

Since:
  2.2

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`m_urlPrefix`
Contains the path part after the JSPWiki base URL
`static final String`
`PROP_PREFIX`
This corresponds to your WikiServlet path.

### Fields inherited from class org.apache.wiki.url.DefaultURLConstructor

`m_engine, m_pathPrefix`

## Constructor Summary

Constructors
Constructor
Description
`ShortURLConstructor()`

## Method Summary

Modifier and Type
Method
Description
`String`
`getForwardPage(jakarta.servlet.http.HttpServletRequest req)`
This method is not needed for the DefaultURLConstructor.
`void`
`initialize(org.apache.wiki.api.core.Engine engine, Properties properties)`
`String`
`makeURL(String context, String name, String parameters)`
Constructs the URL with a bunch of parameters.
`String`
`parsePage(String context, jakarta.servlet.http.HttpServletRequest request, Charset encoding)`
Should parse the "page" parameter from the actual request.

### Methods inherited from class org.apache.wiki.url.DefaultURLConstructor

`doReplacement, getURLPattern`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### m_urlPrefix

protected String m_urlPrefix
Contains the path part after the JSPWiki base URL

### PROP_PREFIX

public static final String PROP_PREFIX
This corresponds to your WikiServlet path. By default, it is assumed to be "wiki/", but you can set it to whatever you like - including an empty name.

See Also:
  - Constant Field Values

## Constructor Details

### ShortURLConstructor

public ShortURLConstructor()

## Method Details

### initialize

public void initialize(org.apache.wiki.api.core.Engine engine, Properties properties)

Specified by:
  `initialize` in interface `org.apache.wiki.api.engine.Initializable`
Overrides:
  `initialize` in class `DefaultURLConstructor`

### makeURL

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

Specified by:
  `makeURL` in interface `URLConstructor`
Overrides:
  `makeURL` in class `DefaultURLConstructor`
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` - If null or empty, no parameters are added. 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

public String parsePage(String context, jakarta.servlet.http.HttpServletRequest request, Charset encoding)
Should parse the "page" parameter from the actual request. 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.

Specified by:
  `parsePage` in interface `URLConstructor`
Overrides:
  `parsePage` in class `DefaultURLConstructor`
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.

### getForwardPage

public String getForwardPage(jakarta.servlet.http.HttpServletRequest req)
This method is not needed for the DefaultURLConstructor.

Specified by:
  `getForwardPage` in interface `URLConstructor`
Overrides:
  `getForwardPage` in class `DefaultURLConstructor`
Parameters:
  `req` - 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.