Package org.ametys.core.util
Class URIUtils
- java.lang.Object
-
- org.ametys.core.util.URIUtils
-
public final class URIUtils extends Object
Utility class for encoding and decoding URL, following the RFC 3986- See Also:
- https://tools.ietf.org/html/rfc3986
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__NAME_VALUE_SEPARATOR
private static String
__PARAMETER_SEPARATOR
private static Predicate<Byte>
_isAlpha
private static Predicate<Byte>
_isDigit
private static Predicate<Byte>
_isPchar
private static Predicate<Byte>
_isSubDelimiter
private static Predicate<Byte>
_isUnreserved
-
Constructor Summary
Constructors Modifier Constructor Description private
URIUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static String
_buildURI(String path, Map<String,String> parameters, boolean encode)
private static String
_encodeUriComponent(String uriComponent, Predicate<Byte> charactersToKeep)
static String
buildURI(String path, Map<String,String> parameters)
Build an URL.static String
decode(String source)
Decodes an URI-encoded String.static String
encodeHeader(String header)
Encode a request header value.static String
encodeParameter(String value)
Encode a parameter's value using UTF-8 encodingstatic String
encodePath(String path)
Encode an URL pathstatic String
encodePathSegment(String pathSegment)
Encode an URL path segmentstatic String
encodeURI(String path, Map<String,String> parameters)
Encode an URL path
-
-
-
Field Detail
-
__NAME_VALUE_SEPARATOR
private static final String __NAME_VALUE_SEPARATOR
- See Also:
- Constant Field Values
-
__PARAMETER_SEPARATOR
private static final String __PARAMETER_SEPARATOR
- See Also:
- Constant Field Values
-
_isSubDelimiter
private static Predicate<Byte> _isSubDelimiter
-
_isUnreserved
private static Predicate<Byte> _isUnreserved
-
-
Constructor Detail
-
URIUtils
private URIUtils()
-
-
Method Detail
-
encodeParameter
public static String encodeParameter(String value)
Encode a parameter's value using UTF-8 encoding- Parameters:
value
- the value or the name of the request's parameter to encode- Returns:
- the encoded value.
-
encodePath
public static String encodePath(String path)
Encode an URL path- Parameters:
path
- the path to encode (before question-mark character)- Returns:
- the encoded path.
-
encodePathSegment
public static String encodePathSegment(String pathSegment)
Encode an URL path segment- Parameters:
pathSegment
- the path segment to encode- Returns:
- the encoded path segment.
-
encodeHeader
public static String encodeHeader(String header)
Encode a request header value.- Parameters:
header
- the value to encode- Returns:
- the encoded value.
-
_encodeUriComponent
private static String _encodeUriComponent(String uriComponent, Predicate<Byte> charactersToKeep)
-
encodeURI
public static String encodeURI(String path, Map<String,String> parameters)
Encode an URL path- Parameters:
path
- the path to encode (before question-mark character)parameters
- the parameters. Can be null.- Returns:
- the encoded path
-
buildURI
public static String buildURI(String path, Map<String,String> parameters)
Build an URL.- Parameters:
path
- the URL path.parameters
- the URL parameters. Can be null.- Returns:
- the computed URL.
-
_buildURI
private static String _buildURI(String path, Map<String,String> parameters, boolean encode)
-
-