|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.request.Url
public class Url
Represents the URL part after Wicket Filter. For example if Wicket Filter is mapped to
/app/*
then with URL /app/my/url
the Url
object would represent
part my/url
. If Wicket Filter is mapped to /*
then with URL
/my/url
the Url
object would represent my/url
(without leading
the slash).
URL consists of segments and query parameters.
Example URLs:
foo/bar/baz?a=1&b=5 - segments: ["foo","bar,"baz], query parameters: ["a"="1", "b"="5"] foo/bar//baz?=4&6 - segments: ["foo", "bar", "", "baz"], query parameters: [""="4", "6"=""] /foo/bar/ - segments: ["", "foo", "bar", ""] foo/bar// - segments: ["foo", "bar", "", ""] ?a=b - segments: [ ], query parameters: ["a"="b"] / - segments: ["", ""] (note that Url represents part after Wicket Filter - so if Wicket filter is mapped to /* this would be an additional slash, i.e. //The Url class takes care of encoding and decoding of the segments and parameters.
Nested Class Summary | |
---|---|
static class |
Url.QueryParameter
Represents a single query parameter |
static class |
Url.StringMode
Modes with which urls can be stringized |
Constructor Summary | |
---|---|
Url()
Construct. |
|
Url(Charset charset)
Construct. |
|
Url(List<String> segments,
Charset charset)
Construct. |
|
Url(List<String> segments,
List<Url.QueryParameter> parameters)
Construct. |
|
Url(List<String> segments,
List<Url.QueryParameter> parameters,
Charset charset)
Construct. |
|
Url(Url url)
Construct. |
Method Summary | |
---|---|
void |
addQueryParameter(String name,
Object value)
Convenience method that removes adds a query parameter with given name |
Url |
canonical()
Try to reduce url by eliminating '..' and '.' from the path where appropriate (this is somehow similar to File.getCanonicalPath() ). |
void |
concatSegments(List<String> segments)
Concatenate the specified segments; The segments can be relative - begin with "." or "..". |
boolean |
equals(Object obj)
|
Charset |
getCharset()
|
String |
getHost()
Gets the host name of this url |
String |
getPath()
return path for current url in original encoding |
String |
getPath(Charset charset)
return path for current url in given encoding |
Integer |
getPort()
Gets the port of this url |
String |
getProtocol()
Gets the protocol of this url (http/https/etc) |
Url.QueryParameter |
getQueryParameter(String name)
Returns first query parameter with specified name or null if such query parameter doesn't exist. |
List<Url.QueryParameter> |
getQueryParameters()
Returns query parameters of the URL. |
StringValue |
getQueryParameterValue(String name)
Returns the value of first query parameter with specified name. |
String |
getQueryString()
return query string part of url in original encoding |
String |
getQueryString(Charset charset)
return query string part of url in given encoding |
List<String> |
getSegments()
Returns segments of the URL. |
int |
hashCode()
|
boolean |
isAbsolute()
Returns whether the Url is absolute. |
static Url |
parse(String url)
Parses the given URL string. |
static Url |
parse(String url,
Charset charset)
Parses the given URL string. |
void |
prependLeadingSegments(List<String> newSegments)
Convenience method that prepends segments to the segments collection |
void |
removeLeadingSegments(int count)
Convenience method that removes count leading segments |
void |
removeQueryParameters(String name)
Convenience method that removes all query parameters with given name. |
void |
resolveRelative(Url relative)
Makes this url the result of resolving the relative url against this url. |
void |
setHost(String host)
Sets the host name of this url |
void |
setPort(Integer port)
Sets the port of this url |
void |
setProtocol(String protocol)
Sets the protocol of this url (http/https/etc) |
void |
setQueryParameter(String name,
Object value)
Convenience method that removes all query parameters with given name and adds new query parameter with specified name and value |
String |
toAbsoluteString()
Deprecated. see toString(StringMode) |
String |
toAbsoluteString(Charset charset)
Deprecated. see toString(StringMode, Charset) |
String |
toString()
Renders a url with Url.StringMode.LOCAL using the url's charset |
String |
toString(Charset charset)
Stringizes this url using Url.StringMode.LOCAL and the specified charset |
String |
toString(Url.StringMode mode)
Stringizes this url using the specifid Url.StringMode and url's charset |
String |
toString(Url.StringMode mode,
Charset charset)
Stringizes this url |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Url()
public Url(Charset charset)
charset
- public Url(Url url)
url
- url being copiedpublic Url(List<String> segments, List<Url.QueryParameter> parameters)
segments
- parameters
- public Url(List<String> segments, Charset charset)
segments
- charset
- public Url(List<String> segments, List<Url.QueryParameter> parameters, Charset charset)
segments
- parameters
- charset
- Method Detail |
---|
public static Url parse(String url)
url
- absolute or relative url with query string
public static Url parse(String url, Charset charset)
url
- absolute or relative url with query stringcharset
-
public Charset getCharset()
public List<String> getSegments()
public List<Url.QueryParameter> getQueryParameters()
public boolean isAbsolute()
true
if Url is absolute, false
otherwise.public void removeQueryParameters(String name)
name
- query parameter namepublic void removeLeadingSegments(int count)
count
leading segments
count
- public void prependLeadingSegments(List<String> newSegments)
segments
to the segments collection
newSegments
- public void setQueryParameter(String name, Object value)
name
- value
- public void addQueryParameter(String name, Object value)
name
- value
- public Url.QueryParameter getQueryParameter(String name)
name
-
null
public StringValue getQueryParameterValue(String name)
null
. Not even if the parameter does not exist.
name
-
StringValue
instance wrapping the parameter valueStringValue.isNull()
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
Url.StringMode.LOCAL
using the url's charset
toString
in class Object
@Deprecated public String toAbsoluteString()
toString(StringMode)
@Deprecated public String toAbsoluteString(Charset charset)
toString(StringMode, Charset)
charset
-
public String toString(Url.StringMode mode, Charset charset)
mode
- Url.StringMode
that determins how to stringize the urlcharset
- charset
public String toString(Url.StringMode mode)
Url.StringMode
and url's charset
mode
- Url.StringMode
that determins how to stringize the url
public String toString(Charset charset)
Url.StringMode.LOCAL
and the specified charset
charset
-
public void concatSegments(List<String> segments)
segments
- public void resolveRelative(Url relative)
relative
url against this url.
Segments will be properly resolved, handling any ..
references, while the query
parameters will be completely replaced with relative
's query parameters.
For example:
wicket/page/render?foo=barresolved with
../component/render?a=bwill become
wicket/component/render?a=b
relative
- relative urlpublic String getProtocol()
null
if none has been setpublic void setProtocol(String protocol)
protocol
- public Integer getPort()
null
if none has been setpublic void setPort(Integer port)
port
- public String getHost()
null
if none is setopublic void setHost(String host)
host
- public String getPath(Charset charset)
charset
- character set for encoding
public String getPath()
public String getQueryString(Charset charset)
charset
- character set for encoding
public String getQueryString()
public Url canonical()
File.getCanonicalPath()
).
Either by different / unexpected browser behavior or by malicious attacks it
can happen that these kind of redundant urls are processed by wicket. These urls
can cause some trouble when mapping the request.
example:
the url
/example/..;jsessionid=234792?0will not get normalized by the browser due to the ';jsessionid' string that gets appended by the servlet container. After wicket strips the jsessionid part the resulting internal url will be
/example/..instead of
/This code correlates to WICKET-4303
url
- unprocessed url
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |