|
Oracle10g JDBC | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.jdbc.driver.DBConversion
Database conversion class.
This class holds information about the character sets used by the driver and the database server. It provides the necessary conversion rountines to convert between Java Strings and character bytes passed via the driver.
The character set used at the driver is determined by the low-layer driver. This class handles these character sets: UCS2, ASCII, ISO_LATIN_1, AL24UTFFSS,UTF8 and AL32UTF8.
Since both AL24UTFFSS and UTF8 use the same UTF8 encoding scheme, the two character sets are handled the same way in this class.
CharacterSet
Field Summary | |
static short |
AL16UTF16_CHARSET
|
static short |
AL24UTFFSS_CHARSET
|
static short |
AL32UTF8_CHARSET
|
static short |
ASCII_CHARSET
|
static java.lang.String |
BUILD_DATE
|
static short |
DBCS_CHARSET
|
static boolean |
DO_CONVERSION_WITH_REPLACEMENT
|
static short |
ISO_LATIN_1_CHARSET
|
static short |
ORACLE8_PROD_VERSION
|
static boolean |
PRIVATE_TRACE
|
static boolean |
TRACE
|
static short |
UCS2_CHARSET
|
static short |
UTF8_CHARSET
|
Constructor Summary | |
DBConversion(short svrCharSet,
short driverCharSet,
short svrNCharSet)
Constructor method. |
Method Summary | |
int |
_getMaxCharbyteSize(short cs)
|
byte[] |
asciiBytesToCHARBytes(byte[] bytes)
Convert an Ascii byte array into a Driver byte array. |
static int |
asciiBytesToJavaChars(byte[] bytes,
int nbytes,
char[] chars)
Convert 8-bit ascii character bytes into a Java char array. |
int |
CHARBytesToJavaChars(byte[] bytes,
int byteOffset,
char[] chars,
int charOffset,
int[] nbytes,
int charSize)
|
java.lang.String |
CharBytesToString(byte[] bytes,
int nbytes)
Convert driver character bytes to a string. |
java.io.InputStream |
CharsToStream(char[] javachars,
int offset,
int len,
int conversion)
|
java.io.Reader |
ConvertCharacterStream(java.io.InputStream stream,
int conversion)
|
java.io.Reader |
ConvertCharacterStream(java.io.InputStream stream,
int conversion,
short form_of_use)
|
java.io.InputStream |
ConvertStream(java.io.InputStream stream,
int conversion)
|
java.io.InputStream |
ConvertStream(java.io.InputStream stream,
int conversion,
int max_bytes)
|
java.io.InputStream |
ConvertStream(java.io.Reader stream,
int conversion,
int max_chars,
short form_of_use)
|
static short |
findDriverCharSet(short svrCharSet,
short oraVersion)
Find the appropriate driver character set to use. |
short |
getDbCharSet()
Obtain the database character set id. |
CharacterSet |
getDbCharSetObj()
Obtain the database character set object. |
short |
getDriverCharSet()
Obtain the id of the character set used in the driver. |
CharacterSet |
getDriverCharSetObj()
Obtain the Driver character set object. |
CharacterSet |
getDriverNCharSetObj()
|
int |
getMaxCharbyteSize()
|
int |
getMaxNCharbyteSize()
|
short |
getNCharSet()
Obtain the database national character set id. |
static int |
getUtfLen(char c)
Return the UTF8 representation length for the given Java character. |
static boolean |
isCharSetMultibyte(short charSet)
Check if a character set is mutlibyte. |
boolean |
IsNCharFixedWith()
|
boolean |
isUcs2CharSet()
|
static int |
javaCharsToAsciiBytes(char[] chars,
int nchars,
byte[] bytes)
Convert Java char array into an ascii byte array. |
int |
javaCharsToCHARBytes(char[] chars,
int nchars,
byte[] bytes)
|
int |
javaCharsToCHARBytes(char[] chars,
int charOffset,
byte[] bytes,
int byteOffset,
int nchars)
|
int |
javaCharsToDbCsBytes(char[] chars,
int nchars,
byte[] bytes)
Convert a Java character array into a byte array in database character set. |
int |
javaCharsToDbCsBytes(char[] chars,
int charOffset,
byte[] bytes,
int byteOffset,
int nchars)
Convert a Java character array into a byte array in database character set. |
int |
javaCharsToNCHARBytes(char[] chars,
int nchars,
byte[] bytes)
|
int |
javaCharsToNCHARBytes(char[] chars,
int charOffset,
byte[] bytes,
int byteOffset,
int nchars)
|
static int |
javaCharsToUcs2Bytes(char[] chars,
int nchars,
byte[] bytes)
Convert a Java character array into a UCS-2 byte array. |
static int |
javaCharsToUcs2Bytes(char[] chars,
int charOffset,
byte[] bytes,
int byteOffset,
int nchars)
Convert a Java character array into a UCS-2 byte array. |
int |
NCHARBytesToJavaChars(byte[] bytes,
int byteOffset,
char[] chars,
int charOffset,
int[] nbytes,
int charSize)
Same as CHARBytesToJavaChars but the charset of the input byte is the National charset. |
java.lang.String |
NCharBytesToString(byte[] bytes,
int nbytes)
|
static int |
RAWBytesToHexChars(byte[] bytes,
int nbytes,
char[] chars)
|
static byte[] |
stringToAsciiBytes(java.lang.String str)
Convert string into its Ascii byte array representation. |
byte[] |
StringToCharBytes(java.lang.String str)
Convert string into a byte array representing characters used at the driver. |
static byte[] |
stringToDriverCharBytes(java.lang.String str,
short charset)
Convert string into a byte array representing characters in one of the Driver character sets. |
static int |
ucs2BytesToJavaChars(byte[] bytes,
int nbytes,
char[] chars)
Convert a UCS-2 byte array into a Java character array. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DO_CONVERSION_WITH_REPLACEMENT
public static final short ORACLE8_PROD_VERSION
public static final short DBCS_CHARSET
public static final short UCS2_CHARSET
public static final short ASCII_CHARSET
public static final short ISO_LATIN_1_CHARSET
public static final short AL24UTFFSS_CHARSET
public static final short UTF8_CHARSET
public static final short AL32UTF8_CHARSET
public static final short AL16UTF16_CHARSET
public static final boolean TRACE
public static final boolean PRIVATE_TRACE
public static final java.lang.String BUILD_DATE
Constructor Detail |
public DBConversion(short svrCharSet, short driverCharSet, short svrNCharSet) throws java.sql.SQLException
svrCharSet
- character set id of the character set used in the
database server. (Since the Oracle server supports a
large number of character sets, no check is performed
on this parameter.)driverCharSet
- character set id of the character set used in the
driver. These are the possible values:
UCS2_CHARSET, ASCII_CHARSET, ISO_LATIN_1_CHARSET,
AL24UTFFSS_CHARSET, UTF8_CHARSET.
java.sql.SQLException
- if driverCharSet is invalid.Method Detail |
public short getDbCharSet()
public short getNCharSet()
public boolean IsNCharFixedWith()
public short getDriverCharSet()
public CharacterSet getDbCharSetObj()
public CharacterSet getDriverCharSetObj()
public CharacterSet getDriverNCharSetObj()
public static final short findDriverCharSet(short svrCharSet, short oraVersion)
This static method is intended to be used by the Thin driver to find the appropriate driver character set to construct a DBConversion object.
svrCharSet
- character set id of the character set used in the
database server.oraVersion
- Oracle version.
public static final byte[] stringToDriverCharBytes(java.lang.String str, short charset) throws java.sql.SQLException
Note: DBCS_CHARSET is not supported by this function
str
- input string to be converted.charset
- character set id of the character set used in the
driver. These are the possible values:
UCS2_CHARSET, ASCII_CHARSET, ISO_LATIN_1_CHARSET,
AL24UTFFSS_CHARSET, UTF8_CHARSET, AL32UTF8_CHARSET.
java.sql.SQLException
- if charset is invalid.public byte[] StringToCharBytes(java.lang.String str) throws java.sql.SQLException
str
- input string to be converted.
java.sql.SQLException
- if a Jdbc internal error occurred.public java.lang.String CharBytesToString(byte[] bytes, int nbytes) throws java.sql.SQLException
bytes
- input character byte array.nbytes
- length of input character byte array to be converted.
java.sql.SQLException
- if errors occurred.public java.lang.String NCharBytesToString(byte[] bytes, int nbytes) throws java.sql.SQLException
java.sql.SQLException
public int javaCharsToCHARBytes(char[] chars, int nchars, byte[] bytes) throws java.sql.SQLException
java.sql.SQLException
public int javaCharsToCHARBytes(char[] chars, int charOffset, byte[] bytes, int byteOffset, int nchars) throws java.sql.SQLException
java.sql.SQLException
public int javaCharsToNCHARBytes(char[] chars, int nchars, byte[] bytes) throws java.sql.SQLException
java.sql.SQLException
public int javaCharsToNCHARBytes(char[] chars, int charOffset, byte[] bytes, int byteOffset, int nchars) throws java.sql.SQLException
java.sql.SQLException
public int CHARBytesToJavaChars(byte[] bytes, int byteOffset, char[] chars, int charOffset, int[] nbytes, int charSize) throws java.sql.SQLException
java.sql.SQLException
public int NCHARBytesToJavaChars(byte[] bytes, int byteOffset, char[] chars, int charOffset, int[] nbytes, int charSize) throws java.sql.SQLException
java.sql.SQLException
public byte[] asciiBytesToCHARBytes(byte[] bytes)
bytes
- input Ascii byte arary.
public int javaCharsToDbCsBytes(char[] chars, int nchars, byte[] bytes) throws java.sql.SQLException
chars
- input Java character array.bytes
- output byte array. (Buffer is allocated by the
calling routine.)
java.sql.SQLException
- if the input is invalid.public int javaCharsToDbCsBytes(char[] chars, int charOffset, byte[] bytes, int byteOffset, int nchars) throws java.sql.SQLException
chars
- input Java character array.charOffset
- offset in the char arraybytes
- output byte array. (Buffer is allocated by the
calling routine.)byteOffset
- offset in the byte arraynchars
- number of characters in chars[] to convert.
java.sql.SQLException
- if the input is invalid.public static final int javaCharsToUcs2Bytes(char[] chars, int nchars, byte[] bytes) throws java.sql.SQLException
chars
- input Java character array.nchars
- number of characters in chars[] to convert.bytes
- output byte array. (Buffer is allocated by the
calling routine.)
java.sql.SQLException
- if the input is invalid.public static final int javaCharsToUcs2Bytes(char[] chars, int charOffset, byte[] bytes, int byteOffset, int nchars) throws java.sql.SQLException
chars
- input Java character array.charOffset
- offset in the char arraybytes
- output byte array. (Buffer is allocated by the
calling routine.)byteOffset
- offset in the byte arraynchars
- number of characters in chars[] to convert.
java.sql.SQLException
- if the input is invalid.public static final int ucs2BytesToJavaChars(byte[] bytes, int nbytes, char[] chars) throws java.sql.SQLException
bytes
- input byte array.nbytes
- number of bytes in bytes[] to convert.chars
- input Java character array. (Buffer is allocated by
the calling routine.)
java.sql.SQLException
- if the input is invalid.public static final byte[] stringToAsciiBytes(java.lang.String str)
str
- input string to be converted.
public static final int asciiBytesToJavaChars(byte[] bytes, int nbytes, char[] chars) throws java.sql.SQLException
bytes
- input character bytes.nbytes
- number of bytes to be converted.chars
- output Java char array (buffer allocated by calling
rountine).
java.sql.SQLException
- if input is invalid.public static final int javaCharsToAsciiBytes(char[] chars, int nchars, byte[] bytes) throws java.sql.SQLException
chars
- input Java character array.nchars
- number of Java characters to be converted.bytes
- output ascii byte array (buffer allocated by calling
rountine).
java.sql.SQLException
- if the input is invalid.public static final boolean isCharSetMultibyte(short charSet)
charSet
- input character set identifier.
public int getMaxCharbyteSize()
public int getMaxNCharbyteSize()
public int _getMaxCharbyteSize(short cs)
public boolean isUcs2CharSet()
public static final int RAWBytesToHexChars(byte[] bytes, int nbytes, char[] chars)
public java.io.InputStream ConvertStream(java.io.InputStream stream, int conversion)
public java.io.InputStream ConvertStream(java.io.InputStream stream, int conversion, int max_bytes)
public java.io.InputStream ConvertStream(java.io.Reader stream, int conversion, int max_chars, short form_of_use)
public java.io.Reader ConvertCharacterStream(java.io.InputStream stream, int conversion) throws java.sql.SQLException
java.sql.SQLException
public java.io.Reader ConvertCharacterStream(java.io.InputStream stream, int conversion, short form_of_use) throws java.sql.SQLException
java.sql.SQLException
public java.io.InputStream CharsToStream(char[] javachars, int offset, int len, int conversion) throws java.sql.SQLException
java.sql.SQLException
public static final int getUtfLen(char c)
c
- is a Java character.
|
Oracle10g JDBC | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |