# com.bea.wlw.netui.pageflow.util
TemplateHelper Class

public class TemplateHelper
extends `Object`
implements `Cloneable`

Class for creating URLs from parameterized templates. This mechanism recognizes the following parameters in URL templates:

url:scheme | Scheme | Usage
url:domain | Domain | May be set
url:port | Port | May be set
url:path | Extra path information | Reserved, must be present in a template.
url:queryString | Reserved query parameters | Reserved, must be present in a template.

If one or more parameters of a template are not set at runtime, the implementation will use defaults if appropriate.

Hierarchy
  `Object`
  `TemplateHelper`

All Implemented Interfaces
  `Cloneable`

## Field Summary

`public static final `String`` | `CONTROL_STATE_PARAM` Control state parameter (reserved).
`protected `HttpServletRequest`` | `httpRequest` HTTP request.
`protected `HttpServletResponse`` | `httpResponse` HTTP response<.
`public static final `String`` | `MODE_PARAM` Window mode query parameter (reserved).
`public static final `String`` | `PAGE_LABEL_PARAM` Page label query parameter (reserved).
`protected `LinkedHashMap`` | `params` Query parameters
`public static final `String`` | `POSTBACK_PARAM` Postback request query parameter (reserved).
`public static final `String`` | `STATE_PARAM` Window state query parameter (reserved).
`public static final `String`` | `WINDOW_LABEL_PARAM` Window label query parameter (reserved).

## Constructor Summary

TemplateHelper(`HttpServletRequest` httpRequest, `HttpServletResponse` httpResponse) Constructs a `GenericURL`.

## Method Summary

`public void` | `addParameter`(`String` name, `String` value) Add a parameter.
`public `Object`` | `clone`() Returns a deep copy.
`public `String`` | `getDomain`() Returns the domain.
`public boolean` | `getEncodeSession`() Returns `true` if URL rewriting is enabled.
`public `String`` | `getParameter`(`String` name) Returns the value of the parameter.
`public `List`` | `getParameters`(`String` name) Returns the values of the given parameter.
`public `String`` | `getPathPrefix`() Returns the path prefix.
`public int` | `getPort`() Returns the port.
`public `String`` | `getQueryString`()
`public `String`` | `getScheme`() Returns the protocol scheme.
`public `String`` | `getTemplate`() Returns the current template.
`public `String`` | `getTemplateName`(`String` templateRef)
`public boolean` | `hasTemplateRef`(`String` templateRef)
`public void` | `removeParameter`(`String` name) Removes the given parameter.
`public void` | `setDomain`(`String` domain) Sets the domain.
`public void` | `setEncodeSession`(boolean encodeSession) Enables URL rewriting for encoding a session ID in the URL.
`public void` | `setPath`(`String` path) Sets path.
`public void` | `setPathPrefix`(`String` pathPrefix) Sets a path prefix.
`public void` | `setPort`(int port) Sets a port.
`public void` | `setQueryString`(`String` queryString)
`public void` | `setScheme`(`String` scheme) Sets the protocol scheme.
`public void` | `setTemplate`(`String` templateName) Sets a URL template for this URL.
`public void` | `setUrl`(`String` url)
`public `String`` | `toString`() Returns a string form (fully-quanlfied) of this URL.

Methods from class `java.lang.`Object``
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Detail

### CONTROL_STATE_PARAM

    public static final String CONTROL_STATE_PARAM

  Control state parameter (reserved).

### httpRequest

    protected HttpServletRequest httpRequest

  HTTP request.

### httpResponse

    protected HttpServletResponse httpResponse

  HTTP response<./p>

### MODE_PARAM

    public static final String MODE_PARAM

  Window mode query parameter (reserved).

### PAGE_LABEL_PARAM

    public static final String PAGE_LABEL_PARAM

  Page label query parameter (reserved).

### params

    protected LinkedHashMap params

  Query parameters

### POSTBACK_PARAM

    public static final String POSTBACK_PARAM

  Postback request query parameter (reserved).

### STATE_PARAM

    public static final String STATE_PARAM

  Window state query parameter (reserved).

### WINDOW_LABEL_PARAM

    public static final String WINDOW_LABEL_PARAM

  Window label query parameter (reserved).

## Constructor Detail

### TemplateHelper

    public TemplateHelper(HttpServletRequest httpRequest,
                          HttpServletResponse httpResponse)

  Constructs a `GenericURL`.

## Method Detail

### addParameter(String, String) Method

    public void addParameter(String name,
                             String value)

Add a parameter. Multiple values for the same parameter can be set by calling this method multiple times with the same name.

#### Parameters

name
  name

value
  value

### clone() Method

    public Object clone()

Returns a deep copy.

Overrides
  `Object.clone()`

#### Returns

clone

### getDomain() Method

    public String getDomain()

Returns the domain. If no domain was previously set, returns the domain that was used to make the current request.

#### Returns

domain

### getEncodeSession() Method

    public boolean getEncodeSession()

Returns `true` if URL rewriting is enabled.

#### Returns

boolean

### getParameter(String) Method

    public String getParameter(String name)

Returns the value of the parameter. If the parameter has several values, returns the first value.

#### Parameters

name
  name of the parameter

#### Returns

value value of the parameter

### getParameters(String) Method

    public List getParameters(String name)

Returns the values of the given parameter.

#### Parameters

name
  name of the parameter

#### Returns

values of the parameter

### getPathPrefix() Method

    public String getPathPrefix()

Returns the path prefix.

#### Returns

path prefix

### getPort() Method

    public int getPort()

Returns the port. If no port was previously set, returns the port that was used to make the current request.

#### Returns

port

### getQueryString() Method

    public String getQueryString()

### getScheme() Method

    public String getScheme()

Returns the protocol scheme. If no protocol was previously set, returns the protocol that was used to make the current request.

#### Returns

protocol scheme

### getTemplate() Method

    public String getTemplate()

Returns the current template.

#### Returns

URL template

### getTemplateName(String) Method

    public String getTemplateName(String templateRef)

### hasTemplateRef(String) Method

    public boolean hasTemplateRef(String templateRef)

### removeParameter(String) Method

    public void removeParameter(String name)

Removes the given parameter.

#### Parameters

name
  name

### setDomain(String) Method

    public void setDomain(String domain)

Sets the domain. If a domain is not specified, the domain that was used to make the current request will be used.

#### Parameters

domain
  domain

### setEncodeSession(boolean) Method

    public void setEncodeSession(boolean encodeSession)

Enables URL rewriting for encoding a session ID in the URL. If not set to `true`, does not encode the URL with the session ID. Default is `true`.

#### Parameters

encodeSession
  boolean

### setPath(String) Method

    public void setPath(String path)

Sets path.

#### Parameters

path
  path

### setPathPrefix(String) Method

    public void setPathPrefix(String pathPrefix)

Sets a path prefix.

#### Parameters

pathPrefix
  path prefix

### setPort(int) Method

    public void setPort(int port)

Sets a port. If a port is not specified, the port that was used to make the current request will be used.

#### Parameters

port
  port

### setQueryString(String) Method

    public void setQueryString(String queryString)

### setScheme(String) Method

    public void setScheme(String scheme)

Sets the protocol scheme. Should be one of "HTTP" or "HTTPS". If a protocol is not specified, the protocol that was used to make the current request will be used.

#### Parameters

scheme
  protocol scheme

### setTemplate(String) Method

    public void setTemplate(String templateName)

Sets a URL template for this URL.

#### Parameters

templateName
  name of the url template

### setUrl(String) Method

    public void setUrl(String url)

### toString() Method

    public String toString()

Returns a string form (fully-quanlfied) of this URL.

Overrides
  `Object.toString()`

#### Returns

string