public abstract class UriCodec extends Object
| Constructor and Description |
|---|
UriCodec() |
| Modifier and Type | Method and Description |
|---|---|
void |
appendEncoded(StringBuilder builder,
String s)
Encodes the string
s as per the rules of this encoder (see class level comment). |
void |
appendPartiallyEncoded(StringBuilder builder,
String s)
Encodes the string
s as per the rules of this encoder (see class level comment). |
static String |
decode(String s)
Equivalent to
decode(s, false, UTF_8, true) |
static String |
decode(String s,
boolean convertPlus,
Charset charset,
boolean throwOnFailure)
Decode a string according to the rules of this decoder.
|
String |
encode(String s,
Charset charset)
Encodes the string
s as per the rules of this encoder (see class level comment). |
protected abstract boolean |
isRetained(char c)
Returns true iff.
|
String |
validate(String uri,
int start,
int end,
String name)
Throw URISyntaxException if any of the characters in the range [start, end) are not valid
according to this codec.
|
static void |
validateSimple(String uri,
String legal)
|
protected abstract boolean isRetained(char c)
public final String validate(String uri, int start, int end, String name) throws URISyntaxException
name is not used, except to generate debugging info.URISyntaxExceptionpublic static void validateSimple(String uri, String legal) throws URISyntaxException
URISyntaxExceptionpublic final String encode(String s, Charset charset)
s as per the rules of this encoder (see class level comment).IllegalArgumentException - if the encoder is unable to encode a sequence of bytes.public final void appendEncoded(StringBuilder builder, String s)
s as per the rules of this encoder (see class level comment).
Encoded output is appended to builder. This uses the default output encoding (UTF-8).public final void appendPartiallyEncoded(StringBuilder builder, String s)
s as per the rules of this encoder (see class level comment).
Encoded output is appended to builder. This uses the default output encoding (UTF-8).
This method must produce partially encoded output. What this means is that if encoded octets
appear in the input string, they are passed through unmodified, instead of being double
escaped. Consider a decoder operating on the global whitelist dealing with a string
“foo%25bar”. With this method, the output will be “foo%25bar”, but with appendEncoded, it
will be double encoded into “foo%2525bar”.public static String decode(String s, boolean convertPlus, Charset charset, boolean throwOnFailure)
convertPlus == true all ‘+’ chars in the decoded output are converted to ‘ ‘
(white space)
- if throwOnFailure == true, an IllegalArgumentException is thrown for
invalid inputs. Else, U+FFFd is emitted to the output in place of invalid input octets.