class URIEncoderDecoder extends Object
application/x-www-form-urlencoded
MIME content type. It contains helper
methods used by the Uri class, and performs encoding and decoding in a
slightly different way than URLEncoder
and URLDecoder
.Modifier and Type | Field and Description |
---|---|
(package private) static String |
digits |
(package private) static String |
encoding |
private static Map<String,Character> |
legalEscaped |
Constructor and Description |
---|
URIEncoderDecoder() |
Modifier and Type | Method and Description |
---|---|
(package private) static String |
decode(String s)
Decodes the string argument which is assumed to be encoded in the
x-www-form-urlencoded MIME content type using the UTF-8 encoding scheme. |
(package private) static String |
decodeUnreserved(String s) |
(package private) static String |
encodeOthers(String s)
Other characters, which are Unicode chars that are not US-ASCII, and are
not ISO Control or are not ISO Space chars are not preserved.
|
private static boolean |
isValidHexChar(char c) |
(package private) static String |
quoteIllegal(String s,
String legal)
All characters except letters ('a'..'
|
(package private) static void |
validate(String s,
String legal)
Validate a string by checking if it contains any characters other than:
1. letters ('a'..'
|
(package private) static void |
validateSimple(String s,
String legal) |
static final String digits
static final String encoding
static void validate(String s, String legal) throws URISyntaxException
called from URI.Helper.parseURI()
to validate each component
s
- java.lang.String
the string to be validatedlegal
- java.lang.String
the characters allowed in the String
sURISyntaxException
static void validateSimple(String s, String legal) throws URISyntaxException
URISyntaxException
static String quoteIllegal(String s, String legal) throws UnsupportedEncodingException
For example: '#' -> %23 Other characters, which are unicode chars that are not US-ASCII, and are not ISO Control or are not ISO Space chars, are preserved.
Called from URI.quoteComponent()
(for multiple argument
constructors)
s
- java.lang.String the string to be convertedlegal
- java.lang.String the characters allowed to be preserved in the
string sUnsupportedEncodingException
static String encodeOthers(String s) throws UnsupportedEncodingException
For example: Euro currency symbol -> "%E2%82%AC".
Called from URI.toASCIIString()
s
- java.lang.String the string to be convertedUnsupportedEncodingException
static String decode(String s) throws UnsupportedEncodingException
x-www-form-urlencoded
MIME content type using the UTF-8 encoding scheme.
'%' and two following hex digit characters are converted to the equivalent byte value. All other characters are passed through unmodified.
e.g. "A%20B%20C %24%25" -> "A B C $%"
Called from URI.getXYZ() methods
s
- java.lang.String The encoded string.UnsupportedEncodingException
static String decodeUnreserved(String s) throws URISyntaxException
URISyntaxException
private static boolean isValidHexChar(char c)
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.