Class Point
java.lang.Object
org.postgresql.pljava.example.annotation.Point
- All Implemented Interfaces:
SQLData
@SQLAction(requires={"point mirror type","point assertHasValues"},
install="SELECT javatest.assertHasValues(CAST(\'(1,2)\' AS point), 1, 2)")
@MappedUDT(name="point",
provides="point mirror type")
public class Point
extends Object
implements SQLData
Example of a "mirrored UDT": a user-defined type that exposes to Java the
internal representation of an existing (but not SQL-standard) PostgreSQL
type. Naturally, the author of this type has to know (from the PostgreSQL
source) that a
Point
is stored as two float8
s, x
first and then y
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertHasValues
(Point pt, double x, double y) Assert a 'point' has given x and y values, to test that its representation in Java corresponds to what PostgreSQL sees.static Point
logAndReturn
(Point pt) Return the same 'point' passed in, logging its contents at level INFO.void
toString()
void
-
Constructor Details
-
Point
public Point()
-
-
Method Details
-
logAndReturn
@Function(schema="javatest", requires="point mirror type", effects=IMMUTABLE, onNullInput=RETURNS_NULL) public static Point logAndReturn(Point pt) Return the same 'point' passed in, logging its contents at level INFO.- Parameters:
pt
- any instance of the type this UDT mirrors- Returns:
- the same instance passed in
-
assertHasValues
@Function(schema="javatest", requires="point mirror type", provides="point assertHasValues", effects=IMMUTABLE, onNullInput=RETURNS_NULL) public static void assertHasValues(Point pt, double x, double y) throws SQLException Assert a 'point' has given x and y values, to test that its representation in Java corresponds to what PostgreSQL sees.- Parameters:
pt
- an instance of this UDTx
- the x value it should havey
- the y value it should have- Throws:
SQLException
- if the values do not match
-
getSQLTypeName
- Specified by:
getSQLTypeName
in interfaceSQLData
-
readSQL
- Specified by:
readSQL
in interfaceSQLData
- Throws:
SQLException
-
writeSQL
- Specified by:
writeSQL
in interfaceSQLData
- Throws:
SQLException
-
toString
-