com.informix.lang
Class Interval

java.lang.Object
  extended bycom.informix.lang.Interval
Direct Known Subclasses:
IntervalDF, IntervalYM

public abstract class Interval
extends java.lang.Object

This is the base class for the Informix data type INTERVAL. This is an Informix-specific JDBC extension. Interval qualifiers and some common methods for the IntervalYM and IntervalDF classes are in this class. Qualifier start code and end code indicators are also defined in this class.


Field Summary
static byte TU_DAY
          The time unit for the DAY field in a binary qualifier.
static byte TU_F1
          The time unit for the FRACTION(1) field in a binary qualifier.
static byte TU_F2
          The time unit for the FRACTION(2) field in a binary qualifier.
static byte TU_F3
          The time unit for the FRACTION(3) field in a binary qualifier.
static byte TU_F4
          The time unit for the FRACTION(4) field in a binary qualifier.
static byte TU_F5
          The time unit for the FRACTION(5) field in a binary qualifier.
static byte TU_FRAC
          The time unit for the default FRACTION field in a binary qualifier.
static byte TU_HOUR
          The time unit for the HOUR field in a binary qualifier.
static byte TU_MINUTE
          The time unit for the MINUTE field in a binary qualifier.
static byte TU_MONTH
          The time unit for the MONTH field in a binary qualifier.
static byte TU_SECOND
          The time unit for the SECOND field in a binary qualifier.
static byte TU_YEAR
          The time unit for the YEAR field in a binary qualifier.
 
Method Summary
 byte getEndCode()
          Gets the end code from the internal qualifier.
static byte getEndCode(short qualifier)
          Extracts the ending field code from a qualifier.
static java.lang.String getFieldName(byte code)
          A static method that takes the TU_XXX value of part of a DATETIME or Interval data type and returns the string value.
static java.lang.String getIfxTypeName(int type, short qual)
          Returns, in string form, the entire name of the Interval or DATETIME from the qualifier.
static byte getLength(short qualifier)
          Extracts the length from a qualifier.
 short getQualifier()
          Returns the qualifier for this Interval object.
static short getQualifier(byte len, byte startCode, byte endCode)
          Composes the Interval qualifier from the length, start code, and end code.
static byte getScale(short qualifier)
          Returns the number of digits in the FRACTION part of the Interval datatype.
 byte getStartCode()
          Gets the start code from the internal qualifier.
static byte getStartCode(short qualifier)
          Extracts the start code of the qualifier.
static byte getStaticEndCode(short qualifier)
          A static method, similar to getEndCode, that returns the ending type of an interval (for example, the 'second' part of 'year to second'.
static byte getStaticStartCode(short qualifier)
          A static method, similar to getStartCode, that returns the starting type of an interval (for example, the 'year' part of 'year to second'.
static void goodQualifier(byte length, byte startCode, byte endCode)
          Verifies the length, startCode, and endCode values of the Interval qualifier.
 void setConnection(java.sql.Connection conn)
          Sets the connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TU_YEAR

public static final byte TU_YEAR
The time unit for the YEAR field in a binary qualifier.

See Also:
Constant Field Values

TU_MONTH

public static final byte TU_MONTH
The time unit for the MONTH field in a binary qualifier.

See Also:
Constant Field Values

TU_DAY

public static final byte TU_DAY
The time unit for the DAY field in a binary qualifier.

See Also:
Constant Field Values

TU_HOUR

public static final byte TU_HOUR
The time unit for the HOUR field in a binary qualifier.

See Also:
Constant Field Values

TU_MINUTE

public static final byte TU_MINUTE
The time unit for the MINUTE field in a binary qualifier.

See Also:
Constant Field Values

TU_SECOND

public static final byte TU_SECOND
The time unit for the SECOND field in a binary qualifier.

See Also:
Constant Field Values

TU_FRAC

public static final byte TU_FRAC
The time unit for the default FRACTION field in a binary qualifier. The same as TU_F2.

See Also:
Constant Field Values

TU_F1

public static final byte TU_F1
The time unit for the FRACTION(1) field in a binary qualifier. The fraction scale is equal to 1.

See Also:
Constant Field Values

TU_F2

public static final byte TU_F2
The time unit for the FRACTION(2) field in a binary qualifier. The fraction scale is equal to 2.

See Also:
Constant Field Values

TU_F3

public static final byte TU_F3
The time unit for the FRACTION(3) field in a binary qualifier. The fraction scale is equal to 3.

See Also:
Constant Field Values

TU_F4

public static final byte TU_F4
The time unit for the FRACTION(4) field in a binary qualifier. The fraction scale is equal to 4.

See Also:
Constant Field Values

TU_F5

public static final byte TU_F5
The time unit for the FRACTION(5) field in a binary qualifier. The fraction scale is equal to 5.

See Also:
Constant Field Values
Method Detail

getLength

public static byte getLength(short qualifier)
Extracts the length from a qualifier.

Parameters:
qualifier - The qualifier from which the length is extracted.
Returns:
The extracted qualifier length.

getQualifier

public short getQualifier()
Returns the qualifier for this Interval object.

Returns:
The Interval qualifier.

getQualifier

public static short getQualifier(byte len,
                                 byte startCode,
                                 byte endCode)
                          throws java.sql.SQLException
Composes the Interval qualifier from the length, start code, and end code.

Parameters:
len - The leading field length.
startCode - The starting time unit field (TU_XXX).
endCode - The ending time unit field (TU_XXX).
Returns:
The composed qualifier.
Throws:
java.sql.SQLException

goodQualifier

public static void goodQualifier(byte length,
                                 byte startCode,
                                 byte endCode)
                          throws java.sql.SQLException
Verifies the length, startCode, and endCode values of the Interval qualifier.

Parameters:
length - The leading field precision.
startCode - The starting time unit field (TU_XXX).
endCode - The ending time unit field (TU_XXX).
Throws:
java.sql.SQLException

getScale

public static byte getScale(short qualifier)
Returns the number of digits in the FRACTION part of the Interval datatype.

Parameters:
qualifier - The qualifier from which the scale is extracted.
Returns:
The scale, which is non-zero only for an end code of fractions.

getStartCode

public static byte getStartCode(short qualifier)
Extracts the start code of the qualifier.

Parameters:
qualifier - The qualifier.
Returns:
The start code for the interval or datetime field.

getEndCode

public static byte getEndCode(short qualifier)
Extracts the ending field code from a qualifier.

Parameters:
qualifier - The qualifier.
Returns:
The end code which has been extracted.

getStartCode

public byte getStartCode()
Gets the start code from the internal qualifier.

Returns:
The start code from the internal qualifier.

getEndCode

public byte getEndCode()
Gets the end code from the internal qualifier.

Returns:
The end code from the internal qualifier.

getStaticStartCode

public static byte getStaticStartCode(short qualifier)
A static method, similar to getStartCode, that returns the starting type of an interval (for example, the 'year' part of 'year to second'. Returns the time unit value (TU_XXX).

Parameters:
qualifier - The datetime or interval qualifier.
Returns:
The TU_ XXX time unit value.

getStaticEndCode

public static byte getStaticEndCode(short qualifier)
A static method, similar to getEndCode, that returns the ending type of an interval (for example, the 'second' part of 'year to second'. Returns the time unit value (TU_XXX).

Parameters:
qualifier - The datetime or interval qualifier.
Returns:
The TU_ XXX time unit value.

getFieldName

public static java.lang.String getFieldName(byte code)
A static method that takes the TU_XXX value of part of a DATETIME or Interval data type and returns the string value. For example, TU_YEAR returns 'year'.

Parameters:
code - The time unit (TU_XXX) value.
Returns:
The string value of the TU_XXX value.

getIfxTypeName

public static java.lang.String getIfxTypeName(int type,
                                              short qual)
Returns, in string form, the entire name of the Interval or DATETIME from the qualifier. Calls the getStartName() and getEndTypeName() methods to construct the string.

Parameters:
type - Indicates whether the type is interval or datetime.
qual - The qualifier.
Returns:
entire name of the interval or datetime in string form

setConnection

public void setConnection(java.sql.Connection conn)
Sets the connection. This allows localized error messages if an exception is thrown.

Parameters:
conn - The connection object