Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.impl

# Class ParameterBufferBase

java.lang.Object
org.firebirdsql.gds.impl.ParameterBufferBase

All Implemented Interfaces:
  `Serializable`, `Iterable<Parameter>`, `ParameterBuffer`

Direct Known Subclasses:
  `BatchParameterBufferImp`, `BlobParameterBufferImp`, `DatabaseParameterBufferImp`, `ServiceParameterBufferImp`, `ServiceRequestBufferImp`, `TransactionParameterBufferImpl`

public abstract class ParameterBufferBase extends Object implements ParameterBuffer, Serializable
Base class for parameter buffers

Author:
  Mark Rotteveel
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `ParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData)`
  Creates a `ParameterBufferBase`.
  `protected`
  `ParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData, Encoding defaultEncoding)`
  Creates a `ParameterBufferBase`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final void`
  `addArgument(int argumentType)`
  Add argument with no parameters.
  `final void`
  `addArgument(int argumentType, byte value)`
  Add a byte argument.
  `final void`
  `addArgument(int type, byte[] content)`
  Add array of bytes.
  `final void`
  `addArgument(int argumentType, int value)`
  Add integer argument.
  `final void`
  `addArgument(int argumentType, long value)`
  Add long argument.
  `final void`
  `addArgument(int argumentType, String value)`
  Add string argument with the default encoding.
  `final void`
  `addArgument(int argumentType, String value, Encoding encoding)`
  Add string argument.
  `protected final void`
  `addArgument(Argument argument)`
  `final boolean`
  `equals(Object other)`
  `protected Optional<Argument>`
  `findFirst(int type)`
  `final int`
  `getArgumentAsInt(int type)`
  Get argument as int.
  `final String`
  `getArgumentAsString(int type)`
  Get argument as string.
  `protected final List<Argument>`
  `getArgumentsList()`
  `final Encoding`
  `getDefaultEncoding()`
  `protected final int`
  `getLength()`
  `final ParameterBufferMetaData`
  `getParameterBufferMetaData()`
  `final int`
  `getType()`
  `final boolean`
  `hasArgument(int type)`
  Check if this parameter buffer has specified argument.
  `final int`
  `hashCode()`
  `final boolean`
  `isEmpty()`
  `final Iterator<Parameter>`
  `iterator()`
  Returns an iterator over a copy of the parameters in this parameter buffer.
  `final void`
  `removeArgument(int type)`
  Remove the first occurrence of the specified argument.
  `final int`
  `size()`
  `final byte[]`
  `toBytes()`
  Converts this parameter buffer to a byte array.
  `final byte[]`
  `toBytesWithType()`
  Converts this parameter buffer to a byte array with type information.
  `final Xdrable`
  `toXdrable()`
  `final void`
  `writeArgumentsTo(OutputStream outputStream)`
  Writes the arguments in the implementation specific serialization into the `OutputStream`.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### ParameterBufferBase

    protected ParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData)
    Creates a `ParameterBufferBase`.

    This uses a default encoding derived from the system default encoding. You usually want to use `ParameterBufferBase(ParameterBufferMetaData, Encoding)` instead.

    Parameters:
      `parameterBufferMetaData` - Metadata for the parameter buffer.

  - ### ParameterBufferBase

    protected ParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData, Encoding defaultEncoding)
    Creates a `ParameterBufferBase`.
    Parameters:
      `parameterBufferMetaData` - Metadata for the parameter buffer.
      `defaultEncoding` - Default encoding to use for string arguments

- ## Method Details

  - ### getDefaultEncoding

    public final Encoding getDefaultEncoding()

  - ### getParameterBufferMetaData

    public final ParameterBufferMetaData getParameterBufferMetaData()

  - ### getType

    public final int getType()
    Specified by:
      `getType` in interface `ParameterBuffer`
    Returns:
      The parameter buffer type identifier

  - ### addArgument

    public final void addArgument(int argumentType, String value)
    Description copied from interface: `ParameterBuffer`
    Add string argument with the default encoding.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.
      `value` - string value to add.

  - ### addArgument

    public final void addArgument(int argumentType, String value, Encoding encoding)
    Description copied from interface: `ParameterBuffer`
    Add string argument.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.
      `value` - string value to add.
      `encoding` - encoding to use for conversion to bytes

  - ### addArgument

    public final void addArgument(int argumentType, byte value)
    Description copied from interface: `ParameterBuffer`
    Add a byte argument.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.
      `value` - byte value to add.

  - ### addArgument

    public final void addArgument(int argumentType, int value)
    Description copied from interface: `ParameterBuffer`
    Add integer argument.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.
      `value` - integer value to add.

  - ### addArgument

    public final void addArgument(int argumentType, long value)
    Description copied from interface: `ParameterBuffer`
    Add long argument.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.
      `value` - long value to add.

  - ### addArgument

    public final void addArgument(int argumentType)
    Description copied from interface: `ParameterBuffer`
    Add argument with no parameters.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `argumentType` - type of argument.

  - ### addArgument

    public final void addArgument(int type, byte[] content)
    Description copied from interface: `ParameterBuffer`
    Add array of bytes.
    Specified by:
      `addArgument` in interface `ParameterBuffer`
    Parameters:
      `type` - type of argument.
      `content` - content of argument.

  - ### addArgument

    protected final void addArgument(Argument argument)

  - ### getArgumentAsString

    public final String getArgumentAsString(int type)
    Description copied from interface: `ParameterBuffer`
    Get argument as string.
    Specified by:
      `getArgumentAsString` in interface `ParameterBuffer`
    Parameters:
      `type` - type of argument to find.
    Returns:
      argument as string or `null` if nothing found.

  - ### getArgumentAsInt

    public final int getArgumentAsInt(int type)
    Description copied from interface: `ParameterBuffer`
    Get argument as int.
    Specified by:
      `getArgumentAsInt` in interface `ParameterBuffer`
    Parameters:
      `type` - type of argument to find.
    Returns:
      argument as string or `0` if nothing found.

  - ### hasArgument

    public final boolean hasArgument(int type)
    Description copied from interface: `ParameterBuffer`
    Check if this parameter buffer has specified argument.
    Specified by:
      `hasArgument` in interface `ParameterBuffer`
    Parameters:
      `type` - type of argument to find.
    Returns:
      `true` if this buffer contains specified argument.

  - ### findFirst

    protected Optional<Argument> findFirst(int type)

  - ### removeArgument

    public final void removeArgument(int type)
    Description copied from interface: `ParameterBuffer`
    Remove the first occurrence of the specified argument.
    Specified by:
      `removeArgument` in interface `ParameterBuffer`
    Parameters:
      `type` - type of argument to remove.

  - ### iterator

    public final Iterator<Parameter> iterator()
    Description copied from interface: `ParameterBuffer`
    Returns an iterator over a copy of the parameters in this parameter buffer.

    It is safe to iterate over this iterator while modifying the parameter buffer. Changes will not be reflected in the iterator.

    Specified by:
      `iterator` in interface `Iterable<Parameter>`
    Specified by:
      `iterator` in interface `ParameterBuffer`
    Returns:
      Iterator over the parameters in this parameter buffer.

  - ### writeArgumentsTo

    public final void writeArgumentsTo(OutputStream outputStream) throws IOException
    Description copied from interface: `ParameterBuffer`
    Writes the arguments in the implementation specific serialization into the `OutputStream`.
    Specified by:
      `writeArgumentsTo` in interface `ParameterBuffer`
    Parameters:
      `outputStream` - The `OutputStream` to write to
    Throws:
      `IOException` - Errors produced by the output stream during writes

  - ### toXdrable

    public final Xdrable toXdrable()
    Specified by:
      `toXdrable` in interface `ParameterBuffer`
    Returns:
      `Xdrable` to write (and optionally read) this instance as Xdr.

  - ### getLength

    protected final int getLength()

  - ### getArgumentsList

    protected final List<Argument> getArgumentsList()

  - ### toBytes

    public final byte[] toBytes()
    Description copied from interface: `ParameterBuffer`
    Converts this parameter buffer to a byte array.

    This byte array includes the extra header-bytes (if any), but does not include the type information

    Specified by:
      `toBytes` in interface `ParameterBuffer`
    Returns:
      Byte array with serialization of this parameter buffer
    See Also:
      - `ParameterBuffer.toBytesWithType()`

  - ### toBytesWithType

    public final byte[] toBytesWithType()
    Description copied from interface: `ParameterBuffer`
    Converts this parameter buffer to a byte array with type information.

    This byte array includes the type information and the extra header bytes (if any).

    Specified by:
      `toBytesWithType` in interface `ParameterBuffer`
    Returns:
      Byte array with serialization of this parameter buffer
    See Also:
      - `ParameterBuffer.toBytes()`

  - ### size

    public final int size()
    Specified by:
      `size` in interface `ParameterBuffer`
    Returns:
      the number of parameters stored.

  - ### isEmpty

    public final boolean isEmpty()
    Specified by:
      `isEmpty` in interface `ParameterBuffer`
    Returns:
      `true` if empty, `false` if this buffer contains at least one parameter

  - ### equals

    public final boolean equals(Object other)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public final int hashCode()
    Overrides:
      `hashCode` in class `Object`