public class StringEncoder extends Object
The cache is controlled via two parameters:
Constructor and Description |
---|
StringEncoder()
Creates a new StringEncoder.
|
StringEncoder(StringEncoderCache cache)
Creates a new StringEncoder.
|
Modifier and Type | Method and Description |
---|---|
static int |
computeCStringSize(String string)
Returns the visitor's output buffer.
|
static int |
computeStringSize(String string)
Returns the visitor's output buffer.
|
void |
encode(String string,
OutputStream out)
Writes the string as a UTF-8 string.
|
int |
encodeSize(String string)
Computes the size of the encoded UTF8 String based on the table below.
|
protected void |
fastEncode(String string,
OutputStream out)
Writes the string as a UTF-8 string.
|
StringEncoderCache |
getCache()
Deprecated.
The cache
StringEncoderCache should be controlled
directly. This method will be removed after the 2.1.0
release. |
static int |
utf8Size(String string)
Computes the size of the encoded UTF8 String based on the table below.
|
public StringEncoder()
public StringEncoder(StringEncoderCache cache)
cache
- The cache for the encoder to use.public static int computeCStringSize(String string)
string
- The 'C' string to determine the size of.public static int computeStringSize(String string)
string
- The 'UTF8' string to determine the size of.public static int utf8Size(String string)
# Code Points Bytes 1 U+0000..U+007F 1 2 U+0080..U+07FF 2 3 U+0800..U+0FFF 3 U+1000..U+FFFF 4 U+10000..U+3FFFF 4 U+40000..U+FFFFF 4 U+100000..U10FFFF 4
string
- The string to determine the length of.public void encode(String string, OutputStream out) throws IOException
string
- The string to encode.out
- The stream to write to.IOException
- On a failure to write the bytes.public int encodeSize(String string)
# Code Points Bytes 1 U+0000..U+007F 1 2 U+0080..U+07FF 2 3 U+0800..U+0FFF 3 U+1000..U+FFFF 4 U+10000..U+3FFFF 4 U+40000..U+FFFFF 4 U+100000..U10FFFF 4
string
- The string to determine the length of.@Deprecated public StringEncoderCache getCache()
StringEncoderCache
should be controlled
directly. This method will be removed after the 2.1.0
release.protected void fastEncode(String string, OutputStream out) throws IOException
string
- The string to encode.out
- The stream to write to.IOException
- On a failure to write the bytes.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.