Class ComplexTuple
- java.lang.Object
-
- org.postgresql.pljava.example.annotation.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.
-
-
Constructor Summary
Constructors Constructor Description ComplexTuple()
-
Method Summary
Modifier and Type Method Description static void
assertHasValues(ComplexTuple cpl, double re, double im)
Assert a 'complextuple' has given re and im values, to test that its representation in Java corresponds to what PostgreSQL sees.String
getSQLTypeName()
static ComplexTuple
logAndReturn(ComplexTuple cpl)
Return the same 'complextuple' passed in, logging its contents at level INFO.void
readSQL(SQLInput stream, String typeName)
static void
setParameter()
Pass a 'complextuple' UDT as a parameter to a PreparedStatement that returns it, and verify that it makes the trip intact.void
writeSQL(SQLOutput stream)
-
-
-
Constructor Detail
-
ComplexTuple
public ComplexTuple()
-
-
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 UDTre
- the 'real' value it should haveim
- 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
-
getSQLTypeName
public String getSQLTypeName()
- Specified by:
getSQLTypeName
in interfaceSQLData
-
readSQL
public void readSQL(SQLInput stream, String typeName) throws SQLException
- Specified by:
readSQL
in interfaceSQLData
- Throws:
SQLException
-
writeSQL
public void writeSQL(SQLOutput stream) throws SQLException
- Specified by:
writeSQL
in interfaceSQLData
- Throws:
SQLException
-
-