Class LinkImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.services.LinkImpl
-
-
Constructor Summary
Constructors Constructor Description LinkImpl(java.lang.String basePath, boolean forForm, LinkSecurity defaultSecurity, Response response, ContextPathEncoder contextPathEncoder, BaseURLSource baseURLSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LinkaddParameter(java.lang.String parameterName, java.lang.String value)Adds a parameter value.LinkaddParameterValue(java.lang.String parameterName, java.lang.Object value)Adds a parameter value as a value object; the value object is converted to a string via ContextPathEncoder.encodeValue(Object) from tapestry-core and the result is added viaLink.addParameter(String, String).LinkcopyWithBasePath(java.lang.String basePath)Creates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.java.lang.StringgetAnchor()Returns the link anchor.java.lang.StringgetBasePath()Returns the completely unadorned base path.java.util.List<java.lang.String>getParameterNames()Returns the names of any additional query parameters for the URI.java.lang.StringgetParameterValue(java.lang.String name)Returns the value of a specifically named query parameter, ornullif no such query parameter is stored in the link.java.lang.String[]getParameterValues(java.lang.String parameterName)Returns the parameter values for the given name.LinkSecuritygetSecurity()Returns the current security for this link, which reflects whether the targeted page is itself secure or insecure.LinkremoveParameter(java.lang.String parameterName)Removes a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.LinksetAnchor(java.lang.String anchor)Sets the link anchor.voidsetSecurity(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.java.lang.StringtoAbsoluteURI()Returns the absolute URL, which includes the scheme, hostname and possibly port (as perBaseURLSource.getBaseURL(boolean)).java.lang.StringtoAbsoluteURI(boolean secure)Returns either the secure or insecure URL, with complete scheme, hostname and possibly port (as perBaseURLSource.getBaseURL(boolean)).java.lang.StringtoRedirectURI()Returns the link as a redirect URI.java.lang.StringtoString()Returns the value fromtoURI()java.lang.StringtoURI()Returns the URI portion of the link.
-
-
-
Constructor Detail
-
LinkImpl
public LinkImpl(java.lang.String basePath, boolean forForm, LinkSecurity defaultSecurity, Response response, ContextPathEncoder contextPathEncoder, BaseURLSource baseURLSource)
-
-
Method Detail
-
copyWithBasePath
public Link copyWithBasePath(java.lang.String basePath)
Description copied from interface:LinkCreates a copy of this link that has the same parameters, anchor, and other attributes, but a different base path.- Specified by:
copyWithBasePathin interfaceLink- Returns:
- a new Link instance
-
addParameter
public Link addParameter(java.lang.String parameterName, java.lang.String value)
Description copied from interface:LinkAdds a parameter value. The value will be added, as is, to the URL. In many cases, the value should be URL encoded viaURLCodec.- Specified by:
addParameterin interfaceLink- Parameters:
parameterName- the name of the parameter to storevalue- 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 java.lang.String getBasePath()
Description copied from interface:LinkReturns the completely unadorned base path. Other methods (such asLink.toURI()), may append an anchor or query parameters.- Specified by:
getBasePathin interfaceLink
-
removeParameter
public Link removeParameter(java.lang.String parameterName)
Description copied from interface:LinkRemoves a parameter value, which is occasionally useful when transforming a parameter into a portion of the path.- Specified by:
removeParameterin interfaceLink- Returns:
- this Link, to support method chaining
-
getAnchor
public java.lang.String getAnchor()
Description copied from interface:LinkReturns the link anchor. If this link does not have an anchor, this method returnsnull.
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames()
Description copied from interface:LinkReturns 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:
getParameterNamesin interfaceLink- Returns:
- list of query parameter names, is alphabetical order
-
getParameterValue
public java.lang.String getParameterValue(java.lang.String name)
Description copied from interface:LinkReturns the value of a specifically named query parameter, ornullif 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, useLink.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 bygetParameterValues.- Specified by:
getParameterValuein interfaceLink- Returns:
- a string representing the single value of the named parameter
-
setAnchor
public Link setAnchor(java.lang.String anchor)
Description copied from interface:LinkSets the link anchor. Null and empty anchors will be ignored when building the link URI.
-
toAbsoluteURI
public java.lang.String toAbsoluteURI()
Description copied from interface:LinkReturns the absolute URL, which includes the scheme, hostname and possibly port (as perBaseURLSource.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() orLink.toURI()(which are equivalent) instead.- Specified by:
toAbsoluteURIin interfaceLink- Returns:
- the complete, qualified URL, including query parameters.
-
toAbsoluteURI
public java.lang.String toAbsoluteURI(boolean secure)
Description copied from interface:LinkReturns either the secure or insecure URL, with complete scheme, hostname and possibly port (as perBaseURLSource.getBaseURL(boolean)).- Specified by:
toAbsoluteURIin interfaceLink- Returns:
- the complete, qualified URL, including query parameters.
-
setSecurity
public void setSecurity(LinkSecurity newSecurity)
Description copied from interface:LinkChanges 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:
setSecurityin interfaceLink- Parameters:
newSecurity- new security value, not null, typicallyLinkSecurity.FORCE_SECUREorLinkSecurity.FORCE_INSECURE
-
getSecurity
public LinkSecurity getSecurity()
Description copied from interface:LinkReturns the current security for this link, which reflects whether the targeted page is itself secure or insecure.- Specified by:
getSecurityin interfaceLink
-
toRedirectURI
public java.lang.String toRedirectURI()
Description copied from interface:LinkReturns the link as a redirect URI. The URI includes any query parameters.- Specified by:
toRedirectURIin interfaceLink
-
toURI
public java.lang.String toURI()
Description copied from interface:LinkReturns 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().
-
toString
public java.lang.String toString()
Returns the value fromtoURI()- Overrides:
toStringin classjava.lang.Object
-
addParameterValue
public Link addParameterValue(java.lang.String parameterName, java.lang.Object value)
Description copied from interface:LinkAdds a parameter value as a value object; the value object is converted to a string via ContextPathEncoder.encodeValue(Object) from tapestry-core and the result is added viaLink.addParameter(String, String). The Link object is returned for further configuration.- Specified by:
addParameterValuein interfaceLink
-
getParameterValues
public java.lang.String[] getParameterValues(java.lang.String parameterName)
Description copied from interface:LinkReturns the parameter values for the given name. Returns null if no such parameter is stored in the link.- Specified by:
getParameterValuesin interfaceLink
-
-