Package net.sourceforge.jtds.jdbc
Class CharsetInfo
- java.lang.Object
-
- net.sourceforge.jtds.jdbc.CharsetInfo
-
public final class CharsetInfo extends java.lang.ObjectLoads and stores information about character sets. Static fields and methods are concerned with loading, storing and retrieval of all character set information, while non-static fields and methods describe a particular character set (Java charset name and whether it's a multi-byte charset).Note: Only one
CharsetInfoinstance exists per charset. This allows simple equality comparisons between instances retrieved with any of thegetmethods.- Version:
- $Id: CharsetInfo.java,v 1.5 2007-07-08 17:28:23 bheineman Exp $
- Author:
- Alin Sinpalean
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcharsetThe Java character set name.private static java.util.HashMapcharsetsServer charset to Java charset map.private static java.lang.StringCHARSETS_RESOURCE_NAMEName of theCharsets.propertiesresource.private static java.util.HashMaplcidToCharsetMapLocale id to Java charset map.private static CharsetInfo[]sortToCharsetMapSort order to Java charset map.private booleanwideCharsIndicates whether current charset is wide (ie multi-byte).
-
Constructor Summary
Constructors Constructor Description CharsetInfo(java.lang.String descriptor)Constructs aCharsetInfoobject from a character set descriptor of the form: charset preceded by a numeric value indicating whether it's a multibyte character set (>1) or not (1) and a vertical bar (|), eg "1|Cp1252" or "2|MS936".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.lang.StringgetCharset()Retrieves the charset name.static CharsetInfogetCharset(byte[] collation)Retrieves theCharsetInfoinstance asociated with the specified collation.static CharsetInfogetCharset(java.lang.String serverCharset)Retrieves theCharsetInfoinstance asociated with the specified server charset.static CharsetInfogetCharsetForLCID(int lcid)Retrieves theCharsetInfoinstance asociated with the specified LCID.static CharsetInfogetCharsetForSortOrder(int sortOrder)Retrieves theCharsetInfoinstance asociated with the specified sort order.inthashCode()booleanisWideChars()Retrieves whether the caracter set is wide (ie multi-byte).java.lang.StringtoString()
-
-
-
Field Detail
-
CHARSETS_RESOURCE_NAME
private static final java.lang.String CHARSETS_RESOURCE_NAME
Name of theCharsets.propertiesresource.- See Also:
- Constant Field Values
-
charsets
private static final java.util.HashMap charsets
Server charset to Java charset map.
-
lcidToCharsetMap
private static final java.util.HashMap lcidToCharsetMap
Locale id to Java charset map.
-
sortToCharsetMap
private static final CharsetInfo[] sortToCharsetMap
Sort order to Java charset map.
-
charset
private final java.lang.String charset
The Java character set name.
-
wideChars
private final boolean wideChars
Indicates whether current charset is wide (ie multi-byte).
-
-
Constructor Detail
-
CharsetInfo
public CharsetInfo(java.lang.String descriptor)
Constructs aCharsetInfoobject from a character set descriptor of the form: charset preceded by a numeric value indicating whether it's a multibyte character set (>1) or not (1) and a vertical bar (|), eg "1|Cp1252" or "2|MS936".- Parameters:
descriptor- the charset descriptor
-
-
Method Detail
-
getCharset
public static CharsetInfo getCharset(java.lang.String serverCharset)
Retrieves theCharsetInfoinstance asociated with the specified server charset.- Parameters:
serverCharset- the server-specific character set name- Returns:
- the associated
CharsetInfo
-
getCharsetForLCID
public static CharsetInfo getCharsetForLCID(int lcid)
Retrieves theCharsetInfoinstance asociated with the specified LCID.- Parameters:
lcid- the server LCID- Returns:
- the associated
CharsetInfo
-
getCharsetForSortOrder
public static CharsetInfo getCharsetForSortOrder(int sortOrder)
Retrieves theCharsetInfoinstance asociated with the specified sort order.- Parameters:
sortOrder- the server sort order- Returns:
- the associated
CharsetInfo
-
getCharset
public static CharsetInfo getCharset(byte[] collation) throws java.sql.SQLException
Retrieves theCharsetInfoinstance asociated with the specified collation.- Parameters:
collation- the server LCID- Returns:
- the associated
CharsetInfo - Throws:
java.sql.SQLException
-
getCharset
public java.lang.String getCharset()
Retrieves the charset name.
-
isWideChars
public boolean isWideChars()
Retrieves whether the caracter set is wide (ie multi-byte).
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-