Oracle JDBC API Reference
11g Release 2 ("11.2.0.3.0")

oracle.sql
Class CHAR

java.lang.Object
  extended by oracle.sql.Datum
      extended by oracle.sql.CHAR
All Implemented Interfaces:
java.io.Serializable

public class CHAR
extends Datum

The Oracle specific representation of characters. The class extends oracle.sql.Datum and interprets the bytes according to one of the Oracle supported character sets. Each object of type oracle.sql.CHAR contains an indication of what character set to use in interpreting the bytes so one class can be used for all the variations, such as National Character Set, Client, Database, etc.

For conversions that are not supported directly by CHAR (e.g. "best effort" conversions from String), if the programer wants a "best attempt" even when the conversion looses information, the "withReplacement" methods of oracle.sql.CharacterSet can be used directly.

See Also:
CharacterSet, Serialized Form

Field Summary
static java.lang.String BUILD_DATE
           
static CharacterSet DEFAULT_CHARSET
           
static boolean TRACE
           
 
Constructor Summary
CHAR(java.lang.Object obj, CharacterSet charSet)
          Construct a CHAR from an Object.
CHAR(java.lang.String str, CharacterSet charSet)
          Constructor for CHAR.
 
Method Summary
 java.io.InputStream asciiStreamValue()
          Convert to an ascii stream representation of the datum object
 java.math.BigDecimal bigDecimalValue()
          Convert this data object into a BigDecimal.
 java.io.InputStream binaryStreamValue()
          Convert to a binary stream representation of the datum object
 boolean booleanValue()
          Convert to a boolean representation of the datum object
 byte byteValue()
          Convert to a byte representation of the datum object
 java.io.Reader characterStreamValue()
          Convert to a character stream representation of the datum object
 java.sql.Date dateValue()
          Convert to a Date representation of the datum object
 double doubleValue()
          Convert to a double representation of the datum object
 float floatValue()
          Convert to a float representation of the datum object
 java.lang.String getString()
          Converts the sequence of characters represented by this to a String.
 int intValue()
          Convert to a integer representation of the datum object
 boolean isConvertibleTo(java.lang.Class jClass)
          Test whether this data object can be converted to the specified Java data type.
 long longValue()
          Convert to a long representation of the datum object
 int oracleId()
          The integer that identifies the character set.
 java.lang.String stringValue()
          Convert this data object into a String.
 java.sql.Timestamp timestampValue()
          Convert to a Timestamp representation of the datum object
 java.sql.Time timeValue()
          Convert to a Time representation of the datum object
 java.lang.Object toJdbc()
          Convert this data object into its default Java object type.
 java.lang.String toString()
          Converts the characters to a String.
 
Methods inherited from class oracle.sql.Datum
getBytes, getLength, getStream, setBytes, setShareBytes, shareBytes, stringValue, timestampValue, timeValue
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CHARSET

public static final CharacterSet DEFAULT_CHARSET

BUILD_DATE

public static final java.lang.String BUILD_DATE
See Also:
Constant Field Values

TRACE

public static final boolean TRACE
See Also:
Constant Field Values
Constructor Detail

CHAR

public CHAR(java.lang.String str,
            CharacterSet charSet)
     throws java.sql.SQLException
Constructor for CHAR.
The String is first converted to the indicated character set. No provision is made for loss if the CharacterSet cannot represent all Unicode characters. Although perhaps some time in the future it may throw an exception in that case.

Parameters:
str - the sequence of characters (represented in Unicode).
charSet - the CharacterSet to which the string should be converted.

if charSet is null, default charset will be used. The default charset choose we8iso8859p1 as Oracle Utiliites charset.

Throws:
java.sql.SQLException - if the attempt to convert str to charSet throws an exception.

CHAR

public CHAR(java.lang.Object obj,
            CharacterSet charSet)
     throws java.sql.SQLException
Construct a CHAR from an Object.

Parameters:
obj - input data from which this class instance is constructed. This constructor calls obj.toString() to obtain the input string.
charSet - character set of the CHAR to be created.
Throws:
java.sql.SQLException - if the input argument 'obj' is an instance of an unsupported class, or if the input object cannot be converted into a CHAR.
Method Detail

oracleId

public int oracleId()
The integer that identifies the character set.

Returns:
Oracle character set ID

getString

public java.lang.String getString()
                           throws java.sql.SQLException
Converts the sequence of characters represented by this to a String.

Returns:
a String containing the Unicode characters represented in this.
Throws:
java.sql.SQLException - if conversion from this.oracleId to UTF is not supported
java.sql.SQLException - if the particular cannot characters cannot be converted without loss to Unicode.

toString

public java.lang.String toString()
Converts the characters to a String. Attempts to use getString, but if that throws an exception presents a hex representation of the individual bytes.

Overrides:
toString in class java.lang.Object

toJdbc

public java.lang.Object toJdbc()
                        throws java.sql.SQLException
Convert this data object into its default Java object type.

Specified by:
toJdbc in class Datum
Returns:
the data value as a (fill in the blank) object.
Throws:
java.sql.SQLException - if any of the lower layer code throws an exception.

isConvertibleTo

public boolean isConvertibleTo(java.lang.Class jClass)
Test whether this data object can be converted to the specified Java data type.

Specified by:
isConvertibleTo in class Datum
Parameters:
jClass - specifies the Java data type to test against.
Returns:
true if this data object is convertible to the specified Java class, and a corresponding xxxValue() method is available; otherwise, a false is returned.

stringValue

public java.lang.String stringValue()
Convert this data object into a String.

Overrides:
stringValue in class Datum
Returns:
the data value in String representation.

booleanValue

public boolean booleanValue()
                     throws java.sql.SQLException
Convert to a boolean representation of the datum object

Overrides:
booleanValue in class Datum
Returns:
boolean representation of the datum object
Throws:
SQLException, - if no boolean representation exists
java.sql.SQLException

intValue

public int intValue()
             throws java.sql.SQLException
Convert to a integer representation of the datum object

Overrides:
intValue in class Datum
Returns:
integer representation of the datum object
Throws:
SQLException, - if no integer representation exists
java.sql.SQLException

longValue

public long longValue()
               throws java.sql.SQLException
Convert to a long representation of the datum object

Overrides:
longValue in class Datum
Returns:
long representation of the datum object
Throws:
SQLException, - if no long representation exists
java.sql.SQLException

floatValue

public float floatValue()
                 throws java.sql.SQLException
Convert to a float representation of the datum object

Overrides:
floatValue in class Datum
Returns:
float representation of the datum object
Throws:
SQLException, - if no float representation exists
java.sql.SQLException

doubleValue

public double doubleValue()
                   throws java.sql.SQLException
Convert to a double representation of the datum object

Overrides:
doubleValue in class Datum
Returns:
double representation of the datum object
Throws:
SQLException, - if no double representation exists
java.sql.SQLException

byteValue

public byte byteValue()
               throws java.sql.SQLException
Convert to a byte representation of the datum object

Overrides:
byteValue in class Datum
Returns:
byte representation of the datum object
Throws:
SQLException, - if no byte representation exists
java.sql.SQLException

dateValue

public java.sql.Date dateValue()
                        throws java.sql.SQLException
Convert to a Date representation of the datum object

Overrides:
dateValue in class Datum
Returns:
java.sql.Date representation of the datum object
Throws:
SQLException, - if no Date representation exists
java.sql.SQLException

timeValue

public java.sql.Time timeValue()
                        throws java.sql.SQLException
Convert to a Time representation of the datum object

Overrides:
timeValue in class Datum
Returns:
java.sql.Time representation of the datum object
Throws:
SQLException, - if no Time representation exists
java.sql.SQLException

timestampValue

public java.sql.Timestamp timestampValue()
                                  throws java.sql.SQLException
Convert to a Timestamp representation of the datum object

Overrides:
timestampValue in class Datum
Returns:
java.sql.Timestamp representation of the datum object
Throws:
SQLException, - if no Timestamp representation exists
java.sql.SQLException

bigDecimalValue

public java.math.BigDecimal bigDecimalValue()
                                     throws java.sql.SQLException
Convert this data object into a BigDecimal.

Overrides:
bigDecimalValue in class Datum
Returns:
the data value in BigDecimal representation.
Throws:
java.sql.SQLException

characterStreamValue

public java.io.Reader characterStreamValue()
                                    throws java.sql.SQLException
Convert to a character stream representation of the datum object

Overrides:
characterStreamValue in class Datum
Returns:
character stream representation of the datum object
Throws:
SQLException, - if no character stream representation exists
java.sql.SQLException

asciiStreamValue

public java.io.InputStream asciiStreamValue()
                                     throws java.sql.SQLException
Convert to an ascii stream representation of the datum object

Overrides:
asciiStreamValue in class Datum
Returns:
ascii stream representation of the datum object
Throws:
SQLException, - if no ascii stream representation exists
java.sql.SQLException

binaryStreamValue

public java.io.InputStream binaryStreamValue()
                                      throws java.sql.SQLException
Convert to a binary stream representation of the datum object

Overrides:
binaryStreamValue in class Datum
Returns:
binary stream representation of the datum object
Throws:
SQLException, - if no binary stream representation exists
java.sql.SQLException

Oracle JDBC API Reference
11g Release 2 ("11.2.0.3.0")

Copyright © 1998, 2007, Oracle. All rights reserved.