Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mysql.jdbc
Class SingleByteCharsetConverter  view SingleByteCharsetConverter download SingleByteCharsetConverter.java

java.lang.Object
  extended bycom.mysql.jdbc.SingleByteCharsetConverter

public class SingleByteCharsetConverter
extends java.lang.Object

Converter for char[]->byte[] and byte[]->char[] for single-byte character sets. Much faster (5-6x) than the built-in solution that ships with the JVM, even with JDK-1.4.x and NewIo.


Field Summary
private static byte[] allBytes
           
private static int BYTE_RANGE
           
private  char[] byteToChars
           
private  byte[] charToByteMap
           
private static java.util.Map CONVERTER_MAP
           
private static byte[] EMPTY_BYTE_ARRAY
           
private static byte[] unknownCharsMap
           
 
Constructor Summary
private SingleByteCharsetConverter(java.lang.String encodingName)
          Prevent instantiation, called out of static method initCharset().
 
Method Summary
static SingleByteCharsetConverter getInstance(java.lang.String encodingName)
          Get a converter for the given encoding name
static SingleByteCharsetConverter initCharset(java.lang.String javaEncodingName)
          Initialize the shared instance of a converter for the given character encoding.
 byte[] toBytes(java.lang.String s)
          Convert the given string to an array of bytes.
 byte[] toBytes(java.lang.String s, int offset, int length)
          Convert the given string to an array of bytes.
 java.lang.String toString(byte[] buffer)
          Convert the byte buffer to a string using this instance's character encoding.
 java.lang.String toString(byte[] buffer, int startPos, int length)
          Convert the byte buffer from startPos to a length of length to a string using this instance's character encoding.
static java.lang.String toStringDefaultEncoding(byte[] buffer, int startPos, int length)
          Convert the byte buffer from startPos to a length of length to a string using the default platform encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

unknownCharsMap

private static byte[] unknownCharsMap

BYTE_RANGE

private static final int BYTE_RANGE
See Also:
Constant Field Values

CONVERTER_MAP

private static final java.util.Map CONVERTER_MAP

allBytes

private static byte[] allBytes

byteToChars

private char[] byteToChars

charToByteMap

private byte[] charToByteMap

EMPTY_BYTE_ARRAY

private static final byte[] EMPTY_BYTE_ARRAY
Constructor Detail

SingleByteCharsetConverter

private SingleByteCharsetConverter(java.lang.String encodingName)
                            throws java.io.UnsupportedEncodingException
Prevent instantiation, called out of static method initCharset().

Method Detail

getInstance

public static SingleByteCharsetConverter getInstance(java.lang.String encodingName)
                                              throws java.io.UnsupportedEncodingException
Get a converter for the given encoding name


initCharset

public static SingleByteCharsetConverter initCharset(java.lang.String javaEncodingName)
                                              throws java.io.UnsupportedEncodingException
Initialize the shared instance of a converter for the given character encoding.


toStringDefaultEncoding

public static java.lang.String toStringDefaultEncoding(byte[] buffer,
                                                       int startPos,
                                                       int length)
Convert the byte buffer from startPos to a length of length to a string using the default platform encoding.


toBytes

public final byte[] toBytes(java.lang.String s)
Convert the given string to an array of bytes.


toBytes

public final byte[] toBytes(java.lang.String s,
                            int offset,
                            int length)
Convert the given string to an array of bytes.


toString

public final java.lang.String toString(byte[] buffer)
Convert the byte buffer to a string using this instance's character encoding.


toString

public final java.lang.String toString(byte[] buffer,
                                       int startPos,
                                       int length)
Convert the byte buffer from startPos to a length of length to a string using this instance's character encoding.