Class ComplexTuple

  • All Implemented Interfaces:
    SQLData

    @SQLAction(requires={"complextuple assertHasValues","complextuple setParameter"},
               install={"SELECT javatest.assertHasValues( CAST(\'(1,2)\' AS javatest.complextuple), 1, 2)","SELECT javatest.setParameter()"})
    @MappedUDT(schema="javatest",
               name="complextuple",
               structure={"x float8","y float8"})
    public class ComplexTuple
    extends Object
    implements SQLData
    Complex (re and im parts are doubles) implemented in Java as a mapped UDT.
    • Method Detail

      • logAndReturn

        @Function(schema="javatest",
                  name="logcomplex",
                  effects=IMMUTABLE,
                  onNullInput=RETURNS_NULL)
        public static ComplexTuple logAndReturn​(ComplexTuple cpl)
        Return the same 'complextuple' passed in, logging its contents at level INFO.
        Parameters:
        cpl - any instance of this UDT
        Returns:
        the same instance passed in
      • assertHasValues

        @Function(schema="javatest",
                  provides="complextuple assertHasValues",
                  effects=IMMUTABLE,
                  onNullInput=RETURNS_NULL)
        public static void assertHasValues​(ComplexTuple cpl,
                                           double re,
                                           double im)
                                    throws SQLException
        Assert a 'complextuple' has given re and im values, to test that its representation in Java corresponds to what PostgreSQL sees.
        Parameters:
        cpl - an instance of this UDT
        re - the 'real' value it should have
        im - the 'imaginary' value it should have
        Throws:
        SQLException - if the values do not match
      • setParameter

        @Function(schema="javatest",
                  provides="complextuple setParameter",
                  effects=IMMUTABLE,
                  onNullInput=RETURNS_NULL)
        public static void setParameter()
                                 throws SQLException
        Pass a 'complextuple' UDT as a parameter to a PreparedStatement that returns it, and verify that it makes the trip intact.
        Throws:
        SQLException