-
Notifications
You must be signed in to change notification settings - Fork 865
/
AbstractGettableData.java
234 lines (200 loc) · 5.97 KB
/
AbstractGettableData.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.datastax.driver.core;
import com.google.common.reflect.TypeToken;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public abstract class AbstractGettableData extends AbstractGettableByIndexData
implements GettableData {
/**
* Creates a new AbstractGettableData object.
*
* @param protocolVersion the protocol version in which values returned by {@link #getValue} will
* be returned. This must be a protocol version supported by this driver. In general, the
* correct value will be the value returned by {@link ProtocolOptions#getProtocolVersion}.
* @throws IllegalArgumentException if {@code protocolVersion} is not a valid protocol version.
*/
protected AbstractGettableData(ProtocolVersion protocolVersion) {
super(protocolVersion);
}
/**
* Returns the index corresponding to a given name.
*
* @param name the name for which to return the index of.
* @return the index for the value coressponding to {@code name}.
* @throws IllegalArgumentException if {@code name} is not valid name for this object.
*/
protected abstract int getIndexOf(String name);
/** {@inheritDoc} */
@Override
public boolean isNull(String name) {
return isNull(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public boolean getBool(String name) {
return getBool(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public byte getByte(String name) {
return getByte(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public short getShort(String name) {
return getShort(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public int getInt(String name) {
return getInt(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public long getLong(String name) {
return getLong(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public Date getTimestamp(String name) {
return getTimestamp(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public LocalDate getDate(String name) {
return getDate(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public long getTime(String name) {
return getTime(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public float getFloat(String name) {
return getFloat(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public double getDouble(String name) {
return getDouble(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public ByteBuffer getBytesUnsafe(String name) {
return getBytesUnsafe(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public ByteBuffer getBytes(String name) {
return getBytes(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public String getString(String name) {
return getString(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public BigInteger getVarint(String name) {
return getVarint(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public BigDecimal getDecimal(String name) {
return getDecimal(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public UUID getUUID(String name) {
return getUUID(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public InetAddress getInet(String name) {
return getInet(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public <T> List<T> getList(String name, Class<T> elementsClass) {
return getList(getIndexOf(name), elementsClass);
}
/** {@inheritDoc} */
@Override
public <T> List<T> getList(String name, TypeToken<T> elementsType) {
return getList(getIndexOf(name), elementsType);
}
/** {@inheritDoc} */
@Override
public <T> Set<T> getSet(String name, Class<T> elementsClass) {
return getSet(getIndexOf(name), elementsClass);
}
/** {@inheritDoc} */
@Override
public <T> Set<T> getSet(String name, TypeToken<T> elementsType) {
return getSet(getIndexOf(name), elementsType);
}
/** {@inheritDoc} */
@Override
public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass) {
return getMap(getIndexOf(name), keysClass, valuesClass);
}
/** {@inheritDoc} */
@Override
public <K, V> Map<K, V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType) {
return getMap(getIndexOf(name), keysType, valuesType);
}
/** {@inheritDoc} */
@Override
public UDTValue getUDTValue(String name) {
return getUDTValue(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public TupleValue getTupleValue(String name) {
return getTupleValue(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public Object getObject(String name) {
return getObject(getIndexOf(name));
}
/** {@inheritDoc} */
@Override
public <T> T get(String name, Class<T> targetClass) {
return get(getIndexOf(name), targetClass);
}
/** {@inheritDoc} */
@Override
public <T> T get(String name, TypeToken<T> targetType) {
return get(getIndexOf(name), targetType);
}
/** {@inheritDoc} */
@Override
public <T> T get(String name, TypeCodec<T> codec) {
return get(getIndexOf(name), codec);
}
}