java.lang.Object
org.firebirdsql.gds.impl.ParameterBufferBase
- All Implemented Interfaces:
Serializable,Iterable<Parameter>,ParameterBuffer
- Direct Known Subclasses:
BatchParameterBufferImp,BlobParameterBufferImp,DatabaseParameterBufferImp,ServiceParameterBufferImp,ServiceRequestBufferImp,TransactionParameterBufferImpl
Base class for parameter buffers
- Author:
- Mark Rotteveel
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData) Creates aParameterBufferBase.protectedParameterBufferBase(ParameterBufferMetaData parameterBufferMetaData, Encoding defaultEncoding) Creates aParameterBufferBase. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddArgument(int argumentType) Add argument with no parameters.final voidaddArgument(int argumentType, byte value) Add a byte argument.final voidaddArgument(int type, byte[] content) Add array of bytes.final voidaddArgument(int argumentType, int value) Add integer argument.final voidaddArgument(int argumentType, long value) Add long argument.final voidaddArgument(int argumentType, String value) Add string argument with the default encoding.final voidaddArgument(int argumentType, String value, Encoding encoding) Add string argument.protected final voidaddArgument(Argument argument) final booleanfindFirst(int type) final intgetArgumentAsInt(int type) Get argument as int.final StringgetArgumentAsString(int type) Get argument as string.final Encodingprotected final intfinal ParameterBufferMetaDatafinal intgetType()final booleanhasArgument(int type) Check if this parameter buffer has specified argument.final inthashCode()iterator()Returns an iterator over a copy of the parameters in this parameter buffer.final voidremoveArgument(int type) Remove the first occurrence of the specified argument.final intsize()final byte[]toBytes()Converts this parameter buffer to a byte array.final byte[]Converts this parameter buffer to a byte array with type information.final Xdrablefinal voidwriteArgumentsTo(OutputStream outputStream) Writes the arguments in the implementation specific serialization into theOutputStream.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ParameterBufferBase
Creates aParameterBufferBase.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 aParameterBufferBase.- Parameters:
parameterBufferMetaData- Metadata for the parameter buffer.defaultEncoding- Default encoding to use for string arguments
-
-
Method Details
-
getDefaultEncoding
-
getParameterBufferMetaData
-
getType
public final int getType()- Specified by:
getTypein interfaceParameterBuffer- Returns:
- The parameter buffer type identifier
-
addArgument
Description copied from interface:ParameterBufferAdd string argument with the default encoding.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
argumentType- type of argument.value- string value to add.
-
addArgument
Description copied from interface:ParameterBufferAdd string argument.- Specified by:
addArgumentin interfaceParameterBuffer- 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:ParameterBufferAdd a byte argument.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
argumentType- type of argument.value- byte value to add.
-
addArgument
public final void addArgument(int argumentType, int value) Description copied from interface:ParameterBufferAdd integer argument.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
argumentType- type of argument.value- integer value to add.
-
addArgument
public final void addArgument(int argumentType, long value) Description copied from interface:ParameterBufferAdd long argument.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
argumentType- type of argument.value- long value to add.
-
addArgument
public final void addArgument(int argumentType) Description copied from interface:ParameterBufferAdd argument with no parameters.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
argumentType- type of argument.
-
addArgument
public final void addArgument(int type, byte[] content) Description copied from interface:ParameterBufferAdd array of bytes.- Specified by:
addArgumentin interfaceParameterBuffer- Parameters:
type- type of argument.content- content of argument.
-
addArgument
-
getArgumentAsString
Description copied from interface:ParameterBufferGet argument as string.- Specified by:
getArgumentAsStringin interfaceParameterBuffer- Parameters:
type- type of argument to find.- Returns:
- argument as string or
nullif nothing found.
-
getArgumentAsInt
public final int getArgumentAsInt(int type) Description copied from interface:ParameterBufferGet argument as int.- Specified by:
getArgumentAsIntin interfaceParameterBuffer- Parameters:
type- type of argument to find.- Returns:
- argument as string or
0if nothing found.
-
hasArgument
public final boolean hasArgument(int type) Description copied from interface:ParameterBufferCheck if this parameter buffer has specified argument.- Specified by:
hasArgumentin interfaceParameterBuffer- Parameters:
type- type of argument to find.- Returns:
trueif this buffer contains specified argument.
-
findFirst
-
removeArgument
public final void removeArgument(int type) Description copied from interface:ParameterBufferRemove the first occurrence of the specified argument.- Specified by:
removeArgumentin interfaceParameterBuffer- Parameters:
type- type of argument to remove.
-
iterator
Description copied from interface:ParameterBufferReturns 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:
iteratorin interfaceIterable<Parameter>- Specified by:
iteratorin interfaceParameterBuffer- Returns:
- Iterator over the parameters in this parameter buffer.
-
writeArgumentsTo
Description copied from interface:ParameterBufferWrites the arguments in the implementation specific serialization into theOutputStream.- Specified by:
writeArgumentsToin interfaceParameterBuffer- Parameters:
outputStream- TheOutputStreamto write to- Throws:
IOException- Errors produced by the output stream during writes
-
toXdrable
- Specified by:
toXdrablein interfaceParameterBuffer- Returns:
Xdrableto write (and optionally read) this instance as Xdr.
-
getLength
protected final int getLength() -
getArgumentsList
-
toBytes
public final byte[] toBytes()Description copied from interface:ParameterBufferConverts 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:
toBytesin interfaceParameterBuffer- Returns:
- Byte array with serialization of this parameter buffer
- See Also:
-
toBytesWithType
public final byte[] toBytesWithType()Description copied from interface:ParameterBufferConverts 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:
toBytesWithTypein interfaceParameterBuffer- Returns:
- Byte array with serialization of this parameter buffer
- See Also:
-
size
public final int size()- Specified by:
sizein interfaceParameterBuffer- Returns:
- the number of parameters stored.
-
equals
-
hashCode
public final int hashCode()
-