Build 1.0_r1(from source)

java.net
Class URIEncoderDecoder

java.lang.Object
  extended by java.net.URIEncoderDecoder

 class URIEncoderDecoder
extends Object

This class is used to encode a string using the format required by 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.


Field Summary
(package private) static String digits
           
(package private) static String encoding
           
 
Constructor Summary
URIEncoderDecoder()
           
 
Method Summary
(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 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.
(package private) static String quoteIllegal(String s, String legal)
          All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') and legal characters are converted into their hexidecimal value prepended by '%'.
(package private) static void validate(String s, String legal)
          Validate a string by checking if it contains any characters other than: 1.
(package private) static void validateSimple(String s, String legal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

digits

static final String digits
See Also:
Constant Field Values

encoding

static final String encoding
See Also:
Constant Field Values
Constructor Detail

URIEncoderDecoder

URIEncoderDecoder()
Method Detail

validate

static void validate(String s,
                     String legal)
              throws URISyntaxException
Validate a string by checking if it contains any characters other than: 1. letters ('a'..'z', 'A'..'Z') 2. numbers ('0'..'9') 3. characters in the legalset parameter 4. others (Unicode characters that are not in US-ASCII set, and are not ISO Control or are not ISO Space characters)

called from URI.Helper.parseURI() to validate each component

Parameters:
s - java.lang.String the string to be validated
legal - java.lang.String the characters allowed in the String s
Throws:
URISyntaxException

validateSimple

static void validateSimple(String s,
                           String legal)
                    throws URISyntaxException
Throws:
URISyntaxException

quoteIllegal

static String quoteIllegal(String s,
                           String legal)
                    throws UnsupportedEncodingException
All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') and legal characters are converted into their hexidecimal value prepended by '%'.

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)

Parameters:
s - java.lang.String the string to be converted
legal - java.lang.String the characters allowed to be preserved in the string s
Returns:
java.lang.String the converted string
Throws:
UnsupportedEncodingException

encodeOthers

static String encodeOthers(String s)
                    throws UnsupportedEncodingException
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. They are converted into their hexidecimal value prepended by '%'.

For example: Euro currency symbol -> "%E2%82%AC".

Called from URI.toASCIIString()

Parameters:
s - java.lang.String the string to be converted
Returns:
java.lang.String the converted string
Throws:
UnsupportedEncodingException

decode

static String decode(String s)
              throws UnsupportedEncodingException
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.

'%' 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

Parameters:
s - java.lang.String The encoded string.
Returns:
java.lang.String The decoded version.
Throws:
UnsupportedEncodingException

Build 1.0_r1(from source)

Please submit a feedback, bug or feature