Class CompositeParameterList

java.lang.Object
org.postgresql.core.v3.CompositeParameterList
All Implemented Interfaces:
ParameterList, V3ParameterList

class CompositeParameterList extends Object implements V3ParameterList
Parameter list for V3 query strings that contain multiple statements. We delegate to one SimpleParameterList per statement, and translate parameter indexes as needed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int[]
     
    private final SimpleParameterList[]
     
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CompositeParameterList(SimpleParameterList[] subparams, int[] offsets)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Use this operation to append more parameters to the current list.
    void
    Ensure that all parameters in this list have been assigned values.
    void
    Unbind all parameter values bound in this list.
    void
    Convert any function output parameters to the correct type (void) and set an ignorable value for it.
    Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query).
    private int
    findSubParam(int index)
     
    int
    getDirection(int i)
     
    byte[][]
    Return the encoding for each parameter.
    byte[]
    Return the flags for each parameter.
    int
    Get the number of IN parameters in this list.
    int
    Get the number of OUT parameters in this list.
    int
    Get the number of parameters in this list.
    int[]
    Return the parameter type information.
    Return a list of the SimpleParameterList objects that make up this parameter list.
    int[]
    Return the oids of the parameters in this list.
    Returns the bound parameter values.
    void
    registerOutParameter(int index, int sqlType)
     
    void
    setBinaryParameter(int index, byte[] value, int oid)
    Binds given byte[] value to a parameter.
    void
    setBytea(int index, byte[] data, int offset, int length)
    Binds a binary bytea value stored as a bytearray to a parameter.
    void
    setBytea(int index, InputStream stream)
    Binds a binary bytea value stored as an InputStream.
    void
    setBytea(int index, InputStream stream, int length)
    Binds a binary bytea value stored as an InputStream.
    void
    setBytea(int index, ByteStreamWriter writer)
    Binds a binary bytea value stored as a ByteStreamWriter.
    void
    setIntParameter(int index, int value)
    Binds an integer value to a parameter.
    void
    setLiteralParameter(int index, String value, int oid)
    Binds a String value that is an unquoted literal to the server's query parser (for example, a bare integer) to a parameter.
    void
    setNull(int index, int oid)
    Binds a SQL NULL value to a parameter.
    void
    setStringParameter(int index, String value, int oid)
    Binds a String value that needs to be quoted for the server's parser to understand (for example, a timestamp) to a parameter.
    void
    setText(int index, InputStream stream)
    Binds a text value stored as an InputStream that is a valid UTF-8 byte stream.
    toString(int index, boolean standardConformingStrings)
    Return a human-readable representation of a particular parameter in this ParameterList.

    Methods inherited from class java.lang.Object

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

    • total

      private final int total
    • subparams

      private final SimpleParameterList[] subparams
    • offsets

      private final int[] offsets
  • Constructor Details

    • CompositeParameterList

      CompositeParameterList(SimpleParameterList[] subparams, int[] offsets)
  • Method Details

    • findSubParam

      private int findSubParam(int index) throws SQLException
      Throws:
      SQLException
    • registerOutParameter

      public void registerOutParameter(int index, int sqlType)
      Specified by:
      registerOutParameter in interface ParameterList
    • getDirection

      public int getDirection(int i)
    • getParameterCount

      public int getParameterCount()
      Description copied from interface: ParameterList
      Get the number of parameters in this list. This value never changes for a particular instance, and might be zero.
      Specified by:
      getParameterCount in interface ParameterList
      Returns:
      the number of parameters in this list.
    • getInParameterCount

      public int getInParameterCount()
      Description copied from interface: ParameterList
      Get the number of IN parameters in this list.
      Specified by:
      getInParameterCount in interface ParameterList
      Returns:
      the number of IN parameters in this list
    • getOutParameterCount

      public int getOutParameterCount()
      Description copied from interface: ParameterList
      Get the number of OUT parameters in this list.
      Specified by:
      getOutParameterCount in interface ParameterList
      Returns:
      the number of OUT parameters in this list
    • getTypeOIDs

      public int[] getTypeOIDs()
      Description copied from interface: ParameterList
      Return the oids of the parameters in this list. May be null for a ParameterList that does not support typing of parameters.
      Specified by:
      getTypeOIDs in interface ParameterList
      Returns:
      oids of the parameters
    • setIntParameter

      public void setIntParameter(int index, int value) throws SQLException
      Description copied from interface: ParameterList
      Binds an integer value to a parameter. The type of the parameter is implicitly 'int4'.
      Specified by:
      setIntParameter in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      value - the integer value to use.
      Throws:
      SQLException - on error or if index is out of range
    • setLiteralParameter

      public void setLiteralParameter(int index, String value, int oid) throws SQLException
      Description copied from interface: ParameterList
      Binds a String value that is an unquoted literal to the server's query parser (for example, a bare integer) to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.
      Specified by:
      setLiteralParameter in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      value - the unquoted literal string to use.
      oid - the type OID of the parameter, or 0 to infer the type.
      Throws:
      SQLException - on error or if index is out of range
    • setStringParameter

      public void setStringParameter(int index, String value, int oid) throws SQLException
      Description copied from interface: ParameterList
      Binds a String value that needs to be quoted for the server's parser to understand (for example, a timestamp) to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.
      Specified by:
      setStringParameter in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      value - the quoted string to use.
      oid - the type OID of the parameter, or 0 to infer the type.
      Throws:
      SQLException - on error or if index is out of range
    • setBinaryParameter

      public void setBinaryParameter(int index, byte[] value, int oid) throws SQLException
      Description copied from interface: ParameterList
      Binds given byte[] value to a parameter. The bytes must already be in correct format matching the OID.
      Specified by:
      setBinaryParameter in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      value - the bytes to send.
      oid - the type OID of the parameter.
      Throws:
      SQLException - on error or if index is out of range
    • setBytea

      public void setBytea(int index, byte[] data, int offset, int length) throws SQLException
      Description copied from interface: ParameterList
      Binds a binary bytea value stored as a bytearray to a parameter. The parameter's type is implicitly set to 'bytea'. The bytearray's contains should remain unchanged until query execution has completed.
      Specified by:
      setBytea in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      data - an array containing the raw data value
      offset - the offset within data of the start of the parameter data.
      length - the number of bytes of parameter data within data to use.
      Throws:
      SQLException - on error or if index is out of range
    • setBytea

      public void setBytea(int index, InputStream stream, int length) throws SQLException
      Description copied from interface: ParameterList
      Binds a binary bytea value stored as an InputStream. The parameter's type is implicitly set to 'bytea'. The stream should remain valid until query execution has completed.
      Specified by:
      setBytea in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      stream - a stream containing the parameter data.
      length - the number of bytes of parameter data to read from stream.
      Throws:
      SQLException - on error or if index is out of range
    • setBytea

      public void setBytea(int index, InputStream stream) throws SQLException
      Description copied from interface: ParameterList
      Binds a binary bytea value stored as an InputStream. The parameter's type is implicitly set to 'bytea'. The stream should remain valid until query execution has completed.
      Specified by:
      setBytea in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      stream - a stream containing the parameter data.
      Throws:
      SQLException - on error or if index is out of range
    • setBytea

      public void setBytea(int index, ByteStreamWriter writer) throws SQLException
      Description copied from interface: ParameterList
      Binds a binary bytea value stored as a ByteStreamWriter. The parameter's type is implicitly set to 'bytea'. The stream should remain valid until query execution has completed.
      Specified by:
      setBytea in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      writer - a writer that can write the bytes for the parameter
      Throws:
      SQLException - on error or if index is out of range
    • setText

      public void setText(int index, InputStream stream) throws SQLException
      Description copied from interface: ParameterList
      Binds a text value stored as an InputStream that is a valid UTF-8 byte stream. Any byte-order marks (BOM) in the stream are passed to the backend. The parameter's type is implicitly set to 'text'. The stream should remain valid until query execution has completed.
      Specified by:
      setText in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      stream - a stream containing the parameter data.
      Throws:
      SQLException - on error or if index is out of range
    • setNull

      public void setNull(int index, int oid) throws SQLException
      Description copied from interface: ParameterList
      Binds a SQL NULL value to a parameter. Associated with the parameter is a typename for the parameter that should correspond to an entry in pg_types.
      Specified by:
      setNull in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      oid - the type OID of the parameter, or 0 to infer the type.
      Throws:
      SQLException - on error or if index is out of range
    • toString

      public String toString(int index, boolean standardConformingStrings)
      Description copied from interface: ParameterList
      Return a human-readable representation of a particular parameter in this ParameterList. If the parameter is not bound, returns "?".
      Specified by:
      toString in interface ParameterList
      Parameters:
      index - the 1-based parameter index to bind.
      standardConformingStrings - true if \ is not an escape character in strings literals
      Returns:
      a string representation of the parameter.
    • copy

      public ParameterList copy()
      Description copied from interface: ParameterList
      Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query). If this ParameterList is immutable, copy() may return the same immutable object.
      Specified by:
      copy in interface ParameterList
      Returns:
      a new ParameterList instance
    • clear

      public void clear()
      Description copied from interface: ParameterList
      Unbind all parameter values bound in this list.
      Specified by:
      clear in interface ParameterList
    • getSubparams

      public SimpleParameterList[] getSubparams()
      Description copied from interface: V3ParameterList
      Return a list of the SimpleParameterList objects that make up this parameter list. If this object is already a SimpleParameterList, returns null (avoids an extra array construction in the common case).
      Specified by:
      getSubparams in interface V3ParameterList
      Returns:
      an array of single-statement parameter lists, or null if this object is already a single-statement parameter list.
    • checkAllParametersSet

      public void checkAllParametersSet() throws SQLException
      Description copied from interface: V3ParameterList
      Ensure that all parameters in this list have been assigned values. Return silently if all is well, otherwise throw an appropriate exception.
      Specified by:
      checkAllParametersSet in interface V3ParameterList
      Throws:
      SQLException - if not all parameters are set.
    • getEncoding

      public byte[][] getEncoding()
      Description copied from interface: V3ParameterList
      Return the encoding for each parameter.
      Specified by:
      getEncoding in interface V3ParameterList
      Returns:
      nested byte array of bytes with encoding information.
    • getFlags

      public byte[] getFlags()
      Description copied from interface: V3ParameterList
      Return the flags for each parameter.
      Specified by:
      getFlags in interface V3ParameterList
      Returns:
      an array of bytes used to store flags.
    • getParamTypes

      public int[] getParamTypes()
      Description copied from interface: V3ParameterList
      Return the parameter type information.
      Specified by:
      getParamTypes in interface V3ParameterList
      Returns:
      an array of Oid type information
    • getValues

      public Object[] getValues()
      Description copied from interface: ParameterList
      Returns the bound parameter values.
      Specified by:
      getValues in interface ParameterList
      Returns:
      Object array containing the parameter values.
    • appendAll

      public void appendAll(ParameterList list) throws SQLException
      Description copied from interface: ParameterList
      Use this operation to append more parameters to the current list.
      Specified by:
      appendAll in interface ParameterList
      Parameters:
      list - of parameters to append with.
      Throws:
      SQLException - fault raised if driver or back end throw an exception
    • convertFunctionOutParameters

      public void convertFunctionOutParameters()
      Description copied from interface: V3ParameterList
      Convert any function output parameters to the correct type (void) and set an ignorable value for it.
      Specified by:
      convertFunctionOutParameters in interface V3ParameterList