org.apache.tapestry5.internal.services

## Class LinkImpl

- java.lang.Object
- - org.apache.tapestry5.internal.services.LinkImpl

- All Implemented Interfaces:
    Link

      public class LinkImpl
      extends Object
      implements Link

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LinkImpl(String basePath, boolean forForm, LinkSecurity defaultSecurity, Response response, ContextPathEncoder contextPathEncoder, BaseURLSource baseURLSource)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Link` | `addParameter(String parameterName, String value)` Adds a parameter value.
    `Link` | `addParameterValue(String parameterName, Object value)` Adds a parameter value as a value object; the value object is converted to a string via `ContextPathEncoder.encodeValue(Object)` and the result is added via `Link.addParameter(String, String)`.
    `Link` | `copyWithBasePath(String basePath)` Creates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.
    `String` | `getAnchor()` Returns the link anchor.
    `String` | `getBasePath()` Returns the completely unadorned base path.
    `List<String>` | `getParameterNames()` Returns the names of any additional query parameters for the URI.
    `String` | `getParameterValue(String name)` Returns the value of a specifically named query parameter, or `null` if no such query parameter is stored in the link.
    `String[]` | `getParameterValues(String parameterName)` Returns the parameter values for the given name.
    `LinkSecurity` | `getSecurity()` Returns the current security for this link, which reflects whether the targeted page is itself secure or insecure.
    `Link` | `removeParameter(String parameterName)` Removes a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.
    `Link` | `setAnchor(String anchor)` Sets the link anchor.
    `void` | `setSecurity(LinkSecurity newSecurity)` Changes the link's security, which can be useful to force a link to be either secure or insecure when normally it might not be.
    `String` | `toAbsoluteURI()` Returns the absolute URL, which includes the scheme, hostname and possibly port (as per `BaseURLSource.getBaseURL(boolean)`).
    `String` | `toAbsoluteURI(boolean secure)` Returns either the secure or insecure URL, with complete scheme, hostname and possibly port (as per `BaseURLSource.getBaseURL(boolean)`).
    `String` | `toRedirectURI()` Returns the link as a redirect URI.
    `String` | `toString()` Returns the value from `toURI()`
    `String` | `toURI()` Returns the URI portion of the link.

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

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

- - ### Constructor Detail

    - #### LinkImpl

          public LinkImpl(String basePath,
                          boolean forForm,
                          LinkSecurity defaultSecurity,
                          Response response,
                          ContextPathEncoder contextPathEncoder,
                          BaseURLSource baseURLSource)

  - ### Method Detail

    - #### copyWithBasePath

          public Link copyWithBasePath(String basePath)

      Description copied from interface: `Link`
      Creates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.
      Specified by:
        `copyWithBasePath` in interface `Link`
      Returns:
        a new Link instance

    - #### addParameter

          public Link addParameter(String parameterName,
                                   String value)

      Description copied from interface: `Link`
      Adds a parameter value. The value will be added, as is, to the URL. In many cases, the value should be URL encoded via `URLCodec`.
      Specified by:
        `addParameter` in interface `Link`
      Parameters:
        `parameterName` - the name of the parameter to store
        `value` - the value to store, a null or blank value is allowed (as of Tapestry 5.3)
      Returns:
        this Link, to support method chaining

    - #### getBasePath

          public String getBasePath()

      Description copied from interface: `Link`
      Returns the completely unadorned base path. Other methods (such as `Link.toURI()`), may append an anchor or query parameters.
      Specified by:
        `getBasePath` in interface `Link`

    - #### removeParameter

          public Link removeParameter(String parameterName)

      Description copied from interface: `Link`
      Removes a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.
      Specified by:
        `removeParameter` in interface `Link`
      Returns:
        this Link, to support method chaining

    - #### getAnchor

          public String getAnchor()

      Description copied from interface: `Link`
      Returns the link anchor. If this link does not have an anchor, this method returns `null`.
      Specified by:
        `getAnchor` in interface `Link`
      Returns:
        the link anchor

    - #### getParameterNames

          public List<String> getParameterNames()

      Description copied from interface: `Link`
      Returns the names of any additional query parameters for the URI. Query parameters store less regular or less often used values that can not be expressed in the path. They also are used to store, or link to, persistent state.
      Specified by:
        `getParameterNames` in interface `Link`
      Returns:
        list of query parameter names, is alphabetical order

    - #### getParameterValue

          public String getParameterValue(String name)

      Description copied from interface: `Link`
      Returns the value of a specifically named query parameter, or `null` if no such query parameter is stored in the link. Use this method only when you are sure the parameter has only one value. If the parameter might have more than one value, use `Link.getParameterValues(java.lang.String)`. If you use this method with a multivalued parameter, the value returned is equal to the first value in the array returned by `getParameterValues`.
      Specified by:
        `getParameterValue` in interface `Link`
      Returns:
        a string representing the single value of the named parameter

    - #### setAnchor

          public Link setAnchor(String anchor)

      Description copied from interface: `Link`
      Sets the link anchor. Null and empty anchors will be ignored when building the link URI.
      Specified by:
        `setAnchor` in interface `Link`
      Parameters:
        `anchor` - the link anchor
      Returns:
        this Link, to support method chaining

    - #### toAbsoluteURI

          public String toAbsoluteURI()

      Description copied from interface: `Link`
      Returns the absolute URL, which includes the scheme, hostname and possibly port (as per `BaseURLSource.getBaseURL(boolean)`). By default, the scheme is chosen to match the security of the current request. Note: the semantics of this method changed between Tapestry 5.1 and 5.2. Most code should use toString() or `Link.toURI()` (which are equivalent) instead.
      Specified by:
        `toAbsoluteURI` in interface `Link`
      Returns:
        the complete, qualified URL, including query parameters.

    - #### toAbsoluteURI

          public String toAbsoluteURI(boolean secure)

      Description copied from interface: `Link`
      Returns either the secure or insecure URL, with complete scheme, hostname and possibly port (as per `BaseURLSource.getBaseURL(boolean)`).
      Specified by:
        `toAbsoluteURI` in interface `Link`
      Returns:
        the complete, qualified URL, including query parameters.

    - #### setSecurity

          public void setSecurity(LinkSecurity newSecurity)

      Description copied from interface: `Link`
      Changes the link's security, which can be useful to force a link to be either secure or insecure when normally it might not be.
      Specified by:
        `setSecurity` in interface `Link`
      Parameters:
        `newSecurity` - new security value, not null, typically `LinkSecurity.FORCE_SECURE` or `LinkSecurity.FORCE_INSECURE`

    - #### getSecurity

          public LinkSecurity getSecurity()

      Description copied from interface: `Link`
      Returns the current security for this link, which reflects whether the targeted page is itself secure or insecure.
      Specified by:
        `getSecurity` in interface `Link`

    - #### toRedirectURI

          public String toRedirectURI()

      Description copied from interface: `Link`
      Returns the link as a redirect URI. The URI includes any query parameters.
      Specified by:
        `toRedirectURI` in interface `Link`

    - #### toURI

          public String toURI()

      Description copied from interface: `Link`
      Returns the URI portion of the link. When the link is created for a form, this will not include query parameters. This is the same value returned from toString().
      Specified by:
        `toURI` in interface `Link`
      Returns:
        the URI, ready to be added as an element attribute

    - #### toString

          public String toString()

      Returns the value from `toURI()`
      Overrides:
        `toString` in class `Object`

    - #### addParameterValue

          public Link addParameterValue(String parameterName,
                                        Object value)

      Description copied from interface: `Link`
      Adds a parameter value as a value object; the value object is converted to a string via `ContextPathEncoder.encodeValue(Object)` and the result is added via `Link.addParameter(String, String)`. The Link object is returned for further configuration.
      Specified by:
        `addParameterValue` in interface `Link`

    - #### getParameterValues

          public String[] getParameterValues(String parameterName)

      Description copied from interface: `Link`
      Returns the parameter values for the given name. Returns null if no such parameter is stored in the link.
      Specified by:
        `getParameterValues` in interface `Link`

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.