Class AbstractType.MultiArray

java.lang.Object
org.postgresql.pljava.adt.spi.AbstractType.MultiArray
Enclosing class:
AbstractType

public static class AbstractType.MultiArray extends Object
A class dedicated to manipulating the types of multidimensional Java arrays, and their instances, that conform to PostgreSQL array constraints (non-'jagged', each dimension's arrays all equal size, no intermediate nulls).

Construct a MultiArray by supplying a component Type and a number of dimensions. The resulting MultiArray represents the Java array type, and has a number of bracket pairs equal to the supplied dimensions argument plus those of the component type if it is itself a Java array. (There could be an Adapter for some PostgreSQL scalar type that presents it as a Java array, and then there could be a PostgreSQL array of that type.) So the type reported by arrayType may have more bracket pairs than the MultiArray's dimensions. Parentheses are used by toString to help see what's going on.

When converting a MultiArray to a Sized, only as many sizes are supplied as the multiarray's dimensions, and when converting that to an Allocated, only that much allocation is done. Populating the arrays at that last allocated level with the converted elements of the PostgreSQL array is the work left for the caller.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Represents a MultiArray for which sizes for its dimensions have been specified, so that an instance can be allocated.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Type
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiArray(Type component, int dimensions)
    Constructs a description of a multiarray with a given component type and dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the resulting Java array type (which, if the component type is also an array, does not distinguish between its dimensions and those of this multiarray).
    Returns this MultiArray as a 'prefix' of suffix (which must have the same ultimate non-array type but a smaller number of dimensions).
    Returns a new MultiArray with the same Java array type but where component is a non-array type and dimensions holds the total number of dimensions.
    Returns a MultiArray representing an array type t in a canonical form, with its ultimate non-array type as the component type, and all of its array dimensions belonging to the multiarray.
    refine(Type model)
    Returns a new MultiArray with this one's type (possibly a raw, or parameterized type) refined according to the known type of model.
    size(int... dims)
    Returns a Sized representing this MultiArray with a size for each of its dimensions.
    Returns a representation of the resulting Java array type, with parentheses around the component type (which may itself be an array type) and around the array brackets corresponding to this multiarray's dimensions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • component

      public final Type component
    • dimensions

      public final int dimensions
  • Constructor Details

    • MultiArray

      public MultiArray(Type component, int dimensions)
      Constructs a description of a multiarray with a given component type and dimensions.
      Parameters:
      component - the type of the component (which may itself be an array)
      dimensions - dimensions of the multiarray (if the component type is an array, the final resulting type will have the sum of its dimensions and these)
  • Method Details

    • toString

      public String toString()
      Returns a representation of the resulting Java array type, with parentheses around the component type (which may itself be an array type) and around the array brackets corresponding to this multiarray's dimensions.
      Overrides:
      toString in class Object
    • arrayType

      public Type arrayType()
      Returns the resulting Java array type (which, if the component type is also an array, does not distinguish between its dimensions and those of this multiarray).
    • canonicalize

      public static AbstractType.MultiArray canonicalize(Type t)
      Returns a MultiArray representing an array type t in a canonical form, with its ultimate non-array type as the component type, and all of its array dimensions belonging to the multiarray.
    • canonicalize

      public AbstractType.MultiArray canonicalize()
      Returns a new MultiArray with the same Java array type but where component is a non-array type and dimensions holds the total number of dimensions.
    • asPrefixOf

      Returns this MultiArray as a 'prefix' of suffix (which must have the same ultimate non-array type but a smaller number of dimensions).

      The result will have the array type of suffix as its component type, and the dimensions required to have the same overall Java arrayType as the receiver.

    • refine

      public AbstractType.MultiArray refine(Type model)
      Returns a new MultiArray with this one's type (possibly a raw, or parameterized type) refined according to the known type of model.
    • size

      public AbstractType.MultiArray.Sized size(int... dims)
      Returns a Sized representing this MultiArray with a size for each of its dimensions.