- java.lang.Object
-
- com.aoapps.net.URIEncoder
-
public final class URIEncoder extends Object
URI encoding utilities.TODO: These methods are for highest performance and are consistent with the JavaScript methods. They are not meant for general purpose URL manipulation, and are not trying to replace any full-featured URI tools.
Consider the following if needing more than what this provides (in no particular order):
- Author:
- AO Industries, Inc.
- See Also:
URLEncoder
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
encodeURI(String uri)
Encodes a URI to RFC 3986 ASCII format in the default encoding
.IRI.ENCODING
static void
encodeURI(String uri, Encoder encoder, Appendable out)
Encodes a URI to RFC 3986 ASCII format in the default encoding
.IRI.ENCODING
static void
encodeURI(String uri, Appendable out)
Encodes a URI to RFC 3986 ASCII format in the default encoding
.IRI.ENCODING
static void
encodeURI(String uri, StringBuffer sb)
Encodes a URI to RFC 3986 ASCII format in the default encoding
.IRI.ENCODING
static void
encodeURI(String uri, StringBuilder sb)
Encodes a URI to RFC 3986 ASCII format in the default encoding
.IRI.ENCODING
static String
encodeURIComponent(String s)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
static void
encodeURIComponent(String s, Encoder encoder, Appendable out)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
static void
encodeURIComponent(String s, Appendable out)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
static void
encodeURIComponent(String s, StringBuffer sb)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
static void
encodeURIComponent(String s, StringBuilder sb)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
-
-
-
Method Detail
-
encodeURIComponent
public static String encodeURIComponent(String s)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
This uses
URLEncoder.encode(java.lang.String)
then replaces '+' with "%20".
-
encodeURIComponent
public static void encodeURIComponent(String s, Appendable out) throws IOException
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
This uses
URLEncoder.encode(java.lang.String, java.lang.String)
then replaces '+' with "%20".
-
encodeURIComponent
public static void encodeURIComponent(String s, Encoder encoder, Appendable out) throws IOException
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
This uses
URLEncoder.encode(java.lang.String, java.lang.String)
then replaces '+' with "%20".- Parameters:
encoder
- An optional encoder the output is applied through- Throws:
IOException
- See Also:
URIDecoder.decodeURIComponent(java.lang.String, com.aoapps.lang.io.Encoder, java.lang.Appendable)
-
encodeURIComponent
public static void encodeURIComponent(String s, StringBuilder sb)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
This uses
URLEncoder.encode(java.lang.String, java.lang.String)
then replaces '+' with "%20".
-
encodeURIComponent
public static void encodeURIComponent(String s, StringBuffer sb)
Encodes a value for use in a path component or fragment in the default encoding
.IRI.ENCODING
This uses
URLEncoder.encode(java.lang.String, java.lang.String)
then replaces '+' with "%20".
-
encodeURI
public static String encodeURI(String uri)
Encodes a URI to RFC 3986 ASCII format in the default encoding
. Encodes the characters in the URI, not including any characters defined in RFC 3986: Reserved Characters, '%' (for already percent-encoded), and unprintable invalid.IRI.ENCODING
Any existing lower-case percent-encoded values are normalized to upper-case.
- Returns:
- The encoded URI or
url
when not modified - See Also:
URIDecoder.decodeURI(java.lang.String)
-
encodeURI
public static void encodeURI(String uri, Appendable out) throws IOException
Encodes a URI to RFC 3986 ASCII format in the default encoding
. Encodes the characters in the URI, not including any characters defined in RFC 3986: Reserved Characters, '%' (for already percent-encoded), and unprintable invalid.IRI.ENCODING
Any existing lower-case percent-encoded values are normalized to upper-case.
- Throws:
IOException
- See Also:
URIDecoder.decodeURI(java.lang.String, java.lang.Appendable)
-
encodeURI
public static void encodeURI(String uri, Encoder encoder, Appendable out) throws IOException
Encodes a URI to RFC 3986 ASCII format in the default encoding
. Encodes the characters in the URI, not including any characters defined in RFC 3986: Reserved Characters, '%' (for already percent-encoded), and unprintable invalid.IRI.ENCODING
Any existing lower-case percent-encoded values are normalized to upper-case.
- Parameters:
encoder
- An optional encoder the output is applied through- Throws:
IOException
- See Also:
URIDecoder.decodeURI(java.lang.String, com.aoapps.lang.io.Encoder, java.lang.Appendable)
-
encodeURI
public static void encodeURI(String uri, StringBuilder sb)
Encodes a URI to RFC 3986 ASCII format in the default encoding
. Encodes the characters in the URI, not including any characters defined in RFC 3986: Reserved Characters, '%' (for already percent-encoded), and unprintable invalid.IRI.ENCODING
Any existing lower-case percent-encoded values are normalized to upper-case.
-
encodeURI
public static void encodeURI(String uri, StringBuffer sb)
Encodes a URI to RFC 3986 ASCII format in the default encoding
. Encodes the characters in the URI, not including any characters defined in RFC 3986: Reserved Characters, '%' (for already percent-encoded), and unprintable invalid.IRI.ENCODING
Any existing lower-case percent-encoded values are normalized to upper-case.
-
-