Package wt.httpgw
Class EncodingConverter
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
wt.util.EncodingConverter
wt.httpgw.EncodingConverter
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Deprecated.
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:
- The ASCII characters '
a' through 'z', 'A' through 'Z', and '0' through '9' remain the same. - The space character '
' is converted into a plus sign '+'. - All other characters are converted into an 8-bit byte sequence using
a character encoding and the resulting bytes are each represented as a
3-character string "
%xy", where xy is the two-digit hexadecimal representation of the byte.
Deployment Notes:
-
The EncodingConverter is a replacement for WTURLEncoder and is instance
based. The EncodingConverter should not be shared amongst threads or
used as a static instance unless appropriate synchronization blocks are
used to protect the internal buffers from overrighting. This can be done
one of two ways. Firstly by declaring the method which calls the
encode/decode methods as synchronized, or by placing a syncrhonized block
around the actually calls to encode/decode as shown below.
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
ConstructorsConstructorDescriptionDeprecated.Consturctor to create a new EncodingConverter with the encoding set to UTF-8.EncodingConverter(int byteSize) Deprecated.Constructor to create a new EncodingConverter with an encoding set to UTF-8 and a specified buffer capacity.EncodingConverter(String encoding) Deprecated.Constructor to create a new EncodingConverter with a specified encoding. -
Method Summary
Methods inherited from class wt.util.EncodingConverter
decode, decode, decodeBytes, decodeBytes, decodeBytes, encode, encode, encode, encode, escapeMethods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeToMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
EncodingConverter
public EncodingConverter()Deprecated.Consturctor to create a new EncodingConverter with the encoding set to UTF-8.
Supported API: true- See Also:
-
EncodingConverter
public EncodingConverter(int byteSize) Deprecated.Constructor to create a new EncodingConverter with an encoding set to UTF-8 and a specified buffer capacity.
Supported API: true- Parameters:
byteSize- The buffer capacity.- See Also:
-
EncodingConverter
Deprecated.Constructor to create a new EncodingConverter with a specified encoding.
Supported API: true- Parameters:
encoding- The encoding to use for encode/decoding.- See Also:
-
Supported API: true
Extendable: false