Package org.postgresql.pljava.adt
Interfaces in this package are meant to occupy a level between a PL/Java
Adapter
(responsible for PostgreSQL internal details that
properly remain encapsulated) and some intended Java representation class
(which may encapsulate details of its own).
Example
Suppose an application would like to manipulate
a PostgreSQL TIME WITH TIME ZONE
in the form of a Java
OffsetTime
instance.
The application selects a PL/Java Adapter
that handles the
PostgreSQL TIME WITH TIME ZONE
type and presents it via the
functional interface Datetime.TimeTZ
in this package.
The application can instantiate that Adapter
with some implementation
(possibly just a lambda) of that functional interface, which will construct
an OffsetTime
instance. That Adapter
instance now maps
TIME WITH TIME ZONE
to OffsetTime
, as desired.
The PostgreSQL internal details are handled by the Adapter
. The
internal details of OffsetTime
are OffsetTime
's business.
In between those two sits the Datetime.TimeTZ
interface in this package, with its one simple role: it presents the value
in a clear, documented form as consisting of:
- microseconds since midnight, and
- a time zone offset in seconds west of the prime meridian
It serves as a contract for the Adapter
and as a clear starting point
for constructing the wanted Java representation.
It is important that the interfaces here serve as documentation as
well as code, as it turns out that OffsetTime
expects its
time zone offsets to be positive east of the prime meridian,
so a sign flip is needed. Interfaces in this package must be
documented with enough detail to allow a developer to make correct
use of the exposed values.
The division of labor between what is exposed in these interfaces and what
is encapsulated within Adapter
s calls for a judgment of which
details are semantically significant. If PostgreSQL somehow changes the
internal details needed to retrieve a timetz
value, it should be the
Adapter
's job to make that transparent. If PostgreSQL ever changes
the fact that a timetz
is microseconds since midnight with
seconds-west as a zone offset, that would require versioning the
corresponding interface here; it is something a developer would need to know.
Reference implementations
A few simple reference implementations (including thetimetz
-as-OffsetTime
used as the example) can also be found
in this package, and Adapter
instances using them are available,
so an application would not really have to follow the steps of the example
to obtain one.- Author:
- Chapman Flack
-
ClassDescriptionContainer for functional interfaces presenting a PostgreSQL array.A contract whereby an array is returned flattened into a Java list, with no attention to its specified dimensionality or index bounds.Container for abstract-type functional interfaces in PostgreSQL's
BITSTRING
type category.TheBIT
andVARBIT
types' PostgreSQL semantics: the number of bits, and the sequence of bytes they're packed into.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.Container for abstract-type functional interfaces in PostgreSQL'sDATETIME
type category.TheDATE
type's PostgreSQL semantics: a signed number of days since the "Postgres epoch".A reference implementation that maps toLocalDate
.TheTIME
type's PostgreSQL semantics: microseconds since midnight.A reference implementation that maps toLocalTime
.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.TheTIMESTAMP
type's PostgreSQL semantics: microseconds since midnight of the PostgreSQL epoch, without an assumed time zone.A reference implementation that maps toLocalDateTime
.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.TheTIMESTAMPTZ
type's PostgreSQL semantics: microseconds since midnight UTC of the PostgreSQL epoch.A reference implementation that maps toOffsetDateTime
.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.TheTIMETZ
type's PostgreSQL semantics: microseconds since midnight, accompanied by a time zone offset expressed in seconds.A reference implementation that maps toOffsetTime
.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.Container for abstract-type functional interfaces in PostgreSQL'sGEOMETRIC
type category.Geometric.Box<T,I> TheBOX
type's PostgreSQL semantics: two corner points.Geometric.Circle<T,I> TheCIRCLE
type's PostgreSQL semantics: center point and radius.TheLINE
type's PostgreSQL semantics: coefficients of its general equation Ax+By+C=0.Geometric.LSeg<T,I> TheLSEG
type's PostgreSQL semantics: two endpoints.Geometric.Path<T,I> ThePATH
type's PostgreSQL semantics: vertex points and whether closed.ThePOINT
type's PostgreSQL semantics: a pair offloat8
coordinates.Geometric.Polygon<T,I1, I2> ThePOLYGON
type's PostgreSQL semantics: vertex points and a bounding box.Container for abstract-type functional interfaces, not quite exactly corresponding to PostgreSQL'sINTERNAL
category; there are some fairly "internal" types that ended up in theUSER
category too, for whatever reason.Internal.Tid<T>Thetid
type's PostgreSQL semantics: a block ID and a row index within that block.Money<T>TheMONEY
type's PostgreSQL semantics: an integer value, whose scaling, display format, and currency are all determined by a user-settable configuration setting.Container for abstract-type functional interfaces in PostgreSQL'sNETWORK
type category (and MAC addresses, which, for arcane reasons, are not in that category).Network.Inet<T>TheINET
andCIDR
types' PostgreSQL semantics: the family (INET
orINET6
), the number of network prefix bits, and the address bytes in network byte order.Network.MAC<T>Themacaddr
andmacaddr8
types' PostgreSQL semantics: a byte array (6 or 8 bytes, respectively)., of which byte 0 is the one appearing first in the text representation (and stored in the member named a of the C struct).Numeric<T>TheNUMERIC
type's PostgreSQL semantics: a sign (or indication that the value is NaN, + infinity, or - infinity), a display scale, a weight, and zero or more base-ten-thousand digits.A reference implementation that maps toBigDecimal
(but cannot represent all possible values).Label to distinguish positive, negative, and three kinds of special values.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.Container for abstract-type functional interfaces in PostgreSQL'sTIMESPAN
type category (which, at present, includes the single typeINTERVAL
).TheINTERVAL
type's PostgreSQL semantics: separate microseconds, days, and months components, independently signed.Functional interface to obtain information from the PostgreSQL type modifier applied to the type.