com.informix.lang

Class Interval

  • java.lang.Object
    • com.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

      Fields 
      Modifier and Type Field and Description
      protected static int DAY_IDX 
      protected static int DECSIZE 
      protected static char[] dtdelim 
      protected static int FRAC_IDX 
      protected static int HOUR_IDX 
      protected short int_qual 
      protected static int MIN_IDX 
      protected static int MONTH_IDX 
      protected static int NUMBER_UNITS 
      protected static int SEC_IDX 
      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.
      protected static int YEAR_IDX 
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected Interval()
      Default Constructor with no arguments
      protected Interval(java.sql.Connection conn)
      Default Constructor with connection argument, used to set current locale
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj) 
      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.
      protected byte getFirstLength(short qual)
      Calculates the length of the first field of a qualifier.
      static java.lang.String getIfxTypeName(int type, short qual)
      Returns, in string form, the entire name of the Interval or DATETIME from the qualifier.
      protected byte getLength()
      Retrieves the length portion of the internal qualifier.
      static byte getLength(short qualifier)
      Extracts the length from a qualifier.
      short getQualifier()
      Returns the qualifier for this Interval object.
      protected short getQualifier(byte startCode, byte endCode)
      Composes the DATETIME qualifier from the start code and end code.
      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.
      int hashCode() 
      void setConnection(java.sql.Connection conn)
      Sets the connection.
      protected int[] stringToUnits(java.lang.String str, short qual)
      Converts a string to an array of integers.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, 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
      • dtdelim

        protected static final char[] dtdelim
      • int_qual

        protected short int_qual
    • Constructor Detail

      • Interval

        protected Interval()
                    throws java.sql.SQLException
        Default Constructor with no arguments
        Throws:
        java.sql.SQLException
      • Interval

        protected Interval(java.sql.Connection conn)
        Default Constructor with connection argument, used to set current locale
        Parameters:
        conn - Current connection
        Throws:
        java.sql.SQLException
    • 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.
      • getLength

        protected byte getLength()
        Retrieves the length portion of the internal qualifier.
        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
      • getQualifier

        protected short getQualifier(byte startCode,
                                     byte endCode)
                              throws java.sql.SQLException
        Composes the DATETIME qualifier from the start code and end code.
        Parameters:
        startCode - The starting time unit field (TU_XXX).
        endCode - The ending time unit field (TU_XXX).
        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.
      • getFirstLength

        protected byte getFirstLength(short qual)
        Calculates the length of the first field of a qualifier.
        Parameters:
        qual - The qualifier.
        Returns:
        The length of the first field.
      • 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
      • stringToUnits

        protected int[] stringToUnits(java.lang.String str,
                                      short qual)
                               throws java.sql.SQLException
        Converts a string to an array of integers. Each entry in the array holds a different unit of time.
        Parameters:
        str - The string to be converted.
        qual - The qualifier used for the conversion.
        Returns:
        The array of integers.
        Throws:
        java.sql.SQLException
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object