StandardCharsets.UTF_8 is already used in FlexBuffersBuilder.
import static com.google.flatbuffers.Constants.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import java.nio.charset.Charset;
/// @cond FLATBUFFERS_INTERNAL
* All tables in the generated code derive from this class, and add their own accessors.
*/
public class Table {
- public final static ThreadLocal<Charset> UTF8_CHARSET = new ThreadLocal<Charset>() {
- @Override
- protected Charset initialValue() {
- return Charset.forName("UTF-8");
- }
- };
/** Used to hold the position of the `bb` buffer. */
protected int bb_pos;
/** The underlying ByteBuffer to hold the data of the Table. */
code += " key, ByteBuffer bb) {\n";
if (key_field->value.type.base_type == BASE_TYPE_STRING) {
code += " byte[] byteKey = ";
- code += "key.getBytes(Table.UTF8_CHARSET.get());\n";
+ code += "key.getBytes(java.nio.charset.StandardCharsets.UTF_8);\n";
}
code += " int span = ";
code += "bb.getInt(vectorLocation - 4);\n";
if (base_type == BASE_TYPE_STRING) {
writer +=
"val byteKey = key."
- "toByteArray(Table.UTF8_CHARSET.get()!!)";
+ "toByteArray(java.nio.charset.StandardCharsets.UTF_8)";
}
writer += "var span = bb.getInt(vectorLocation - 4)";
writer += "var start = 0";
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(10, o1, _bb), __offset(10, o2, _bb), _bb); }
public static Monster __lookup_by_key(Monster obj, int vectorLocation, String key, ByteBuffer bb) {
- byte[] byteKey = key.getBytes(Table.UTF8_CHARSET.get());
+ byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
int span = bb.getInt(vectorLocation - 4);
int start = 0;
while (span != 0) {
fun finishMonsterBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finish(offset, "MONS")
fun finishSizePrefixedMonsterBuffer(builder: FlatBufferBuilder, offset: Int) = builder.finishSizePrefixed(offset, "MONS")
fun __lookup_by_key(obj: Monster?, vectorLocation: Int, key: String, bb: ByteBuffer) : Monster? {
- val byteKey = key.toByteArray(Table.UTF8_CHARSET.get()!!)
+ val byteKey = key.toByteArray(java.nio.charset.StandardCharsets.UTF_8)
var span = bb.getInt(vectorLocation - 4)
var start = 0
while (span != 0) {