Class Uris
- Object
-
- org.thymeleaf.expression.Uris
-
public final class Uris extends Object
Expression Object for performing URI/URL operations (esp.escaping/unescaping) inside Thymeleaf Standard Expressions.
An object of this class is usually available in variable evaluation expressions with the name
#uris.- Since:
- 2.1.4
- Author:
- Daniel Fernández
-
-
Constructor Summary
Constructors Constructor Description Uris()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringescapeFragmentId(String text)Perform am URI fragment identifier escape operation on aStringinput usingUTF-8as encoding.StringescapeFragmentId(String text, String encoding)Perform am URI fragment identifier escape operation on aStringinput.StringescapePath(String text)Perform am URI path escape operation on aStringinput usingUTF-8as encoding.StringescapePath(String text, String encoding)Perform am URI path escape operation on aStringinput.StringescapePathSegment(String text)Perform am URI path segment escape operation on aStringinput usingUTF-8as encoding.StringescapePathSegment(String text, String encoding)Perform am URI path segment escape operation on aStringinput.StringescapeQueryParam(String text)Perform am URI query parameter (name or value) escape operation on aStringinput usingUTF-8as encoding.StringescapeQueryParam(String text, String encoding)Perform am URI query parameter (name or value) escape operation on aStringinput.StringunescapeFragmentId(String text)Perform am URI fragment identifier unescape operation on aStringinput usingUTF-8as encoding.StringunescapeFragmentId(String text, String encoding)Perform am URI fragment identifier unescape operation on aStringinput.StringunescapePath(String text)Perform am URI path unescape operation on aStringinput usingUTF-8as encoding.StringunescapePath(String text, String encoding)Perform am URI path unescape operation on aStringinput.StringunescapePathSegment(String text)Perform am URI path segment unescape operation on aStringinput usingUTF-8as encoding.StringunescapePathSegment(String text, String encoding)Perform am URI path segment unescape operation on aStringinput.StringunescapeQueryParam(String text)Perform am URI query parameter (name or value) unescape operation on aStringinput usingUTF-8as encoding.StringunescapeQueryParam(String text, String encoding)Perform am URI query parameter (name or value) unescape operation on aStringinput.
-
-
-
Method Detail
-
escapePath
public String escapePath(String text)
Perform am URI path escape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI path (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @/
All other chars will be escaped by converting them to the sequence of bytes that represents them in the
UTF-8and then representing each byte in%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapePath
public String unescapePath(String text)
Perform am URI path unescape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use
UTF-8in order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapePath
public String escapePath(String text, String encoding)
Perform am URI path escape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI path (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @/
All other chars will be escaped by converting them to the sequence of bytes that represents them in the specified encoding and then representing each byte in
%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.encoding- the encoding to be used for unescaping.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapePath
public String unescapePath(String text, String encoding)
Perform am URI path unescape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use the specified
encodingin order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.encoding- the encoding to be used for unescaping.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapePathSegment
public String escapePathSegment(String text)
Perform am URI path segment escape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI path segment (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @
All other chars will be escaped by converting them to the sequence of bytes that represents them in the
UTF-8and then representing each byte in%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapePathSegment
public String unescapePathSegment(String text)
Perform am URI path segment unescape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use
UTF-8in order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapePathSegment
public String escapePathSegment(String text, String encoding)
Perform am URI path segment escape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI path segment (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @
All other chars will be escaped by converting them to the sequence of bytes that represents them in the specified encoding and then representing each byte in
%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.encoding- the encoding to be used for escaping.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapePathSegment
public String unescapePathSegment(String text, String encoding)
Perform am URI path segment unescape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use specified
encodingin order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.encoding- the encoding to be used for unescaping.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapeFragmentId
public String escapeFragmentId(String text)
Perform am URI fragment identifier escape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI fragment identifier (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @/ ?
All other chars will be escaped by converting them to the sequence of bytes that represents them in the
UTF-8and then representing each byte in%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapeFragmentId
public String unescapeFragmentId(String text)
Perform am URI fragment identifier unescape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use
UTF-8in order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapeFragmentId
public String escapeFragmentId(String text, String encoding)
Perform am URI fragment identifier escape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI fragment identifier (will not be escaped):
A-Z a-z 0-9- . _ ~! $ & ' ( ) * + , ; =: @/ ?
All other chars will be escaped by converting them to the sequence of bytes that represents them in the specified encoding and then representing each byte in
%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.encoding- the encoding to be used for escaping.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapeFragmentId
public String unescapeFragmentId(String text, String encoding)
Perform am URI fragment identifier unescape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use specified
encodingin order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.encoding- the encoding to be used for unescaping.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapeQueryParam
public String escapeQueryParam(String text)
Perform am URI query parameter (name or value) escape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI query parameter (will not be escaped):
A-Z a-z 0-9- . _ ~! $ ' ( ) * , ;: @/ ?
All other chars will be escaped by converting them to the sequence of bytes that represents them in the
UTF-8and then representing each byte in%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapeQueryParam
public String unescapeQueryParam(String text)
Perform am URI query parameter (name or value) unescape operation on a
Stringinput usingUTF-8as encoding.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use
UTF-8in order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
escapeQueryParam
public String escapeQueryParam(String text, String encoding)
Perform am URI query parameter (name or value) escape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.The following are the only allowed chars in an URI query parameter (will not be escaped):
A-Z a-z 0-9- . _ ~! $ ' ( ) * , ;: @/ ?
All other chars will be escaped by converting them to the sequence of bytes that represents them in the specified encoding and then representing each byte in
%HHsyntax, beingHHthe hexadecimal representation of the byte.This method is thread-safe.
- Parameters:
text- theStringto be escaped.encoding- the encoding to be used for escaping.- Returns:
- The escaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no escaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
unescapeQueryParam
public String unescapeQueryParam(String text, String encoding)
Perform am URI query parameter (name or value) unescape operation on a
Stringinput.This method simply calls the equivalent method in the
UriEscapeclass from the Unbescape library.This method will unescape every percent-encoded (
%HH) sequences present in input, even for those characters that do not need to be percent-encoded in this context (unreserved characters can be percent-encoded even if/when this is not required, though it is not generally considered a good practice).This method will use specified
encodingin order to determine the characters specified in the percent-encoded byte sequences.This method is thread-safe.
- Parameters:
text- theStringto be unescaped.encoding- the encoding to be used for unescaping.- Returns:
- The unescaped result
String. As a memory-performance improvement, will return the exact same object as thetextinput argument if no unescaping modifications were required (and no additionalStringobjects will be created during processing). Will returnnulliftextisnull.
-
-