org.firebirdsql.gds.impl.ServiceParameterBufferImp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaybird Show documentation
Show all versions of jaybird Show documentation
JDBC Driver for the Firebird RDBMS
The newest version!
/*
* Firebird Open Source JavaEE Connector - JDBC Driver
*
* Distributable under LGPL license.
* You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* LGPL License for more details.
*
* This file was created by members of the firebird development team.
* All individual contributions remain the Copyright (C) of those
* individuals. Contributors to this file are either listed here or
* can be obtained from a source control history command.
*
* All rights reserved.
*/
package org.firebirdsql.gds.impl;
import org.firebirdsql.encodings.Encoding;
import org.firebirdsql.gds.ISCConstants;
import org.firebirdsql.gds.ParameterBuffer;
import org.firebirdsql.gds.ParameterTagMapping;
import org.firebirdsql.gds.ServiceParameterBuffer;
import org.firebirdsql.gds.impl.argument.ArgumentType;
import java.io.Serial;
/**
* Implementation of ServiceParameterBuffer.
*/
public class ServiceParameterBufferImp extends ParameterBufferBase implements ServiceParameterBuffer {
@Serial
private static final long serialVersionUID = 3112578847419907591L;
/**
* Creates an empty service parameter buffer
*/
public ServiceParameterBufferImp(SpbMetaData spbMetaData, Encoding defaultEncoding) {
super(spbMetaData, defaultEncoding);
}
@Override
public ParameterTagMapping getTagMapping() {
return ParameterTagMapping.SPB;
}
public enum SpbMetaData implements ParameterBufferMetaData {
// TODO Unsure if we need the versions without _ATTACH
SPB_VERSION_2_ATTACH(ISCConstants.isc_spb_version) {
@Override
public void addPreamble(ParameterBuffer parameterBuffer) {
parameterBuffer.addArgument(ISCConstants.isc_spb_current_version);
}
@Override
public ArgumentType getStringArgumentType(int tag) {
return ArgumentType.TraditionalDpb;
}
@Override
public ArgumentType getByteArrayArgumentType(int tag) {
return ArgumentType.TraditionalDpb;
}
@Override
public ArgumentType getIntegerArgumentType(int tag) {
return ArgumentType.TraditionalDpb;
}
@Override
public ArgumentType getSingleArgumentType(int tag) {
if (tag == ISCConstants.isc_spb_current_version) {
return ArgumentType.SingleTpb;
}
return ArgumentType.TraditionalDpb;
}
},
// Technically this has nothing to do with SPB version 2/3
SPB_VERSION_2(ISCConstants.isc_spb_current_version) {
// TODO Check if correct and add additional types
@Override
public ArgumentType getStringArgumentType(int tag) {
return ArgumentType.StringSpb;
}
@Override
public ArgumentType getByteArrayArgumentType(int tag) {
return ArgumentType.StringSpb;
}
@Override
public ArgumentType getIntegerArgumentType(int tag) {
return switch (tag) {
case ISCConstants.isc_spb_rpr_commit_trans_64,
ISCConstants.isc_spb_rpr_rollback_trans_64,
ISCConstants.isc_spb_rpr_recover_two_phase_64 -> ArgumentType.BigIntSpb;
default -> ArgumentType.IntSpb;
};
}
@Override
public ArgumentType getSingleArgumentType(int tag) {
return ArgumentType.SingleTpb;
}
@Override
public ArgumentType getByteArgumentType(int tag) {
return ArgumentType.ByteSpb;
}
},
SPB_VERSION_3_ATTACH(ISCConstants.isc_spb_version3) {
@Override
public ArgumentType getStringArgumentType(int tag) {
return ArgumentType.Wide;
}
@Override
public ArgumentType getByteArrayArgumentType(int tag) {
return ArgumentType.Wide;
}
@Override
public ArgumentType getIntegerArgumentType(int tag) {
return ArgumentType.Wide;
}
@Override
public ArgumentType getSingleArgumentType(int tag) {
return ArgumentType.Wide;
}
};
private final int spbVersion;
SpbMetaData(int spbVersion) {
this.spbVersion = spbVersion;
}
@Override
public final int getType() {
return spbVersion;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy