|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.ByteArrayOutputStream
wt.util.EncodingConverter
public class EncodingConverter
The class contains utility methods for converting a
String into a MIME format called
"x-www-form-urlencoded" and vice versa.
To convert a String, each character is examined in turn:
a' through 'z',
'A' through 'Z', and '0'
through '9' remain the same.
' is converted into a
plus sign '+'.
%xy", where xy is the
two-digit hexadecimal representation of the byte.
Deployment Notes:
static EncodingConverter staticEncoder = new EncodingConverter();
public void sampleMethod(String s)
{
synchronized( staticEncoder )
}
{
staticEncoder.encode(s);
}
| Field Summary |
|---|
| Fields inherited from class java.io.ByteArrayOutputStream |
|---|
buf, count |
| Constructor Summary | |
|---|---|
EncodingConverter()
Consturctor to create a new EncodingConverter with the encoding set to UTF-8. |
|
EncodingConverter(int ByteSize)
Constructor to create a new EncodingConverter with an encoding set to UTF-8 and a specified buffer capacity. |
|
EncodingConverter(String encoding)
Constructor to create a new EncodingConverter with a specified encoding. |
|
| Method Summary | |
|---|---|
String |
decode(String s)
Translates a string from x-www-form-urlencoded format back
into a string. |
String |
decode(String encoded,
String encoding)
Translates a string from x-www-form-urlencoded format back the
original string. |
static String |
decodeBytes(String str)
Convience method to convert the bytes of a String in ISO-8859_1 encoding to UTF-8 encoding. |
static String |
decodeBytes(String str,
String enc)
Convience method to convert the bytes of a String in ISO-8859_1 encoding to a designated encoding. |
static String |
decodeBytes(String str,
String from_enc,
String to_enc)
Convience method to convert the bytes of a String in an input encoding encoding to a designated encoding. |
String |
encode(String s)
Translates a string into x-www-form-urlencoded format. |
void |
encode(StringBuffer buf,
String s)
Translates a string into x-www-form-urlencoded format. |
void |
encode(StringBuffer buf,
String s,
String encoding)
Translates a string into x-www-form-urlencoded format. |
String |
encode(String s,
String encoding)
Translates a string into x-www-form-urlencoded format. |
static String |
escape(String str)
Escape special characters in accordance with URL path segment encoding requirements. |
| Methods inherited from class java.io.ByteArrayOutputStream |
|---|
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo |
| Methods inherited from class java.io.OutputStream |
|---|
flush, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public EncodingConverter()
public EncodingConverter(int ByteSize)
ByteSize - The buffer capacity.public EncodingConverter(String encoding)
encoding - The encoding to use for encode/decoding.| Method Detail |
|---|
public String encode(String s)
x-www-form-urlencoded format.
Hex escaped characters are first encoded using UTF8 character encoding
before Hex escaping the resulting bytes. This produces an encoded
string that can be decoded without loss of data.
s - String to be translated.
String.
public String encode(String s,
String encoding)
x-www-form-urlencoded format.
Hex escaped characters are first encoded using the given character encoding
before Hex escaping the resulting bytes.
s - String to be translated.encoding - the character encoding name
String, or "" if the string s was null.
public void encode(StringBuffer buf,
String s)
x-www-form-urlencoded format.
Hex escaped characters are first encoded using UTF8 character encoding
before Hex escaping the resulting bytes. This produces an encoded
string that can be decoded without loss of data.
buf - StringBuffer to receive encoded characters.s - String to be translated.
public void encode(StringBuffer buf,
String s,
String encoding)
x-www-form-urlencoded format.
Hex escaped characters are first encoded using the given character encoding
before Hex escaping the resulting bytes.
buf - StringBuffer to receive encoded characters.s - String to be translated.encoding - the character encoding namepublic static String escape(String str)
str - String to escape.
public String decode(String s)
x-www-form-urlencoded format back
into a string. Hex escaped bytes are converted and the resulting sequence of
8-bit values is converted to characters using UTF8 encoding. This produces a
decoded string from the results of encode without loss data.
s - String to be translated.
String.
public String decode(String encoded,
String encoding)
x-www-form-urlencoded format back the
original string. Hex escaped bytes are converted and the resulting
sequence of 8-bit values is converted to characters using the given character
encoding.
encoded - String to be translated.encoding - the character encoding name
String or "" if encoded is null.
public static final String decodeBytes(String str)
throws UnsupportedEncodingException
str - The string to re-encode for the correct bytes.
UnsupportedEncodingException
public static final String decodeBytes(String str,
String enc)
throws UnsupportedEncodingException
str - The string to re-encode for the correct bytes.enc - The encoding to translate to.
UnsupportedEncodingException
public static final String decodeBytes(String str,
String from_enc,
String to_enc)
throws UnsupportedEncodingException
str - The string to re-encode for the correct bytes.from_enc - The encoding coming from.to_enc - The encoding to translate to.
UnsupportedEncodingException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||