/
ServiceRequestBufferImp.java
86 lines (75 loc) · 2.9 KB
/
ServiceRequestBufferImp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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.ServiceRequestBuffer;
import org.firebirdsql.gds.impl.argument.ArgumentType;
import org.firebirdsql.gds.impl.argument.NumericArgument;
/**
* Implementation of ServiceRequestBufferImp.
*/
public class ServiceRequestBufferImp extends ParameterBufferBase implements ServiceRequestBuffer {
public ServiceRequestBufferImp(SrbMetaData srbMetaData, Encoding encoding) {
super(srbMetaData, encoding);
}
@Override
public void addArgument(int argumentType, byte value) {
// TODO Handle through metadata behavior
getArgumentsList().add(new NumericArgument(argumentType, ArgumentType.ByteSpb, value));
}
public enum SrbMetaData implements ParameterBufferMetaData {
// Technically this has nothing to do with SPB version 2/3
SRB_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) {
switch (tag) {
case ISCConstants.isc_spb_rpr_commit_trans_64:
case ISCConstants.isc_spb_rpr_rollback_trans_64:
case ISCConstants.isc_spb_rpr_recover_two_phase_64:
return ArgumentType.BigIntSpb;
default:
return ArgumentType.IntSpb;
}
}
@Override
public ArgumentType getSingleArgumentType(int tag) {
return ArgumentType.SingleTpb;
}
};
private final int spbVersion;
SrbMetaData(int spbVersion) {
this.spbVersion = spbVersion;
}
@Override
public final int getType() {
return spbVersion;
}
}
}