Remove some unused fbs files
This commit is contained in:
parent
891036d89a
commit
be9d562d57
197
third_party/flatbuffers/java/pom.xml
vendored
197
third_party/flatbuffers/java/pom.xml
vendored
@ -1,197 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.google.flatbuffers</groupId>
|
||||
<artifactId>flatbuffers-java</artifactId>
|
||||
<version>24.3.25</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>FlatBuffers Java API</name>
|
||||
<description>
|
||||
Memory Efficient Serialization Library
|
||||
</description>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Wouter van Oortmerssen</name>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Derek Bailey</name>
|
||||
<email>dbaileychess@gmail.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<url>https://github.com/google/flatbuffers</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License V2.0</name>
|
||||
<url>https://raw.githubusercontent.com/google/flatbuffers/master/LICENSE</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://github.com/google/flatbuffers</url>
|
||||
<connection>
|
||||
scm:git:https://github.com/google/flatbuffers.git
|
||||
</connection>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.truth</groupId>
|
||||
<artifactId>truth</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<additionalparam>-Xdoclint:none</additionalparam>
|
||||
<additionalOptions>-Xdoclint:none</additionalOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>5.1.2</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.8</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<gpgArguments>
|
||||
<arg>--pinentry-mode</arg>
|
||||
<arg>loopback</arg>
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<configuration>
|
||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
<releaseProfiles>release</releaseProfiles>
|
||||
<goals>deploy</goals>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jdk9</id>
|
||||
<activation>
|
||||
<jdk>[1.9,)</jdk>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<release>8</release>
|
||||
<testExcludes>
|
||||
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
|
||||
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
|
||||
</testExcludes>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jdk8</id>
|
||||
<activation>
|
||||
<jdk>1.8</jdk>
|
||||
</activation>
|
||||
<properties>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<testExcludes>
|
||||
<testExclude>MyGame/Example/MonsterStorageGrpc.java</testExclude>
|
||||
<testExclude>MyGame/OtherNameSpace/TableBT.java</testExclude>
|
||||
</testExcludes>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
@ -1,252 +0,0 @@
|
||||
package com.google.flatbuffers;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Implements {@code ReadBuf} using an array of bytes
|
||||
* as a backing storage. Using array of bytes are
|
||||
* usually faster than {@code ByteBuffer}.
|
||||
*
|
||||
* This class is not thread-safe, meaning that
|
||||
* it must operate on a single thread. Operating from
|
||||
* multiple thread leads into a undefined behavior
|
||||
*/
|
||||
public class ArrayReadWriteBuf implements ReadWriteBuf {
|
||||
|
||||
private byte[] buffer;
|
||||
private int writePos;
|
||||
|
||||
public ArrayReadWriteBuf() {
|
||||
this(10);
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(int initialCapacity) {
|
||||
this(new byte[initialCapacity]);
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(byte[] buffer) {
|
||||
this.buffer = buffer;
|
||||
this.writePos = 0;
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(byte[] buffer, int startPos) {
|
||||
this.buffer = buffer;
|
||||
this.writePos = startPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
this.writePos = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(int index) {
|
||||
return buffer[index] != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte get(int index) {
|
||||
return buffer[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return (short) ((buffer[index+ 1] << 8) | (buffer[index] & 0xff));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return (((buffer[index + 3]) << 24) |
|
||||
((buffer[index + 2] & 0xff) << 16) |
|
||||
((buffer[index + 1] & 0xff) << 8) |
|
||||
((buffer[index] & 0xff)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return ((((long) buffer[index++] & 0xff)) |
|
||||
(((long) buffer[index++] & 0xff) << 8) |
|
||||
(((long) buffer[index++] & 0xff) << 16) |
|
||||
(((long) buffer[index++] & 0xff) << 24) |
|
||||
(((long) buffer[index++] & 0xff) << 32) |
|
||||
(((long) buffer[index++] & 0xff) << 40) |
|
||||
(((long) buffer[index++] & 0xff) << 48) |
|
||||
(((long) buffer[index]) << 56));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(int index) {
|
||||
return Float.intBitsToFloat(getInt(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(int index) {
|
||||
return Double.longBitsToDouble(getLong(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int start, int size) {
|
||||
return Utf8Safe.decodeUtf8Array(buffer, start, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] data() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void putBoolean(boolean value) {
|
||||
setBoolean(writePos, value);
|
||||
writePos++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(byte[] value, int start, int length) {
|
||||
set(writePos, value, start, length);
|
||||
writePos+=length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(byte value) {
|
||||
set(writePos, value);
|
||||
writePos++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putShort(short value) {
|
||||
setShort(writePos, value);
|
||||
writePos +=2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInt(int value) {
|
||||
setInt(writePos, value);
|
||||
writePos +=4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLong(long value) {
|
||||
setLong(writePos, value);
|
||||
writePos +=8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFloat(float value) {
|
||||
setFloat(writePos, value);
|
||||
writePos +=4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putDouble(double value) {
|
||||
setDouble(writePos, value);
|
||||
writePos +=8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(int index, boolean value) {
|
||||
set(index, value ? (byte)1 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int index, byte value) {
|
||||
requestCapacity(index + 1);
|
||||
buffer[index] = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int index, byte[] toCopy, int start, int length) {
|
||||
requestCapacity(index + (length - start));
|
||||
System.arraycopy(toCopy, start, buffer, index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, short value) {
|
||||
requestCapacity(index + 2);
|
||||
|
||||
buffer[index++] = (byte) ((value) & 0xff);
|
||||
buffer[index ] = (byte) ((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
requestCapacity(index + 4);
|
||||
|
||||
buffer[index++] = (byte) ((value) & 0xff);
|
||||
buffer[index++] = (byte) ((value >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((value >> 16) & 0xff);
|
||||
buffer[index ] = (byte) ((value >> 24) & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
requestCapacity(index + 8);
|
||||
|
||||
int i = (int) value;
|
||||
buffer[index++] = (byte) ((i) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 16) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 24) & 0xff);
|
||||
i = (int) (value >> 32);
|
||||
buffer[index++] = (byte) ((i) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 16) & 0xff);
|
||||
buffer[index ] = (byte) ((i >> 24) & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloat(int index, float value) {
|
||||
requestCapacity(index + 4);
|
||||
|
||||
int iValue = Float.floatToRawIntBits(value);
|
||||
buffer[index++] = (byte) ((iValue) & 0xff);
|
||||
buffer[index++] = (byte) ((iValue >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((iValue >> 16) & 0xff);
|
||||
buffer[index ] = (byte) ((iValue >> 24) & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int index, double value) {
|
||||
requestCapacity(index + 8);
|
||||
|
||||
long lValue = Double.doubleToRawLongBits(value);
|
||||
int i = (int) lValue;
|
||||
buffer[index++] = (byte) ((i) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 16) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 24) & 0xff);
|
||||
i = (int) (lValue >> 32);
|
||||
buffer[index++] = (byte) ((i) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 8) & 0xff);
|
||||
buffer[index++] = (byte) ((i >> 16) & 0xff);
|
||||
buffer[index ] = (byte) ((i >> 24) & 0xff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int limit() {
|
||||
return writePos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writePosition() {
|
||||
return writePos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestCapacity(int capacity) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("Capacity may not be negative (likely a previous int overflow)");
|
||||
}
|
||||
if (buffer.length >= capacity) {
|
||||
return true;
|
||||
}
|
||||
// implemented in the same growing fashion as ArrayList
|
||||
int oldCapacity = buffer.length;
|
||||
int newCapacity = oldCapacity + (oldCapacity >> 1);
|
||||
if (newCapacity < capacity) { // Note: this also catches newCapacity int overflow
|
||||
newCapacity = capacity;
|
||||
}
|
||||
buffer = Arrays.copyOf(buffer, newCapacity);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
|
||||
/**
|
||||
* All vector access objects derive from this class, and add their own accessors.
|
||||
*/
|
||||
public class BaseVector {
|
||||
/** Used to hold the vector data position. */
|
||||
private int vector;
|
||||
/** Used to hold the vector size. */
|
||||
private int length;
|
||||
/** Used to hold the vector element size in table. */
|
||||
private int element_size;
|
||||
/** The underlying ByteBuffer to hold the data of the vector. */
|
||||
protected ByteBuffer bb;
|
||||
|
||||
/**
|
||||
* Get the start data of a vector.
|
||||
*
|
||||
* @return Returns the start of the vector data.
|
||||
*/
|
||||
protected int __vector() {
|
||||
return vector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the element position in vector's ByteBuffer.
|
||||
*
|
||||
* @param j An `int` index of element into a vector.
|
||||
* @return Returns the position of the vector element in a ByteBuffer.
|
||||
*/
|
||||
protected int __element(int j) {
|
||||
return vector + j * element_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-init the internal state with an external buffer {@code ByteBuffer}, an offset within and
|
||||
* element size.
|
||||
*
|
||||
* This method exists primarily to allow recycling vector instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references.
|
||||
*/
|
||||
protected void __reset(int _vector, int _element_size, ByteBuffer _bb) {
|
||||
bb = _bb;
|
||||
if (bb != null) {
|
||||
vector = _vector;
|
||||
length = bb.getInt(_vector - Constants.SIZEOF_INT);
|
||||
element_size = _element_size;
|
||||
} else {
|
||||
vector = 0;
|
||||
length = 0;
|
||||
element_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the internal state with a null {@code ByteBuffer} and a zero position.
|
||||
*
|
||||
* This method exists primarily to allow recycling vector instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references. The instance will be unusable until it is assigned
|
||||
* again to a {@code ByteBuffer}.
|
||||
*/
|
||||
public void reset() {
|
||||
__reset(0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of a vector.
|
||||
*
|
||||
* @return Returns the length of the vector.
|
||||
*/
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
/// @endcond
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of booleans.
|
||||
*/
|
||||
public final class BooleanVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public BooleanVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_BYTE, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the boolean at the given index.
|
||||
*
|
||||
* @param j The index from which the boolean will be read.
|
||||
* @return the boolean value at the given index.
|
||||
*/
|
||||
public boolean get(int j) {
|
||||
return 0 != bb.get(__element(j));
|
||||
}
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
package com.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class ByteBufferReadWriteBuf implements ReadWriteBuf {
|
||||
|
||||
private final ByteBuffer buffer;
|
||||
|
||||
public ByteBufferReadWriteBuf(ByteBuffer bb) {
|
||||
this.buffer = bb;
|
||||
this.buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(int index) {
|
||||
return get(index) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte get(int index) {
|
||||
return buffer.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int index) {
|
||||
return buffer.getShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int index) {
|
||||
return buffer.getInt(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int index) {
|
||||
return buffer.getLong(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(int index) {
|
||||
return buffer.getFloat(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(int index) {
|
||||
return buffer.getDouble(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int start, int size) {
|
||||
return Utf8Safe.decodeUtf8Buffer(buffer, start, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] data() {
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putBoolean(boolean value) {
|
||||
buffer.put(value ? (byte)1 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(byte[] value, int start, int length) {
|
||||
buffer.put(value, start, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(byte value) {
|
||||
buffer.put(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putShort(short value) {
|
||||
buffer.putShort(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInt(int value) {
|
||||
buffer.putInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLong(long value) {
|
||||
buffer.putLong(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFloat(float value) {
|
||||
buffer.putFloat(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putDouble(double value) {
|
||||
buffer.putDouble(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(int index, boolean value) {
|
||||
set(index, value ? (byte)1 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int index, byte value) {
|
||||
requestCapacity(index + 1);
|
||||
buffer.put(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int index, byte[] value, int start, int length) {
|
||||
requestCapacity(index + (length - start));
|
||||
int curPos = buffer.position();
|
||||
buffer.position(index);
|
||||
buffer.put(value, start, length);
|
||||
buffer.position(curPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShort(int index, short value) {
|
||||
requestCapacity(index + 2);
|
||||
buffer.putShort(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int index, int value) {
|
||||
requestCapacity(index + 4);
|
||||
buffer.putInt(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLong(int index, long value) {
|
||||
requestCapacity(index + 8);
|
||||
buffer.putLong(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloat(int index, float value) {
|
||||
requestCapacity(index + 4);
|
||||
buffer.putFloat(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int index, double value) {
|
||||
requestCapacity(index + 8);
|
||||
buffer.putDouble(index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int writePosition() {
|
||||
return buffer.position();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int limit() {
|
||||
return buffer.limit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestCapacity(int capacity) {
|
||||
return capacity <= buffer.limit();
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/// @file
|
||||
/// @addtogroup flatbuffers_java_api
|
||||
/// @{
|
||||
|
||||
/**
|
||||
* Class that collects utility functions around `ByteBuffer`.
|
||||
*/
|
||||
public class ByteBufferUtil {
|
||||
|
||||
/**
|
||||
* Extract the size prefix from a `ByteBuffer`.
|
||||
*
|
||||
* @param bb a size-prefixed buffer
|
||||
* @return the size prefix
|
||||
*/
|
||||
public static int getSizePrefix(ByteBuffer bb) {
|
||||
return bb.getInt(bb.position());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a duplicate of a size-prefixed `ByteBuffer` that has its position
|
||||
* advanced just past the size prefix.
|
||||
*
|
||||
* @param bb a size-prefixed buffer
|
||||
* @return a new buffer on the same underlying data that has skipped the
|
||||
* size prefix
|
||||
*/
|
||||
public static ByteBuffer removeSizePrefix(ByteBuffer bb) {
|
||||
ByteBuffer s = bb.duplicate();
|
||||
s.position(s.position() + SIZE_PREFIX_LENGTH);
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of signed or unsigned 8-bit values.
|
||||
*/
|
||||
public final class ByteVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param vector Start data of a vector.
|
||||
* @param bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public ByteVector __assign(int vector, ByteBuffer bb) {
|
||||
__reset(vector, Constants.SIZEOF_BYTE, bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the byte at the given index.
|
||||
*
|
||||
* @param j The index from which the byte will be read.
|
||||
* @return the 8-bit value at the given index.
|
||||
*/
|
||||
public byte get(int j) {
|
||||
return bb.get(__element(j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the byte at the given index, zero-extends it to type int, and returns the result,
|
||||
* which is therefore in the range 0 through 255.
|
||||
*
|
||||
* @param j The index from which the byte will be read.
|
||||
* @return the unsigned 8-bit at the given index.
|
||||
*/
|
||||
public int getAsUnsigned(int j) {
|
||||
return (int) get(j) & 0xFF;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
|
||||
/**
|
||||
* Class that holds shared constants
|
||||
*/
|
||||
public class Constants {
|
||||
// Java doesn't seem to have these.
|
||||
/** The number of bytes in an `byte`. */
|
||||
static final int SIZEOF_BYTE = 1;
|
||||
/** The number of bytes in a `short`. */
|
||||
static final int SIZEOF_SHORT = 2;
|
||||
/** The number of bytes in an `int`. */
|
||||
static final int SIZEOF_INT = 4;
|
||||
/** The number of bytes in an `float`. */
|
||||
static final int SIZEOF_FLOAT = 4;
|
||||
/** The number of bytes in an `long`. */
|
||||
static final int SIZEOF_LONG = 8;
|
||||
/** The number of bytes in an `double`. */
|
||||
static final int SIZEOF_DOUBLE = 8;
|
||||
/** The number of bytes in a file identifier. */
|
||||
static final int FILE_IDENTIFIER_LENGTH = 4;
|
||||
/** The number of bytes in a size prefix. */
|
||||
public static final int SIZE_PREFIX_LENGTH = 4;
|
||||
/** A version identifier to force a compile error if someone
|
||||
accidentally tries to build generated code with a runtime of
|
||||
two mismatched version. Versions need to always match, as
|
||||
the runtime and generated code are modified in sync.
|
||||
Changes to the Java implementation need to be sure to change
|
||||
the version here and in the code generator on every possible
|
||||
incompatible change */
|
||||
public static void FLATBUFFERS_24_3_25() {}
|
||||
}
|
||||
|
||||
/// @endcond
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of double values.
|
||||
*/
|
||||
public final class DoubleVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public DoubleVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_DOUBLE, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the double value at the given index.
|
||||
*
|
||||
* @param j The index from which the double value will be read.
|
||||
* @return the double value at the given index.
|
||||
*/
|
||||
public double get(int j) {
|
||||
return bb.getDouble(__element(j));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,802 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.google.flatbuffers.FlexBuffers.*;
|
||||
import static com.google.flatbuffers.FlexBuffers.Unsigned.byteToUnsignedInt;
|
||||
import static com.google.flatbuffers.FlexBuffers.Unsigned.intToUnsignedLong;
|
||||
import static com.google.flatbuffers.FlexBuffers.Unsigned.shortToUnsignedInt;
|
||||
|
||||
/// @file
|
||||
/// @addtogroup flatbuffers_java_api
|
||||
/// @{
|
||||
|
||||
/**
|
||||
* Helper class that builds FlexBuffers
|
||||
* <p> This class presents all necessary APIs to create FlexBuffers. A `ByteBuffer` will be used to store the
|
||||
* data. It can be created internally, or passed down in the constructor.</p>
|
||||
*
|
||||
* <p>There are some limitations when compared to original implementation in C++. Most notably:
|
||||
* <ul>
|
||||
* <li><p> No support for mutations (might change in the future).</p></li>
|
||||
* <li><p> Buffer size limited to {@link Integer#MAX_VALUE}</p></li>
|
||||
* <li><p> Since Java does not support unsigned type, all unsigned operations accepts an immediate higher representation
|
||||
* of similar type.</p></li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*/
|
||||
public class FlexBuffersBuilder {
|
||||
|
||||
/**
|
||||
* No keys or strings will be shared
|
||||
*/
|
||||
public static final int BUILDER_FLAG_NONE = 0;
|
||||
/**
|
||||
* Keys will be shared between elements. Identical keys will only be serialized once, thus possibly saving space.
|
||||
* But serialization performance might be slower and consumes more memory.
|
||||
*/
|
||||
public static final int BUILDER_FLAG_SHARE_KEYS = 1;
|
||||
/**
|
||||
* Strings will be shared between elements. Identical strings will only be serialized once, thus possibly saving space.
|
||||
* But serialization performance might be slower and consumes more memory. This is ideal if you expect many repeated
|
||||
* strings on the message.
|
||||
*/
|
||||
public static final int BUILDER_FLAG_SHARE_STRINGS = 2;
|
||||
/**
|
||||
* Strings and keys will be shared between elements.
|
||||
*/
|
||||
public static final int BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3;
|
||||
/**
|
||||
* Reserved for the future.
|
||||
*/
|
||||
public static final int BUILDER_FLAG_SHARE_KEY_VECTORS = 4;
|
||||
/**
|
||||
* Reserved for the future.
|
||||
*/
|
||||
public static final int BUILDER_FLAG_SHARE_ALL = 7;
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
private static final int WIDTH_8 = 0;
|
||||
private static final int WIDTH_16 = 1;
|
||||
private static final int WIDTH_32 = 2;
|
||||
private static final int WIDTH_64 = 3;
|
||||
private final ReadWriteBuf bb;
|
||||
private final ArrayList<Value> stack = new ArrayList<>();
|
||||
private final HashMap<String, Integer> keyPool = new HashMap<>();
|
||||
private final HashMap<String, Integer> stringPool = new HashMap<>();
|
||||
private final int flags;
|
||||
private boolean finished = false;
|
||||
|
||||
// A lambda to sort map keys
|
||||
private Comparator<Value> keyComparator = new Comparator<Value>() {
|
||||
@Override
|
||||
public int compare(Value o1, Value o2) {
|
||||
int ia = o1.key;
|
||||
int io = o2.key;
|
||||
byte c1, c2;
|
||||
do {
|
||||
c1 = bb.get(ia);
|
||||
c2 = bb.get(io);
|
||||
if (c1 == 0)
|
||||
return c1 - c2;
|
||||
ia++;
|
||||
io++;
|
||||
}
|
||||
while (c1 == c2);
|
||||
return c1 - c2;
|
||||
}
|
||||
};
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
* Constructs a newly allocated {@code FlexBuffersBuilder} with {@link #BUILDER_FLAG_SHARE_KEYS} set.
|
||||
* @param bufSize size of buffer in bytes.
|
||||
*/
|
||||
public FlexBuffersBuilder(int bufSize) {
|
||||
this(new ArrayReadWriteBuf(bufSize), BUILDER_FLAG_SHARE_KEYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a newly allocated {@code FlexBuffersBuilder} with {@link #BUILDER_FLAG_SHARE_KEYS} set.
|
||||
*/
|
||||
public FlexBuffersBuilder() {
|
||||
this(256);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a newly allocated {@code FlexBuffersBuilder}.
|
||||
*
|
||||
* @param bb `ByteBuffer` that will hold the message
|
||||
* @param flags Share flags
|
||||
*/
|
||||
@Deprecated
|
||||
public FlexBuffersBuilder(ByteBuffer bb, int flags) {
|
||||
this(new ArrayReadWriteBuf(bb.array()), flags);
|
||||
}
|
||||
|
||||
public FlexBuffersBuilder(ReadWriteBuf bb, int flags) {
|
||||
this.bb = bb;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a newly allocated {@code FlexBuffersBuilder}.
|
||||
* By default same keys will be serialized only once
|
||||
* @param bb `ByteBuffer` that will hold the message
|
||||
*/
|
||||
public FlexBuffersBuilder(ByteBuffer bb) {
|
||||
this(bb, BUILDER_FLAG_SHARE_KEYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the FlexBuffersBuilder by purging all data that it holds.
|
||||
*/
|
||||
public void clear(){
|
||||
bb.clear();
|
||||
stack.clear();
|
||||
keyPool.clear();
|
||||
stringPool.clear();
|
||||
finished = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return `ByteBuffer` containing FlexBuffer message. {@code #finish()} must be called before calling this
|
||||
* function otherwise an assert will trigger.
|
||||
*
|
||||
* @return `ByteBuffer` with finished message
|
||||
*/
|
||||
public ReadWriteBuf getBuffer() {
|
||||
assert (finished);
|
||||
return bb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a null value into the buffer
|
||||
*/
|
||||
public void putNull() {
|
||||
putNull(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a null value into the buffer
|
||||
* @param key key used to store element in map
|
||||
*/
|
||||
public void putNull(String key) {
|
||||
stack.add(Value.nullValue(putKey(key)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single boolean into the buffer
|
||||
* @param val true or false
|
||||
*/
|
||||
public void putBoolean(boolean val) {
|
||||
putBoolean(null, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a single boolean into the buffer
|
||||
* @param key key used to store element in map
|
||||
* @param val true or false
|
||||
*/
|
||||
public void putBoolean(String key, boolean val) {
|
||||
stack.add(Value.bool(putKey(key), val));
|
||||
}
|
||||
|
||||
private int putKey(String key) {
|
||||
if (key == null) {
|
||||
return -1;
|
||||
}
|
||||
int pos = bb.writePosition();
|
||||
if ((flags & BUILDER_FLAG_SHARE_KEYS) != 0) {
|
||||
Integer keyFromPool = keyPool.get(key);
|
||||
if (keyFromPool == null) {
|
||||
byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8);
|
||||
bb.put(keyBytes, 0, keyBytes.length);
|
||||
bb.put((byte) 0);
|
||||
keyPool.put(key, pos);
|
||||
} else {
|
||||
pos = keyFromPool;
|
||||
}
|
||||
} else {
|
||||
byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8);
|
||||
bb.put(keyBytes, 0, keyBytes.length);
|
||||
bb.put((byte) 0);
|
||||
keyPool.put(key, pos);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a integer into the buff
|
||||
* @param val integer
|
||||
*/
|
||||
public void putInt(int val) {
|
||||
putInt(null, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a integer into the buff
|
||||
* @param key key used to store element in map
|
||||
* @param val integer
|
||||
*/
|
||||
public void putInt(String key, int val) {
|
||||
putInt(key, (long) val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a integer into the buff
|
||||
* @param key key used to store element in map
|
||||
* @param val 64-bit integer
|
||||
*/
|
||||
public void putInt(String key, long val) {
|
||||
int iKey = putKey(key);
|
||||
if (Byte.MIN_VALUE <= val && val <= Byte.MAX_VALUE) {
|
||||
stack.add(Value.int8(iKey, (int) val));
|
||||
} else if (Short.MIN_VALUE <= val && val <= Short.MAX_VALUE) {
|
||||
stack.add(Value.int16(iKey, (int) val));
|
||||
} else if (Integer.MIN_VALUE <= val && val <= Integer.MAX_VALUE) {
|
||||
stack.add(Value.int32(iKey, (int) val));
|
||||
} else {
|
||||
stack.add(Value.int64(iKey, val));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 64-bit integer into the buff
|
||||
* @param value integer
|
||||
*/
|
||||
public void putInt(long value) {
|
||||
putInt(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a unsigned integer into the buff.
|
||||
* @param value integer representing unsigned value
|
||||
*/
|
||||
public void putUInt(int value) {
|
||||
putUInt(null, (long) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a unsigned integer (stored in a signed 64-bit integer) into the buff.
|
||||
* @param value integer representing unsigned value
|
||||
*/
|
||||
public void putUInt(long value) {
|
||||
putUInt(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 64-bit unsigned integer (stored as {@link BigInteger}) into the buff.
|
||||
* Warning: This operation might be very slow.
|
||||
* @param value integer representing unsigned value
|
||||
*/
|
||||
public void putUInt64(BigInteger value) {
|
||||
putUInt64(null, value.longValue());
|
||||
}
|
||||
|
||||
private void putUInt64(String key, long value) {
|
||||
stack.add(Value.uInt64(putKey(key), value));
|
||||
}
|
||||
|
||||
private void putUInt(String key, long value) {
|
||||
int iKey = putKey(key);
|
||||
Value vVal;
|
||||
|
||||
int width = widthUInBits(value);
|
||||
|
||||
if (width == WIDTH_8) {
|
||||
vVal = Value.uInt8(iKey, (int)value);
|
||||
} else if (width == WIDTH_16) {
|
||||
vVal = Value.uInt16(iKey, (int)value);
|
||||
} else if (width == WIDTH_32) {
|
||||
vVal = Value.uInt32(iKey, (int)value);
|
||||
} else {
|
||||
vVal = Value.uInt64(iKey, value);
|
||||
}
|
||||
stack.add(vVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 32-bit float into the buff.
|
||||
* @param value float representing value
|
||||
*/
|
||||
public void putFloat(float value) {
|
||||
putFloat(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 32-bit float into the buff.
|
||||
* @param key key used to store element in map
|
||||
* @param value float representing value
|
||||
*/
|
||||
public void putFloat(String key, float val) {
|
||||
stack.add(Value.float32(putKey(key), val));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 64-bit float into the buff.
|
||||
* @param value float representing value
|
||||
*/
|
||||
public void putFloat(double value) {
|
||||
putFloat(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a 64-bit float into the buff.
|
||||
* @param key key used to store element in map
|
||||
* @param value float representing value
|
||||
*/
|
||||
public void putFloat(String key, double val) {
|
||||
stack.add(Value.float64(putKey(key), val));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a String into the buffer
|
||||
* @param value string
|
||||
* @return start position of string in the buffer
|
||||
*/
|
||||
public int putString(String value) {
|
||||
return putString(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a String into the buffer
|
||||
* @param key key used to store element in map
|
||||
* @param value string
|
||||
* @return start position of string in the buffer
|
||||
*/
|
||||
public int putString(String key, String val) {
|
||||
int iKey = putKey(key);
|
||||
if ((flags & FlexBuffersBuilder.BUILDER_FLAG_SHARE_STRINGS) != 0) {
|
||||
Integer i = stringPool.get(val);
|
||||
if (i == null) {
|
||||
Value value = writeString(iKey, val);
|
||||
stringPool.put(val, (int) value.iValue);
|
||||
stack.add(value);
|
||||
return (int) value.iValue;
|
||||
} else {
|
||||
int bitWidth = widthUInBits(val.length());
|
||||
stack.add(Value.blob(iKey, i, FBT_STRING, bitWidth));
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
Value value = writeString(iKey, val);
|
||||
stack.add(value);
|
||||
return (int) value.iValue;
|
||||
}
|
||||
}
|
||||
|
||||
private Value writeString(int key, String s) {
|
||||
return writeBlob(key, s.getBytes(StandardCharsets.UTF_8), FBT_STRING, true);
|
||||
}
|
||||
|
||||
// in bits to fit a unsigned int
|
||||
static int widthUInBits(long len) {
|
||||
if (len <= byteToUnsignedInt((byte)0xff)) return WIDTH_8;
|
||||
if (len <= shortToUnsignedInt((short)0xffff)) return WIDTH_16;
|
||||
if (len <= intToUnsignedLong(0xffff_ffff)) return WIDTH_32;
|
||||
return WIDTH_64;
|
||||
}
|
||||
|
||||
private Value writeBlob(int key, byte[] blob, int type, boolean trailing) {
|
||||
int bitWidth = widthUInBits(blob.length);
|
||||
int byteWidth = align(bitWidth);
|
||||
writeInt(blob.length, byteWidth);
|
||||
int sloc = bb.writePosition();
|
||||
bb.put(blob, 0, blob.length);
|
||||
if (trailing) {
|
||||
bb.put((byte) 0);
|
||||
}
|
||||
return Value.blob(key, sloc, type, bitWidth);
|
||||
}
|
||||
|
||||
// Align to prepare for writing a scalar with a certain size.
|
||||
private int align(int alignment) {
|
||||
int byteWidth = 1 << alignment;
|
||||
int padBytes = Value.paddingBytes(bb.writePosition(), byteWidth);
|
||||
while (padBytes-- != 0) {
|
||||
bb.put((byte) 0);
|
||||
}
|
||||
return byteWidth;
|
||||
}
|
||||
|
||||
private void writeInt(long value, int byteWidth) {
|
||||
switch (byteWidth) {
|
||||
case 1: bb.put((byte) value); break;
|
||||
case 2: bb.putShort((short) value); break;
|
||||
case 4: bb.putInt((int) value); break;
|
||||
case 8: bb.putLong(value); break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a byte array into the message
|
||||
* @param value byte array
|
||||
* @return position in buffer as the start of byte array
|
||||
*/
|
||||
public int putBlob(byte[] value) {
|
||||
return putBlob(null, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a byte array into the message
|
||||
* @param key key used to store element in map
|
||||
* @param value byte array
|
||||
* @return position in buffer as the start of byte array
|
||||
*/
|
||||
public int putBlob(String key, byte[] val) {
|
||||
int iKey = putKey(key);
|
||||
Value value = writeBlob(iKey, val, FBT_BLOB, false);
|
||||
stack.add(value);
|
||||
return (int) value.iValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new vector in the buffer.
|
||||
* @return a reference indicating position of the vector in buffer. This
|
||||
* reference must be passed along when the vector is finished using endVector()
|
||||
*/
|
||||
public int startVector() {
|
||||
return stack.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes a vector, but writing the information in the buffer
|
||||
* @param key key used to store element in map
|
||||
* @param start reference for beginning of the vector. Returned by {@link startVector()}
|
||||
* @param typed boolean indicating whether vector is typed
|
||||
* @param fixed boolean indicating whether vector is fixed
|
||||
* @return Reference to the vector
|
||||
*/
|
||||
public int endVector(String key, int start, boolean typed, boolean fixed) {
|
||||
int iKey = putKey(key);
|
||||
Value vec = createVector(iKey, start, stack.size() - start, typed, fixed, null);
|
||||
// Remove temp elements and return vector.
|
||||
while (stack.size() > start) {
|
||||
stack.remove(stack.size() - 1);
|
||||
}
|
||||
stack.add(vec);
|
||||
return (int) vec.iValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish writing the message into the buffer. After that no other element must
|
||||
* be inserted into the buffer. Also, you must call this function before start using the
|
||||
* FlexBuffer message
|
||||
* @return `ByteBuffer` containing the FlexBuffer message
|
||||
*/
|
||||
public ByteBuffer finish() {
|
||||
// If you hit this assert, you likely have objects that were never included
|
||||
// in a parent. You need to have exactly one root to finish a buffer.
|
||||
// Check your Start/End calls are matched, and all objects are inside
|
||||
// some other object.
|
||||
assert (stack.size() == 1);
|
||||
// Write root value.
|
||||
int byteWidth = align(stack.get(0).elemWidth(bb.writePosition(), 0));
|
||||
writeAny(stack.get(0), byteWidth);
|
||||
// Write root type.
|
||||
bb.put(stack.get(0).storedPackedType());
|
||||
// Write root size. Normally determined by parent, but root has no parent :)
|
||||
bb.put((byte) byteWidth);
|
||||
this.finished = true;
|
||||
return ByteBuffer.wrap(bb.data(), 0, bb.writePosition());
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a vector based on the elements stored in the stack
|
||||
*
|
||||
* @param key reference to its key
|
||||
* @param start element in the stack
|
||||
* @param length size of the vector
|
||||
* @param typed whether is TypedVector or not
|
||||
* @param fixed whether is Fixed vector or not
|
||||
* @param keys Value representing key vector
|
||||
* @return Value representing the created vector
|
||||
*/
|
||||
private Value createVector(int key, int start, int length, boolean typed, boolean fixed, Value keys) {
|
||||
if (fixed & !typed)
|
||||
throw new UnsupportedOperationException("Untyped fixed vector is not supported");
|
||||
|
||||
// Figure out smallest bit width we can store this vector with.
|
||||
int bitWidth = Math.max(WIDTH_8, widthUInBits(length));
|
||||
int prefixElems = 1;
|
||||
if (keys != null) {
|
||||
// If this vector is part of a map, we will pre-fix an offset to the keys
|
||||
// to this vector.
|
||||
bitWidth = Math.max(bitWidth, keys.elemWidth(bb.writePosition(), 0));
|
||||
prefixElems += 2;
|
||||
}
|
||||
int vectorType = FBT_KEY;
|
||||
// Check bit widths and types for all elements.
|
||||
for (int i = start; i < stack.size(); i++) {
|
||||
int elemWidth = stack.get(i).elemWidth(bb.writePosition(), i + prefixElems);
|
||||
bitWidth = Math.max(bitWidth, elemWidth);
|
||||
if (typed) {
|
||||
if (i == start) {
|
||||
vectorType = stack.get(i).type;
|
||||
if (!FlexBuffers.isTypedVectorElementType(vectorType)) {
|
||||
throw new FlexBufferException("TypedVector does not support this element type");
|
||||
}
|
||||
} else {
|
||||
// If you get this assert, you are writing a typed vector with
|
||||
// elements that are not all the same type.
|
||||
assert (vectorType == stack.get(i).type);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If you get this assert, your fixed types are not one of:
|
||||
// Int / UInt / Float / Key.
|
||||
assert (!fixed || FlexBuffers.isTypedVectorElementType(vectorType));
|
||||
|
||||
int byteWidth = align(bitWidth);
|
||||
// Write vector. First the keys width/offset if available, and size.
|
||||
if (keys != null) {
|
||||
writeOffset(keys.iValue, byteWidth);
|
||||
writeInt(1L << keys.minBitWidth, byteWidth);
|
||||
}
|
||||
if (!fixed) {
|
||||
writeInt(length, byteWidth);
|
||||
}
|
||||
// Then the actual data.
|
||||
int vloc = bb.writePosition();
|
||||
for (int i = start; i < stack.size(); i++) {
|
||||
writeAny(stack.get(i), byteWidth);
|
||||
}
|
||||
// Then the types.
|
||||
if (!typed) {
|
||||
for (int i = start; i < stack.size(); i++) {
|
||||
bb.put(stack.get(i).storedPackedType(bitWidth));
|
||||
}
|
||||
}
|
||||
return new Value(key, keys != null ? FBT_MAP
|
||||
: (typed ? FlexBuffers.toTypedVector(vectorType, fixed ? length : 0)
|
||||
: FBT_VECTOR), bitWidth, vloc);
|
||||
}
|
||||
|
||||
private void writeOffset(long val, int byteWidth) {
|
||||
int reloff = (int) (bb.writePosition() - val);
|
||||
assert (byteWidth == 8 || reloff < 1L << (byteWidth * 8));
|
||||
writeInt(reloff, byteWidth);
|
||||
}
|
||||
|
||||
private void writeAny(final Value val, int byteWidth) {
|
||||
switch (val.type) {
|
||||
case FBT_NULL:
|
||||
case FBT_BOOL:
|
||||
case FBT_INT:
|
||||
case FBT_UINT:
|
||||
writeInt(val.iValue, byteWidth);
|
||||
break;
|
||||
case FBT_FLOAT:
|
||||
writeDouble(val.dValue, byteWidth);
|
||||
break;
|
||||
default:
|
||||
writeOffset(val.iValue, byteWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeDouble(double val, int byteWidth) {
|
||||
if (byteWidth == 4) {
|
||||
bb.putFloat((float) val);
|
||||
} else if (byteWidth == 8) {
|
||||
bb.putDouble(val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new map in the buffer.
|
||||
* @return a reference indicating position of the map in buffer. This
|
||||
* reference must be passed along when the map is finished using endMap()
|
||||
*/
|
||||
public int startMap() {
|
||||
return stack.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes a map, but writing the information in the buffer
|
||||
* @param key key used to store element in map
|
||||
* @param start reference for beginning of the map. Returned by {@link startMap()}
|
||||
* @return Reference to the map
|
||||
*/
|
||||
public int endMap(String key, int start) {
|
||||
int iKey = putKey(key);
|
||||
|
||||
Collections.sort(stack.subList(start, stack.size()), keyComparator);
|
||||
|
||||
Value keys = createKeyVector(start, stack.size() - start);
|
||||
Value vec = createVector(iKey, start, stack.size() - start, false, false, keys);
|
||||
// Remove temp elements and return map.
|
||||
while (stack.size() > start) {
|
||||
stack.remove(stack.size() - 1);
|
||||
}
|
||||
stack.add(vec);
|
||||
return (int) vec.iValue;
|
||||
}
|
||||
|
||||
private Value createKeyVector(int start, int length) {
|
||||
// Figure out smallest bit width we can store this vector with.
|
||||
int bitWidth = Math.max(WIDTH_8, widthUInBits(length));
|
||||
int prefixElems = 1;
|
||||
// Check bit widths and types for all elements.
|
||||
for (int i = start; i < stack.size(); i++) {
|
||||
int elemWidth = Value.elemWidth(FBT_KEY, WIDTH_8, stack.get(i).key, bb.writePosition(), i + prefixElems);
|
||||
bitWidth = Math.max(bitWidth, elemWidth);
|
||||
}
|
||||
|
||||
int byteWidth = align(bitWidth);
|
||||
// Write vector. First the keys width/offset if available, and size.
|
||||
writeInt(length, byteWidth);
|
||||
// Then the actual data.
|
||||
int vloc = bb.writePosition();
|
||||
for (int i = start; i < stack.size(); i++) {
|
||||
int pos = stack.get(i).key;
|
||||
assert(pos != -1);
|
||||
writeOffset(stack.get(i).key, byteWidth);
|
||||
}
|
||||
// Then the types.
|
||||
return new Value(-1, FlexBuffers.toTypedVector(FBT_KEY,0), bitWidth, vloc);
|
||||
}
|
||||
|
||||
private static class Value {
|
||||
final int type;
|
||||
// for scalars, represents scalar size in bytes
|
||||
// for vectors, represents the size
|
||||
// for string, length
|
||||
final int minBitWidth;
|
||||
// float value
|
||||
final double dValue;
|
||||
// integer value
|
||||
long iValue;
|
||||
// position of the key associated with this value in buffer
|
||||
int key;
|
||||
|
||||
Value(int key, int type, int bitWidth, long iValue) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.minBitWidth = bitWidth;
|
||||
this.iValue = iValue;
|
||||
this.dValue = Double.MIN_VALUE;
|
||||
}
|
||||
|
||||
Value(int key, int type, int bitWidth, double dValue) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.minBitWidth = bitWidth;
|
||||
this.dValue = dValue;
|
||||
this.iValue = Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
static Value nullValue(int key) {
|
||||
return new Value(key, FBT_NULL, WIDTH_8, 0);
|
||||
}
|
||||
|
||||
static Value bool(int key, boolean b) {
|
||||
return new Value(key, FBT_BOOL, WIDTH_8, b ? 1 : 0);
|
||||
}
|
||||
|
||||
static Value blob(int key, int position, int type, int bitWidth) {
|
||||
return new Value(key, type, bitWidth, position);
|
||||
}
|
||||
|
||||
static Value int8(int key, int value) {
|
||||
return new Value(key, FBT_INT, WIDTH_8, value);
|
||||
}
|
||||
|
||||
static Value int16(int key, int value) {
|
||||
return new Value(key, FBT_INT, WIDTH_16, value);
|
||||
}
|
||||
|
||||
static Value int32(int key, int value) {
|
||||
return new Value(key, FBT_INT, WIDTH_32, value);
|
||||
}
|
||||
|
||||
static Value int64(int key, long value) {
|
||||
return new Value(key, FBT_INT, WIDTH_64, value);
|
||||
}
|
||||
|
||||
static Value uInt8(int key, int value) {
|
||||
return new Value(key, FBT_UINT, WIDTH_8, value);
|
||||
}
|
||||
|
||||
static Value uInt16(int key, int value) {
|
||||
return new Value(key, FBT_UINT, WIDTH_16, value);
|
||||
}
|
||||
|
||||
static Value uInt32(int key, int value) {
|
||||
return new Value(key, FBT_UINT, WIDTH_32, value);
|
||||
}
|
||||
|
||||
static Value uInt64(int key, long value) {
|
||||
return new Value(key, FBT_UINT, WIDTH_64, value);
|
||||
}
|
||||
|
||||
static Value float32(int key, float value) {
|
||||
return new Value(key, FBT_FLOAT, WIDTH_32, value);
|
||||
}
|
||||
|
||||
static Value float64(int key, double value) {
|
||||
return new Value(key, FBT_FLOAT, WIDTH_64, value);
|
||||
}
|
||||
|
||||
private byte storedPackedType() {
|
||||
return storedPackedType(WIDTH_8);
|
||||
}
|
||||
|
||||
private byte storedPackedType(int parentBitWidth) {
|
||||
return packedType(storedWidth(parentBitWidth), type);
|
||||
}
|
||||
|
||||
private static byte packedType(int bitWidth, int type) {
|
||||
return (byte) (bitWidth | (type << 2));
|
||||
}
|
||||
|
||||
private int storedWidth(int parentBitWidth) {
|
||||
if (FlexBuffers.isTypeInline(type)) {
|
||||
return Math.max(minBitWidth, parentBitWidth);
|
||||
} else {
|
||||
return minBitWidth;
|
||||
}
|
||||
}
|
||||
|
||||
private int elemWidth(int bufSize, int elemIndex) {
|
||||
return elemWidth(type, minBitWidth, iValue, bufSize, elemIndex);
|
||||
}
|
||||
|
||||
private static int elemWidth(int type, int minBitWidth, long iValue, int bufSize, int elemIndex) {
|
||||
if (FlexBuffers.isTypeInline(type)) {
|
||||
return minBitWidth;
|
||||
} else {
|
||||
// We have an absolute offset, but want to store a relative offset
|
||||
// elem_index elements beyond the current buffer end. Since whether
|
||||
// the relative offset fits in a certain byte_width depends on
|
||||
// the size of the elements before it (and their alignment), we have
|
||||
// to test for each size in turn.
|
||||
|
||||
// Original implementation checks for largest scalar
|
||||
// which is long unsigned int
|
||||
for (int byteWidth = 1; byteWidth <= 32; byteWidth *= 2) {
|
||||
// Where are we going to write this offset?
|
||||
int offsetLoc = bufSize + paddingBytes(bufSize, byteWidth) + (elemIndex * byteWidth);
|
||||
// Compute relative offset.
|
||||
long offset = offsetLoc - iValue;
|
||||
// Does it fit?
|
||||
int bitWidth = widthUInBits(offset);
|
||||
if (((1L) << bitWidth) == byteWidth)
|
||||
return bitWidth;
|
||||
}
|
||||
assert (false); // Must match one of the sizes above.
|
||||
return WIDTH_64;
|
||||
}
|
||||
}
|
||||
|
||||
private static int paddingBytes(int bufSize, int scalarSize) {
|
||||
return ((~bufSize) + 1) & (scalarSize - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of float values.
|
||||
*/
|
||||
public final class FloatVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public FloatVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_FLOAT, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the float value at the given index.
|
||||
*
|
||||
* @param j The index from which the float value will be read.
|
||||
* @return the float value at the given index.
|
||||
*/
|
||||
public float get(int j) {
|
||||
return bb.getFloat(__element(j));
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of signed or unsigned 32-bit values.
|
||||
*/
|
||||
public final class IntVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public IntVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_INT, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the integer at the given index.
|
||||
*
|
||||
* @param j The index from which the integer will be read.
|
||||
* @return the 32-bit value at the given index.
|
||||
*/
|
||||
public int get(int j) {
|
||||
return bb.getInt(__element(j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the integer at the given index, zero-extends it to type long, and returns the result,
|
||||
* which is therefore in the range 0 through 4294967295.
|
||||
*
|
||||
* @param j The index from which the integer will be read.
|
||||
* @return the unsigned 32-bit at the given index.
|
||||
*/
|
||||
public long getAsUnsigned(int j) {
|
||||
return (long) get(j) & 0xFFFFFFFFL;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of long values.
|
||||
*/
|
||||
public final class LongVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public LongVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_LONG, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the long value at the given index.
|
||||
*
|
||||
* @param j The index from which the long value will be read.
|
||||
* @return the signed 64-bit value at the given index.
|
||||
*/
|
||||
public long get(int j) {
|
||||
return bb.getLong(__element(j));
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.google.flatbuffers;
|
||||
|
||||
/**
|
||||
* Represent a chunk of data, where FlexBuffers will read from.
|
||||
*/
|
||||
public interface ReadBuf {
|
||||
|
||||
/**
|
||||
* Read boolean from data. Booleans as stored as single byte
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return boolean element
|
||||
*/
|
||||
boolean getBoolean(int index);
|
||||
|
||||
/**
|
||||
* Read a byte from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a byte
|
||||
*/
|
||||
byte get(int index);
|
||||
|
||||
/**
|
||||
* Read a short from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a short
|
||||
*/
|
||||
short getShort(int index);
|
||||
|
||||
/**
|
||||
* Read a 32-bit int from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return an int
|
||||
*/
|
||||
int getInt(int index);
|
||||
|
||||
/**
|
||||
* Read a 64-bit long from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a long
|
||||
*/
|
||||
long getLong(int index);
|
||||
|
||||
/**
|
||||
* Read a 32-bit float from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a float
|
||||
*/
|
||||
float getFloat(int index);
|
||||
|
||||
/**
|
||||
* Read a 64-bit float from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a double
|
||||
*/
|
||||
double getDouble(int index);
|
||||
|
||||
/**
|
||||
* Read an UTF-8 string from data.
|
||||
* @param start initial element of the string
|
||||
* @param size size of the string in bytes.
|
||||
* @return a {@code String}
|
||||
*/
|
||||
String getString(int start, int size);
|
||||
|
||||
/**
|
||||
* Expose ReadBuf as an array of bytes.
|
||||
* This method is meant to be as efficient as possible, so for a array-backed ReadBuf, it should
|
||||
* return its own internal data. In case access to internal data is not possible,
|
||||
* a copy of the data into an array of bytes might occur.
|
||||
* @return ReadBuf as an array of bytes
|
||||
*/
|
||||
byte[] data();
|
||||
|
||||
/**
|
||||
* Defines the size of the message in the buffer. It also determines last position that buffer
|
||||
* can be read. Last byte to be accessed is in position {@code limit() -1}.
|
||||
* @return indicate last position
|
||||
*/
|
||||
int limit();
|
||||
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
package com.google.flatbuffers;
|
||||
|
||||
/**
|
||||
* Interface to represent a read-write buffer. This interface will be used to access and write
|
||||
* FlexBuffers message.
|
||||
*/
|
||||
public interface ReadWriteBuf extends ReadBuf {
|
||||
|
||||
/**
|
||||
* Clears (resets) the buffer so that it can be reused. Write position will be set to the
|
||||
* start.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Put a boolean into the buffer at {@code writePosition()} . Booleans as stored as single
|
||||
* byte. Write position will be incremented.
|
||||
* @return boolean element
|
||||
*/
|
||||
void putBoolean(boolean value);
|
||||
|
||||
/**
|
||||
* Put an array of bytes into the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
* @param value the data to be copied
|
||||
* @param start initial position on value to be copied
|
||||
* @param length amount of bytes to be copied
|
||||
*/
|
||||
void put (byte[] value, int start, int length);
|
||||
|
||||
/**
|
||||
* Write a byte into the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void put(byte value);
|
||||
|
||||
/**
|
||||
* Write a 16-bit into in the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void putShort(short value);
|
||||
|
||||
/**
|
||||
* Write a 32-bit into in the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void putInt(int value);
|
||||
|
||||
/**
|
||||
* Write a 64-bit into in the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void putLong(long value);
|
||||
|
||||
/**
|
||||
* Write a 32-bit float into the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void putFloat(float value);
|
||||
|
||||
/**
|
||||
* Write a 64-bit float into the buffer at {@code writePosition()}. Write position will be
|
||||
* incremented.
|
||||
*/
|
||||
void putDouble(double value);
|
||||
|
||||
/**
|
||||
* Write boolean into a given position on the buffer. Booleans as stored as single byte.
|
||||
* @param index position of the element in buffer
|
||||
*/
|
||||
void setBoolean(int index, boolean value);
|
||||
|
||||
/**
|
||||
* Read a byte from data.
|
||||
* @param index position of the element in the buffer
|
||||
* @return a byte
|
||||
*/
|
||||
void set(int index, byte value);
|
||||
|
||||
/**
|
||||
* Write an array of bytes into the buffer.
|
||||
* @param index initial position of the buffer to be written
|
||||
* @param value the data to be copied
|
||||
* @param start initial position on value to be copied
|
||||
* @param length amount of bytes to be copied
|
||||
*/
|
||||
void set(int index, byte[] value, int start, int length);
|
||||
|
||||
/**
|
||||
* Read a short from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a short
|
||||
*/
|
||||
void setShort(int index, short value);
|
||||
|
||||
/**
|
||||
* Read a 32-bit int from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return an int
|
||||
*/
|
||||
void setInt(int index, int value);
|
||||
|
||||
/**
|
||||
* Read a 64-bit long from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a long
|
||||
*/
|
||||
void setLong(int index, long value);
|
||||
|
||||
/**
|
||||
* Read a 32-bit float from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a float
|
||||
*/
|
||||
void setFloat(int index, float value);
|
||||
|
||||
/**
|
||||
* Read a 64-bit float from data.
|
||||
* @param index position of the element in ReadBuf
|
||||
* @return a double
|
||||
*/
|
||||
void setDouble(int index, double value);
|
||||
|
||||
|
||||
int writePosition();
|
||||
/**
|
||||
* Defines the size of the message in the buffer. It also determines last position that buffer
|
||||
* can be read or write. Last byte to be accessed is in position {@code limit() -1}.
|
||||
* @return indicate last position
|
||||
*/
|
||||
int limit();
|
||||
|
||||
/**
|
||||
* Request capacity of the buffer. In case buffer is already larger
|
||||
* than the requested, this method will just return true. Otherwise
|
||||
* It might try to resize the buffer.
|
||||
*
|
||||
* @return true if buffer is able to offer
|
||||
* the requested capacity
|
||||
*/
|
||||
boolean requestCapacity(int capacity);
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of signed or unsigned 16-bit values.
|
||||
*/
|
||||
public final class ShortVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public ShortVector __assign(int _vector, ByteBuffer _bb) {
|
||||
__reset(_vector, Constants.SIZEOF_SHORT, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the short value at the given index.
|
||||
*
|
||||
* @param j The index from which the short value will be read.
|
||||
* @return the 16-bit value at the given index.
|
||||
*/
|
||||
public short get(int j) {
|
||||
return bb.getShort(__element(j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the short at the given index, zero-extends it to type int, and returns the result,
|
||||
* which is therefore in the range 0 through 65535.
|
||||
*
|
||||
* @param j The index from which the short value will be read.
|
||||
* @return the unsigned 16-bit at the given index.
|
||||
*/
|
||||
public int getAsUnsigned(int j) {
|
||||
return (int) get(j) & 0xFFFF;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of String.
|
||||
*/
|
||||
public final class StringVector extends BaseVector {
|
||||
private Utf8 utf8 = Utf8.getDefault();
|
||||
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _element_size Size of a vector element.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public StringVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
|
||||
__reset(_vector, _element_size, _bb); return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the String at the given index.
|
||||
*
|
||||
* @param j The index from which the String value will be read.
|
||||
* @return the String at the given index.
|
||||
*/
|
||||
public String get(int j) {
|
||||
return Table.__string(__element(j), bb, utf8);
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
|
||||
/**
|
||||
* All structs in the generated code derive from this class, and add their own accessors.
|
||||
*/
|
||||
public class Struct {
|
||||
/** Used to hold the position of the `bb` buffer. */
|
||||
protected int bb_pos;
|
||||
/** The underlying ByteBuffer to hold the data of the Struct. */
|
||||
protected ByteBuffer bb;
|
||||
|
||||
/**
|
||||
* Re-init the internal state with an external buffer {@code ByteBuffer} and an offset within.
|
||||
*
|
||||
* This method exists primarily to allow recycling Table instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references.
|
||||
*/
|
||||
protected void __reset(int _i, ByteBuffer _bb) {
|
||||
bb = _bb;
|
||||
if (bb != null) {
|
||||
bb_pos = _i;
|
||||
} else {
|
||||
bb_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets internal state with a null {@code ByteBuffer} and a zero position.
|
||||
*
|
||||
* This method exists primarily to allow recycling Struct instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references. The instance will be unusable until it is assigned
|
||||
* again to a {@code ByteBuffer}.
|
||||
*
|
||||
* @param struct the instance to reset to initial state
|
||||
*/
|
||||
public void __reset() {
|
||||
__reset(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// @endcond
|
@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/// @cond FLATBUFFERS_INTERNAL
|
||||
|
||||
/**
|
||||
* All tables in the generated code derive from this class, and add their own accessors.
|
||||
*/
|
||||
public class Table {
|
||||
/** Used to hold the position of the `bb` buffer. */
|
||||
protected int bb_pos;
|
||||
/** The underlying ByteBuffer to hold the data of the Table. */
|
||||
protected ByteBuffer bb;
|
||||
/** Used to hold the vtable position. */
|
||||
private int vtable_start;
|
||||
/** Used to hold the vtable size. */
|
||||
private int vtable_size;
|
||||
Utf8 utf8 = Utf8.getDefault();
|
||||
|
||||
/**
|
||||
* Get the underlying ByteBuffer.
|
||||
*
|
||||
* @return Returns the Table's ByteBuffer.
|
||||
*/
|
||||
public ByteBuffer getByteBuffer() { return bb; }
|
||||
|
||||
/**
|
||||
* Look up a field in the vtable.
|
||||
*
|
||||
* @param vtable_offset An `int` offset to the vtable in the Table's ByteBuffer.
|
||||
* @return Returns an offset into the object, or `0` if the field is not present.
|
||||
*/
|
||||
protected int __offset(int vtable_offset) {
|
||||
return vtable_offset < vtable_size ? bb.getShort(vtable_start + vtable_offset) : 0;
|
||||
}
|
||||
|
||||
protected static int __offset(int vtable_offset, int offset, ByteBuffer bb) {
|
||||
int vtable = bb.capacity() - offset;
|
||||
return bb.getShort(vtable + vtable_offset - bb.getInt(vtable)) + vtable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a relative offset.
|
||||
*
|
||||
* @param offset An `int` index into the Table's ByteBuffer containing the relative offset.
|
||||
* @return Returns the relative offset stored at `offset`.
|
||||
*/
|
||||
protected int __indirect(int offset) {
|
||||
return offset + bb.getInt(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a relative offset.
|
||||
*
|
||||
* @param offset An `int` index into a ByteBuffer containing the relative offset.
|
||||
* @param bb from which the relative offset will be retrieved.
|
||||
* @return Returns the relative offset stored at `offset`.
|
||||
*/
|
||||
protected static int __indirect(int offset, ByteBuffer bb) {
|
||||
return offset + bb.getInt(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Java `String` from UTF-8 data stored inside the FlatBuffer.
|
||||
*
|
||||
* This allocates a new string and converts to wide chars upon each access,
|
||||
* which is not very efficient. Instead, each FlatBuffer string also comes with an
|
||||
* accessor based on __vector_as_bytebuffer below, which is much more efficient,
|
||||
* assuming your Java program can handle UTF-8 data directly.
|
||||
*
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @return Returns a `String` from the data stored inside the FlatBuffer at `offset`.
|
||||
*/
|
||||
protected String __string(int offset) {
|
||||
return __string(offset, bb, utf8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Java `String` from UTF-8 data stored inside the FlatBuffer.
|
||||
*
|
||||
* This allocates a new string and converts to wide chars upon each access,
|
||||
* which is not very efficient. Instead, each FlatBuffer string also comes with an
|
||||
* accessor based on __vector_as_bytebuffer below, which is much more efficient,
|
||||
* assuming your Java program can handle UTF-8 data directly.
|
||||
*
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @param bb Table ByteBuffer used to read a string at given offset.
|
||||
* @param utf8 decoder that creates a Java `String` from UTF-8 characters.
|
||||
* @return Returns a `String` from the data stored inside the FlatBuffer at `offset`.
|
||||
*/
|
||||
protected static String __string(int offset, ByteBuffer bb, Utf8 utf8) {
|
||||
offset += bb.getInt(offset);
|
||||
int length = bb.getInt(offset);
|
||||
return utf8.decodeUtf8(bb, offset + SIZEOF_INT, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of a vector.
|
||||
*
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @return Returns the length of the vector whose offset is stored at `offset`.
|
||||
*/
|
||||
protected int __vector_len(int offset) {
|
||||
offset += bb_pos;
|
||||
offset += bb.getInt(offset);
|
||||
return bb.getInt(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the start data of a vector.
|
||||
*
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @return Returns the start of the vector data whose offset is stored at `offset`.
|
||||
*/
|
||||
protected int __vector(int offset) {
|
||||
offset += bb_pos;
|
||||
return offset + bb.getInt(offset) + SIZEOF_INT; // data starts after the length
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a whole vector as a ByteBuffer.
|
||||
*
|
||||
* This is efficient, since it only allocates a new {@link ByteBuffer} object,
|
||||
* but does not actually copy the data, it still refers to the same bytes
|
||||
* as the original ByteBuffer. Also useful with nested FlatBuffers, etc.
|
||||
*
|
||||
* @param vector_offset The position of the vector in the byte buffer
|
||||
* @param elem_size The size of each element in the array
|
||||
* @return The {@link ByteBuffer} for the array
|
||||
*/
|
||||
protected ByteBuffer __vector_as_bytebuffer(int vector_offset, int elem_size) {
|
||||
int o = __offset(vector_offset);
|
||||
if (o == 0) return null;
|
||||
ByteBuffer bb = this.bb.duplicate().order(ByteOrder.LITTLE_ENDIAN);
|
||||
int vectorstart = __vector(o);
|
||||
bb.position(vectorstart);
|
||||
bb.limit(vectorstart + __vector_len(o) * elem_size);
|
||||
return bb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize vector as a ByteBuffer.
|
||||
*
|
||||
* This is more efficient than using duplicate, since it doesn't copy the data
|
||||
* nor allocattes a new {@link ByteBuffer}, creating no garbage to be collected.
|
||||
*
|
||||
* @param bb The {@link ByteBuffer} for the array
|
||||
* @param vector_offset The position of the vector in the byte buffer
|
||||
* @param elem_size The size of each element in the array
|
||||
* @return The {@link ByteBuffer} for the array
|
||||
*/
|
||||
protected ByteBuffer __vector_in_bytebuffer(ByteBuffer bb, int vector_offset, int elem_size) {
|
||||
int o = this.__offset(vector_offset);
|
||||
if (o == 0) return null;
|
||||
int vectorstart = __vector(o);
|
||||
bb.rewind();
|
||||
bb.limit(vectorstart + __vector_len(o) * elem_size);
|
||||
bb.position(vectorstart);
|
||||
return bb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize any Table-derived type to point to the union at the given `offset`.
|
||||
*
|
||||
* @param t A `Table`-derived type that should point to the union at `offset`.
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @return Returns the Table that points to the union at `offset`.
|
||||
*/
|
||||
protected Table __union(Table t, int offset) {
|
||||
return __union(t, offset, bb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize any Table-derived type to point to the union at the given `offset`.
|
||||
*
|
||||
* @param t A `Table`-derived type that should point to the union at `offset`.
|
||||
* @param offset An `int` index into the Table's ByteBuffer.
|
||||
* @param bb Table ByteBuffer used to initialize the object Table-derived type.
|
||||
* @return Returns the Table that points to the union at `offset`.
|
||||
*/
|
||||
protected static Table __union(Table t, int offset, ByteBuffer bb) {
|
||||
t.__reset(__indirect(offset, bb), bb);
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a {@link ByteBuffer} contains a file identifier.
|
||||
*
|
||||
* @param bb A {@code ByteBuffer} to check if it contains the identifier
|
||||
* `ident`.
|
||||
* @param ident A `String` identifier of the FlatBuffer file.
|
||||
* @return True if the buffer contains the file identifier
|
||||
*/
|
||||
protected static boolean __has_identifier(ByteBuffer bb, String ident) {
|
||||
if (ident.length() != FILE_IDENTIFIER_LENGTH)
|
||||
throw new AssertionError("FlatBuffers: file identifier must be length " +
|
||||
FILE_IDENTIFIER_LENGTH);
|
||||
for (int i = 0; i < FILE_IDENTIFIER_LENGTH; i++) {
|
||||
if (ident.charAt(i) != (char)bb.get(bb.position() + SIZEOF_INT + i)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort tables by the key.
|
||||
*
|
||||
* @param offsets An 'int' indexes of the tables into the bb.
|
||||
* @param bb A {@code ByteBuffer} to get the tables.
|
||||
*/
|
||||
protected void sortTables(int[] offsets, final ByteBuffer bb) {
|
||||
Integer[] off = new Integer[offsets.length];
|
||||
for (int i = 0; i < offsets.length; i++) off[i] = offsets[i];
|
||||
java.util.Arrays.sort(off, new java.util.Comparator<Integer>() {
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
return keysCompare(o1, o2, bb);
|
||||
}
|
||||
});
|
||||
for (int i = 0; i < offsets.length; i++) offsets[i] = off[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two tables by the key.
|
||||
*
|
||||
* @param o1 An 'Integer' index of the first key into the bb.
|
||||
* @param o2 An 'Integer' index of the second key into the bb.
|
||||
* @param bb A {@code ByteBuffer} to get the keys.
|
||||
*/
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer bb) { return 0; }
|
||||
|
||||
/**
|
||||
* Compare two strings in the buffer.
|
||||
*
|
||||
* @param offset_1 An 'int' index of the first string into the bb.
|
||||
* @param offset_2 An 'int' index of the second string into the bb.
|
||||
* @param bb A {@code ByteBuffer} to get the strings.
|
||||
*/
|
||||
protected static int compareStrings(int offset_1, int offset_2, ByteBuffer bb) {
|
||||
offset_1 += bb.getInt(offset_1);
|
||||
offset_2 += bb.getInt(offset_2);
|
||||
int len_1 = bb.getInt(offset_1);
|
||||
int len_2 = bb.getInt(offset_2);
|
||||
int startPos_1 = offset_1 + SIZEOF_INT;
|
||||
int startPos_2 = offset_2 + SIZEOF_INT;
|
||||
int len = Math.min(len_1, len_2);
|
||||
for(int i = 0; i < len; i++) {
|
||||
if (bb.get(i + startPos_1) != bb.get(i + startPos_2))
|
||||
return bb.get(i + startPos_1) - bb.get(i + startPos_2);
|
||||
}
|
||||
return len_1 - len_2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare string from the buffer with the 'String' object.
|
||||
*
|
||||
* @param offset_1 An 'int' index of the first string into the bb.
|
||||
* @param key Second string as a byte array.
|
||||
* @param bb A {@code ByteBuffer} to get the first string.
|
||||
*/
|
||||
protected static int compareStrings(int offset_1, byte[] key, ByteBuffer bb) {
|
||||
offset_1 += bb.getInt(offset_1);
|
||||
int len_1 = bb.getInt(offset_1);
|
||||
int len_2 = key.length;
|
||||
int startPos_1 = offset_1 + Constants.SIZEOF_INT;
|
||||
int len = Math.min(len_1, len_2);
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (bb.get(i + startPos_1) != key[i])
|
||||
return bb.get(i + startPos_1) - key[i];
|
||||
}
|
||||
return len_1 - len_2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-init the internal state with an external buffer {@code ByteBuffer} and an offset within.
|
||||
*
|
||||
* This method exists primarily to allow recycling Table instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references.
|
||||
*/
|
||||
protected void __reset(int _i, ByteBuffer _bb) {
|
||||
bb = _bb;
|
||||
if (bb != null) {
|
||||
bb_pos = _i;
|
||||
vtable_start = bb_pos - bb.getInt(bb_pos);
|
||||
vtable_size = bb.getShort(vtable_start);
|
||||
} else {
|
||||
bb_pos = 0;
|
||||
vtable_start = 0;
|
||||
vtable_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the internal state with a null {@code ByteBuffer} and a zero position.
|
||||
*
|
||||
* This method exists primarily to allow recycling Table instances without risking memory leaks
|
||||
* due to {@code ByteBuffer} references. The instance will be unusable until it is assigned
|
||||
* again to a {@code ByteBuffer}.
|
||||
*/
|
||||
public void __reset() {
|
||||
__reset(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// @endcond
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import static com.google.flatbuffers.Constants.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Helper type for accessing vector of unions.
|
||||
*/
|
||||
public final class UnionVector extends BaseVector {
|
||||
/**
|
||||
* Assigns vector access object to vector data.
|
||||
*
|
||||
* @param _vector Start data of a vector.
|
||||
* @param _element_size Size of a vector element.
|
||||
* @param _bb Table's ByteBuffer.
|
||||
* @return Returns current vector access object assigned to vector data whose offset is stored at
|
||||
* `vector`.
|
||||
*/
|
||||
public UnionVector __assign(int _vector, int _element_size, ByteBuffer _bb) {
|
||||
__reset(_vector, _element_size, _bb); return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize any Table-derived type to point to the union at the given `index`.
|
||||
*
|
||||
* @param obj A `Table`-derived type that should point to the union at `index`.
|
||||
* @param j An `int` index into the union vector.
|
||||
* @return Returns the Table that points to the union at `index`.
|
||||
*/
|
||||
public Table get(Table obj, int j) {
|
||||
return Table.__union(obj, __element(j), bb);
|
||||
}
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static java.lang.Character.MAX_SURROGATE;
|
||||
import static java.lang.Character.MIN_SURROGATE;
|
||||
import static java.lang.Character.MIN_HIGH_SURROGATE;
|
||||
import static java.lang.Character.MIN_LOW_SURROGATE;
|
||||
import static java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT;
|
||||
import static java.lang.Character.isSurrogatePair;
|
||||
import static java.lang.Character.toCodePoint;
|
||||
|
||||
public abstract class Utf8 {
|
||||
|
||||
/**
|
||||
* Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string,
|
||||
* this method is equivalent to {@code string.getBytes(UTF_8).length}, but is more efficient in
|
||||
* both time and space.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code sequence} contains ill-formed UTF-16 (unpaired
|
||||
* surrogates)
|
||||
*/
|
||||
public abstract int encodedLength(CharSequence sequence);
|
||||
|
||||
/**
|
||||
* Encodes the given characters to the target {@link ByteBuffer} using UTF-8 encoding.
|
||||
*
|
||||
* <p>Selects an optimal algorithm based on the type of {@link ByteBuffer} (i.e. heap or direct)
|
||||
* and the capabilities of the platform.
|
||||
*
|
||||
* @param in the source string to be encoded
|
||||
* @param out the target buffer to receive the encoded string.
|
||||
*/
|
||||
public abstract void encodeUtf8(CharSequence in, ByteBuffer out);
|
||||
|
||||
/**
|
||||
* Decodes the given UTF-8 portion of the {@link ByteBuffer} into a {@link String}.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input is not valid UTF-8.
|
||||
*/
|
||||
public abstract String decodeUtf8(ByteBuffer buffer, int offset, int length);
|
||||
|
||||
private static Utf8 DEFAULT;
|
||||
|
||||
/**
|
||||
* Get the default UTF-8 processor.
|
||||
* @return the default processor
|
||||
*/
|
||||
public static Utf8 getDefault() {
|
||||
if (DEFAULT == null) {
|
||||
DEFAULT = new Utf8Safe();
|
||||
}
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default instance of the UTF-8 processor.
|
||||
* @param instance the new instance to use
|
||||
*/
|
||||
public static void setDefault(Utf8 instance) {
|
||||
DEFAULT = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a Java's CharSequence UTF8 codepoint into a byte array.
|
||||
* @param in CharSequence to be encoded
|
||||
* @param start start position of the first char in the codepoint
|
||||
* @param out byte array of 4 bytes to be filled
|
||||
* @return return the amount of bytes occupied by the codepoint
|
||||
*/
|
||||
public static int encodeUtf8CodePoint(CharSequence in, int start, byte[] out) {
|
||||
// utf8 codepoint needs at least 4 bytes
|
||||
assert out.length >= 4;
|
||||
|
||||
final int inLength = in.length();
|
||||
if (start >= inLength) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char c = in.charAt(start);
|
||||
if (c < 0x80) {
|
||||
// One byte (0xxx xxxx)
|
||||
out[0] = (byte) c;
|
||||
return 1;
|
||||
} else if (c < 0x800) {
|
||||
// Two bytes (110x xxxx 10xx xxxx)
|
||||
out[0] = (byte) (0xC0 | (c >>> 6));
|
||||
out[1] = (byte) (0x80 | (0x3F & c));
|
||||
return 2;
|
||||
} else if (c < MIN_SURROGATE || MAX_SURROGATE < c) {
|
||||
// Three bytes (1110 xxxx 10xx xxxx 10xx xxxx)
|
||||
// Maximum single-char code point is 0xFFFF, 16 bits.
|
||||
out[0] = (byte) (0xE0 | (c >>> 12));
|
||||
out[1] =(byte) (0x80 | (0x3F & (c >>> 6)));
|
||||
out[2] = (byte) (0x80 | (0x3F & c));
|
||||
return 3;
|
||||
} else {
|
||||
// Four bytes (1111 xxxx 10xx xxxx 10xx xxxx 10xx xxxx)
|
||||
// Minimum code point represented by a surrogate pair is 0x10000, 17 bits, four UTF-8
|
||||
// bytes
|
||||
final char low;
|
||||
if (start + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(start+1)))) {
|
||||
throw new UnpairedSurrogateException(start, inLength);
|
||||
}
|
||||
int codePoint = toCodePoint(c, low);
|
||||
out[0] = (byte) ((0xF << 4) | (codePoint >>> 18));
|
||||
out[1] = (byte) (0x80 | (0x3F & (codePoint >>> 12)));
|
||||
out[2] = (byte) (0x80 | (0x3F & (codePoint >>> 6)));
|
||||
out[3] = (byte) (0x80 | (0x3F & codePoint));
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility methods for decoding bytes into {@link String}. Callers are responsible for extracting
|
||||
* bytes (possibly using Unsafe methods), and checking remaining bytes. All other UTF-8 validity
|
||||
* checks and codepoint conversion happen in this class.
|
||||
*/
|
||||
static class DecodeUtil {
|
||||
|
||||
/**
|
||||
* Returns whether this is a single-byte codepoint (i.e., ASCII) with the form '0XXXXXXX'.
|
||||
*/
|
||||
static boolean isOneByte(byte b) {
|
||||
return b >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this is a two-byte codepoint with the form '10XXXXXX'.
|
||||
*/
|
||||
static boolean isTwoBytes(byte b) {
|
||||
return b < (byte) 0xE0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this is a three-byte codepoint with the form '110XXXXX'.
|
||||
*/
|
||||
static boolean isThreeBytes(byte b) {
|
||||
return b < (byte) 0xF0;
|
||||
}
|
||||
|
||||
static void handleOneByte(byte byte1, char[] resultArr, int resultPos) {
|
||||
resultArr[resultPos] = (char) byte1;
|
||||
}
|
||||
|
||||
static void handleTwoBytes(
|
||||
byte byte1, byte byte2, char[] resultArr, int resultPos)
|
||||
throws IllegalArgumentException {
|
||||
// Simultaneously checks for illegal trailing-byte in leading position (<= '11000000') and
|
||||
// overlong 2-byte, '11000001'.
|
||||
if (byte1 < (byte) 0xC2) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8: Illegal leading byte in 2 bytes utf");
|
||||
}
|
||||
if (isNotTrailingByte(byte2)) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8: Illegal trailing byte in 2 bytes utf");
|
||||
}
|
||||
resultArr[resultPos] = (char) (((byte1 & 0x1F) << 6) | trailingByteValue(byte2));
|
||||
}
|
||||
|
||||
static void handleThreeBytes(
|
||||
byte byte1, byte byte2, byte byte3, char[] resultArr, int resultPos)
|
||||
throws IllegalArgumentException {
|
||||
if (isNotTrailingByte(byte2)
|
||||
// overlong? 5 most significant bits must not all be zero
|
||||
|| (byte1 == (byte) 0xE0 && byte2 < (byte) 0xA0)
|
||||
// check for illegal surrogate codepoints
|
||||
|| (byte1 == (byte) 0xED && byte2 >= (byte) 0xA0)
|
||||
|| isNotTrailingByte(byte3)) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
resultArr[resultPos] = (char)
|
||||
(((byte1 & 0x0F) << 12) | (trailingByteValue(byte2) << 6) | trailingByteValue(byte3));
|
||||
}
|
||||
|
||||
static void handleFourBytes(
|
||||
byte byte1, byte byte2, byte byte3, byte byte4, char[] resultArr, int resultPos)
|
||||
throws IllegalArgumentException{
|
||||
if (isNotTrailingByte(byte2)
|
||||
// Check that 1 <= plane <= 16. Tricky optimized form of:
|
||||
// valid 4-byte leading byte?
|
||||
// if (byte1 > (byte) 0xF4 ||
|
||||
// overlong? 4 most significant bits must not all be zero
|
||||
// byte1 == (byte) 0xF0 && byte2 < (byte) 0x90 ||
|
||||
// codepoint larger than the highest code point (U+10FFFF)?
|
||||
// byte1 == (byte) 0xF4 && byte2 > (byte) 0x8F)
|
||||
|| (((byte1 << 28) + (byte2 - (byte) 0x90)) >> 30) != 0
|
||||
|| isNotTrailingByte(byte3)
|
||||
|| isNotTrailingByte(byte4)) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
int codepoint = ((byte1 & 0x07) << 18)
|
||||
| (trailingByteValue(byte2) << 12)
|
||||
| (trailingByteValue(byte3) << 6)
|
||||
| trailingByteValue(byte4);
|
||||
resultArr[resultPos] = DecodeUtil.highSurrogate(codepoint);
|
||||
resultArr[resultPos + 1] = DecodeUtil.lowSurrogate(codepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the byte is not a valid continuation of the form '10XXXXXX'.
|
||||
*/
|
||||
private static boolean isNotTrailingByte(byte b) {
|
||||
return b > (byte) 0xBF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual value of the trailing byte (removes the prefix '10') for composition.
|
||||
*/
|
||||
private static int trailingByteValue(byte b) {
|
||||
return b & 0x3F;
|
||||
}
|
||||
|
||||
private static char highSurrogate(int codePoint) {
|
||||
return (char) ((MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10))
|
||||
+ (codePoint >>> 10));
|
||||
}
|
||||
|
||||
private static char lowSurrogate(int codePoint) {
|
||||
return (char) (MIN_LOW_SURROGATE + (codePoint & 0x3ff));
|
||||
}
|
||||
}
|
||||
|
||||
// These UTF-8 handling methods are copied from Guava's Utf8Unsafe class with a modification to throw
|
||||
// a protocol buffer local exception. This exception is then caught in CodedOutputStream so it can
|
||||
// fallback to more lenient behavior.
|
||||
static class UnpairedSurrogateException extends IllegalArgumentException {
|
||||
UnpairedSurrogateException(int index, int length) {
|
||||
super("Unpaired surrogate at index " + index + " of " + length);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* This class implements the Utf8 API using the Java Utf8 encoder. Use
|
||||
* Utf8.setDefault(new Utf8Old()); to use it.
|
||||
*/
|
||||
public class Utf8Old extends Utf8 {
|
||||
|
||||
private static class Cache {
|
||||
final CharsetEncoder encoder;
|
||||
final CharsetDecoder decoder;
|
||||
CharSequence lastInput = null;
|
||||
ByteBuffer lastOutput = null;
|
||||
|
||||
Cache() {
|
||||
encoder = StandardCharsets.UTF_8.newEncoder();
|
||||
decoder = StandardCharsets.UTF_8.newDecoder();
|
||||
}
|
||||
}
|
||||
|
||||
// ThreadLocal.withInitial() is not used to make the following code compatible with Android API
|
||||
// level 23.
|
||||
private static final ThreadLocal<Cache> CACHE =
|
||||
new ThreadLocal<Cache>() {
|
||||
@Override
|
||||
protected Cache initialValue() {
|
||||
return new Cache();
|
||||
}
|
||||
};
|
||||
|
||||
// Play some games so that the old encoder doesn't pay twice for computing
|
||||
// the length of the encoded string.
|
||||
|
||||
@Override
|
||||
public int encodedLength(CharSequence in) {
|
||||
final Cache cache = CACHE.get();
|
||||
int estimated = (int) (in.length() * cache.encoder.maxBytesPerChar());
|
||||
if (cache.lastOutput == null || cache.lastOutput.capacity() < estimated) {
|
||||
cache.lastOutput = ByteBuffer.allocate(Math.max(128, estimated));
|
||||
}
|
||||
cache.lastOutput.clear();
|
||||
cache.lastInput = in;
|
||||
CharBuffer wrap = (in instanceof CharBuffer) ?
|
||||
(CharBuffer) in : CharBuffer.wrap(in);
|
||||
CoderResult result = cache.encoder.encode(wrap, cache.lastOutput, true);
|
||||
if (result.isError()) {
|
||||
try {
|
||||
result.throwException();
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("bad character encoding", e);
|
||||
}
|
||||
}
|
||||
cache.lastOutput.flip();
|
||||
return cache.lastOutput.remaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeUtf8(CharSequence in, ByteBuffer out) {
|
||||
final Cache cache = CACHE.get();
|
||||
if (cache.lastInput != in) {
|
||||
// Update the lastOutput to match our input, although flatbuffer should
|
||||
// never take this branch.
|
||||
encodedLength(in);
|
||||
}
|
||||
out.put(cache.lastOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decodeUtf8(ByteBuffer buffer, int offset, int length) {
|
||||
CharsetDecoder decoder = CACHE.get().decoder;
|
||||
decoder.reset();
|
||||
buffer = buffer.duplicate();
|
||||
buffer.position(offset);
|
||||
buffer.limit(offset + length);
|
||||
try {
|
||||
CharBuffer result = decoder.decode(buffer);
|
||||
return result.toString();
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("Bad encoding", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,421 +0,0 @@
|
||||
package com.google.flatbuffers;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import static java.lang.Character.MAX_SURROGATE;
|
||||
import static java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT;
|
||||
import static java.lang.Character.MIN_SURROGATE;
|
||||
import static java.lang.Character.isSurrogatePair;
|
||||
import static java.lang.Character.toCodePoint;
|
||||
|
||||
/**
|
||||
* A set of low-level, high-performance static utility methods related
|
||||
* to the UTF-8 character encoding. This class has no dependencies
|
||||
* outside of the core JDK libraries.
|
||||
*
|
||||
* <p>There are several variants of UTF-8. The one implemented by
|
||||
* this class is the restricted definition of UTF-8 introduced in
|
||||
* Unicode 3.1, which mandates the rejection of "overlong" byte
|
||||
* sequences as well as rejection of 3-byte surrogate codepoint byte
|
||||
* sequences. Note that the UTF-8 decoder included in Oracle's JDK
|
||||
* has been modified to also reject "overlong" byte sequences, but (as
|
||||
* of 2011) still accepts 3-byte surrogate codepoint byte sequences.
|
||||
*
|
||||
* <p>The byte sequences considered valid by this class are exactly
|
||||
* those that can be roundtrip converted to Strings and back to bytes
|
||||
* using the UTF-8 charset, without loss: <pre> {@code
|
||||
* Arrays.equals(bytes, new String(bytes, Internal.UTF_8).getBytes(Internal.UTF_8))
|
||||
* }</pre>
|
||||
*
|
||||
* <p>See the Unicode Standard,</br>
|
||||
* Table 3-6. <em>UTF-8 Bit Distribution</em>,</br>
|
||||
* Table 3-7. <em>Well Formed UTF-8 Byte Sequences</em>.
|
||||
*/
|
||||
final public class Utf8Safe extends Utf8 {
|
||||
|
||||
/**
|
||||
* Returns the number of bytes in the UTF-8-encoded form of {@code sequence}. For a string,
|
||||
* this method is equivalent to {@code string.getBytes(UTF_8).length}, but is more efficient in
|
||||
* both time and space.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code sequence} contains ill-formed UTF-16 (unpaired
|
||||
* surrogates)
|
||||
*/
|
||||
private static int computeEncodedLength(CharSequence sequence) {
|
||||
// Warning to maintainers: this implementation is highly optimized.
|
||||
int utf16Length = sequence.length();
|
||||
int utf8Length = utf16Length;
|
||||
int i = 0;
|
||||
|
||||
// This loop optimizes for pure ASCII.
|
||||
while (i < utf16Length && sequence.charAt(i) < 0x80) {
|
||||
i++;
|
||||
}
|
||||
|
||||
// This loop optimizes for chars less than 0x800.
|
||||
for (; i < utf16Length; i++) {
|
||||
char c = sequence.charAt(i);
|
||||
if (c < 0x800) {
|
||||
utf8Length += ((0x7f - c) >>> 31); // branch free!
|
||||
} else {
|
||||
utf8Length += encodedLengthGeneral(sequence, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (utf8Length < utf16Length) {
|
||||
// Necessary and sufficient condition for overflow because of maximum 3x expansion
|
||||
throw new IllegalArgumentException("UTF-8 length does not fit in int: "
|
||||
+ (utf8Length + (1L << 32)));
|
||||
}
|
||||
return utf8Length;
|
||||
}
|
||||
|
||||
private static int encodedLengthGeneral(CharSequence sequence, int start) {
|
||||
int utf16Length = sequence.length();
|
||||
int utf8Length = 0;
|
||||
for (int i = start; i < utf16Length; i++) {
|
||||
char c = sequence.charAt(i);
|
||||
if (c < 0x800) {
|
||||
utf8Length += (0x7f - c) >>> 31; // branch free!
|
||||
} else {
|
||||
utf8Length += 2;
|
||||
// jdk7+: if (Character.isSurrogate(c)) {
|
||||
if (Character.MIN_SURROGATE <= c && c <= Character.MAX_SURROGATE) {
|
||||
// Check that we have a well-formed surrogate pair.
|
||||
int cp = Character.codePointAt(sequence, i);
|
||||
if (cp < MIN_SUPPLEMENTARY_CODE_POINT) {
|
||||
throw new Utf8Safe.UnpairedSurrogateException(i, utf16Length);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return utf8Length;
|
||||
}
|
||||
|
||||
public static String decodeUtf8Array(byte[] bytes, int index, int size) {
|
||||
// Bitwise OR combines the sign bits so any negative value fails the check.
|
||||
if ((index | size | bytes.length - index - size) < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format("buffer length=%d, index=%d, size=%d", bytes.length, index, size));
|
||||
}
|
||||
|
||||
int offset = index;
|
||||
final int limit = offset + size;
|
||||
|
||||
// The longest possible resulting String is the same as the number of input bytes, when it is
|
||||
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
|
||||
char[] resultArr = new char[size];
|
||||
int resultPos = 0;
|
||||
|
||||
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
|
||||
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
|
||||
while (offset < limit) {
|
||||
byte b = bytes[offset];
|
||||
if (!DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
|
||||
}
|
||||
|
||||
while (offset < limit) {
|
||||
byte byte1 = bytes[offset++];
|
||||
if (DecodeUtil.isOneByte(byte1)) {
|
||||
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
|
||||
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
|
||||
// extra optimized loop to take care of these runs.
|
||||
while (offset < limit) {
|
||||
byte b = bytes[offset];
|
||||
if (!DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
|
||||
}
|
||||
} else if (DecodeUtil.isTwoBytes(byte1)) {
|
||||
if (offset >= limit) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleTwoBytes(byte1, /* byte2 */ bytes[offset++], resultArr, resultPos++);
|
||||
} else if (DecodeUtil.isThreeBytes(byte1)) {
|
||||
if (offset >= limit - 1) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleThreeBytes(
|
||||
byte1,
|
||||
/* byte2 */ bytes[offset++],
|
||||
/* byte3 */ bytes[offset++],
|
||||
resultArr,
|
||||
resultPos++);
|
||||
} else {
|
||||
if (offset >= limit - 2) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleFourBytes(
|
||||
byte1,
|
||||
/* byte2 */ bytes[offset++],
|
||||
/* byte3 */ bytes[offset++],
|
||||
/* byte4 */ bytes[offset++],
|
||||
resultArr,
|
||||
resultPos++);
|
||||
// 4-byte case requires two chars.
|
||||
resultPos++;
|
||||
}
|
||||
}
|
||||
|
||||
return new String(resultArr, 0, resultPos);
|
||||
}
|
||||
|
||||
public static String decodeUtf8Buffer(ByteBuffer buffer, int offset,
|
||||
int length) {
|
||||
// Bitwise OR combines the sign bits so any negative value fails the check.
|
||||
if ((offset | length | buffer.limit() - offset - length) < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
String.format("buffer limit=%d, index=%d, limit=%d", buffer.limit(),
|
||||
offset, length));
|
||||
}
|
||||
|
||||
final int limit = offset + length;
|
||||
|
||||
// The longest possible resulting String is the same as the number of input bytes, when it is
|
||||
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
|
||||
char[] resultArr = new char[length];
|
||||
int resultPos = 0;
|
||||
|
||||
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
|
||||
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
|
||||
while (offset < limit) {
|
||||
byte b = buffer.get(offset);
|
||||
if (!DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
|
||||
}
|
||||
|
||||
while (offset < limit) {
|
||||
byte byte1 = buffer.get(offset++);
|
||||
if (DecodeUtil.isOneByte(byte1)) {
|
||||
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
|
||||
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
|
||||
// extra optimized loop to take care of these runs.
|
||||
while (offset < limit) {
|
||||
byte b = buffer.get(offset);
|
||||
if (!DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
|
||||
}
|
||||
} else if (DecodeUtil.isTwoBytes(byte1)) {
|
||||
if (offset >= limit) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleTwoBytes(
|
||||
byte1, /* byte2 */ buffer.get(offset++), resultArr, resultPos++);
|
||||
} else if (DecodeUtil.isThreeBytes(byte1)) {
|
||||
if (offset >= limit - 1) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleThreeBytes(
|
||||
byte1,
|
||||
/* byte2 */ buffer.get(offset++),
|
||||
/* byte3 */ buffer.get(offset++),
|
||||
resultArr,
|
||||
resultPos++);
|
||||
} else {
|
||||
if (offset >= limit - 2) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
DecodeUtil.handleFourBytes(
|
||||
byte1,
|
||||
/* byte2 */ buffer.get(offset++),
|
||||
/* byte3 */ buffer.get(offset++),
|
||||
/* byte4 */ buffer.get(offset++),
|
||||
resultArr,
|
||||
resultPos++);
|
||||
// 4-byte case requires two chars.
|
||||
resultPos++;
|
||||
}
|
||||
}
|
||||
|
||||
return new String(resultArr, 0, resultPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int encodedLength(CharSequence in) {
|
||||
return computeEncodedLength(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the given UTF-8 portion of the {@link ByteBuffer} into a {@link String}.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input is not valid UTF-8.
|
||||
*/
|
||||
@Override
|
||||
public String decodeUtf8(ByteBuffer buffer, int offset, int length)
|
||||
throws IllegalArgumentException {
|
||||
if (buffer.hasArray()) {
|
||||
return decodeUtf8Array(buffer.array(), buffer.arrayOffset() + offset, length);
|
||||
} else {
|
||||
return decodeUtf8Buffer(buffer, offset, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void encodeUtf8Buffer(CharSequence in, ByteBuffer out) {
|
||||
final int inLength = in.length();
|
||||
int outIx = out.position();
|
||||
int inIx = 0;
|
||||
|
||||
// Since ByteBuffer.putXXX() already checks boundaries for us, no need to explicitly check
|
||||
// access. Assume the buffer is big enough and let it handle the out of bounds exception
|
||||
// if it occurs.
|
||||
try {
|
||||
// Designed to take advantage of
|
||||
// https://wikis.oracle.com/display/HotSpotInternals/RangeCheckElimination
|
||||
for (char c; inIx < inLength && (c = in.charAt(inIx)) < 0x80; ++inIx) {
|
||||
out.put(outIx + inIx, (byte) c);
|
||||
}
|
||||
if (inIx == inLength) {
|
||||
// Successfully encoded the entire string.
|
||||
out.position(outIx + inIx);
|
||||
return;
|
||||
}
|
||||
|
||||
outIx += inIx;
|
||||
for (char c; inIx < inLength; ++inIx, ++outIx) {
|
||||
c = in.charAt(inIx);
|
||||
if (c < 0x80) {
|
||||
// One byte (0xxx xxxx)
|
||||
out.put(outIx, (byte) c);
|
||||
} else if (c < 0x800) {
|
||||
// Two bytes (110x xxxx 10xx xxxx)
|
||||
|
||||
// Benchmarks show put performs better than putShort here (for HotSpot).
|
||||
out.put(outIx++, (byte) (0xC0 | (c >>> 6)));
|
||||
out.put(outIx, (byte) (0x80 | (0x3F & c)));
|
||||
} else if (c < MIN_SURROGATE || MAX_SURROGATE < c) {
|
||||
// Three bytes (1110 xxxx 10xx xxxx 10xx xxxx)
|
||||
// Maximum single-char code point is 0xFFFF, 16 bits.
|
||||
|
||||
// Benchmarks show put performs better than putShort here (for HotSpot).
|
||||
out.put(outIx++, (byte) (0xE0 | (c >>> 12)));
|
||||
out.put(outIx++, (byte) (0x80 | (0x3F & (c >>> 6))));
|
||||
out.put(outIx, (byte) (0x80 | (0x3F & c)));
|
||||
} else {
|
||||
// Four bytes (1111 xxxx 10xx xxxx 10xx xxxx 10xx xxxx)
|
||||
|
||||
// Minimum code point represented by a surrogate pair is 0x10000, 17 bits, four UTF-8
|
||||
// bytes
|
||||
final char low;
|
||||
if (inIx + 1 == inLength || !isSurrogatePair(c, (low = in.charAt(++inIx)))) {
|
||||
throw new UnpairedSurrogateException(inIx, inLength);
|
||||
}
|
||||
// TODO(nathanmittler): Consider using putInt() to improve performance.
|
||||
int codePoint = toCodePoint(c, low);
|
||||
out.put(outIx++, (byte) ((0xF << 4) | (codePoint >>> 18)));
|
||||
out.put(outIx++, (byte) (0x80 | (0x3F & (codePoint >>> 12))));
|
||||
out.put(outIx++, (byte) (0x80 | (0x3F & (codePoint >>> 6))));
|
||||
out.put(outIx, (byte) (0x80 | (0x3F & codePoint)));
|
||||
}
|
||||
}
|
||||
|
||||
// Successfully encoded the entire string.
|
||||
out.position(outIx);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// TODO(nathanmittler): Consider making the API throw IndexOutOfBoundsException instead.
|
||||
|
||||
// If we failed in the outer ASCII loop, outIx will not have been updated. In this case,
|
||||
// use inIx to determine the bad write index.
|
||||
int badWriteIndex = out.position() + Math.max(inIx, outIx - out.position() + 1);
|
||||
throw new ArrayIndexOutOfBoundsException(
|
||||
"Failed writing " + in.charAt(inIx) + " at index " + badWriteIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static int encodeUtf8Array(CharSequence in, byte[] out,
|
||||
int offset, int length) {
|
||||
int utf16Length = in.length();
|
||||
int j = offset;
|
||||
int i = 0;
|
||||
int limit = offset + length;
|
||||
// Designed to take advantage of
|
||||
// https://wikis.oracle.com/display/HotSpotInternals/RangeCheckElimination
|
||||
for (char c; i < utf16Length && i + j < limit && (c = in.charAt(i)) < 0x80; i++) {
|
||||
out[j + i] = (byte) c;
|
||||
}
|
||||
if (i == utf16Length) {
|
||||
return j + utf16Length;
|
||||
}
|
||||
j += i;
|
||||
for (char c; i < utf16Length; i++) {
|
||||
c = in.charAt(i);
|
||||
if (c < 0x80 && j < limit) {
|
||||
out[j++] = (byte) c;
|
||||
} else if (c < 0x800 && j <= limit - 2) { // 11 bits, two UTF-8 bytes
|
||||
out[j++] = (byte) ((0xF << 6) | (c >>> 6));
|
||||
out[j++] = (byte) (0x80 | (0x3F & c));
|
||||
} else if ((c < Character.MIN_SURROGATE || Character.MAX_SURROGATE < c) && j <= limit - 3) {
|
||||
// Maximum single-char code point is 0xFFFF, 16 bits, three UTF-8 bytes
|
||||
out[j++] = (byte) ((0xF << 5) | (c >>> 12));
|
||||
out[j++] = (byte) (0x80 | (0x3F & (c >>> 6)));
|
||||
out[j++] = (byte) (0x80 | (0x3F & c));
|
||||
} else if (j <= limit - 4) {
|
||||
// Minimum code point represented by a surrogate pair is 0x10000, 17 bits,
|
||||
// four UTF-8 bytes
|
||||
final char low;
|
||||
if (i + 1 == in.length()
|
||||
|| !Character.isSurrogatePair(c, (low = in.charAt(++i)))) {
|
||||
throw new UnpairedSurrogateException((i - 1), utf16Length);
|
||||
}
|
||||
int codePoint = Character.toCodePoint(c, low);
|
||||
out[j++] = (byte) ((0xF << 4) | (codePoint >>> 18));
|
||||
out[j++] = (byte) (0x80 | (0x3F & (codePoint >>> 12)));
|
||||
out[j++] = (byte) (0x80 | (0x3F & (codePoint >>> 6)));
|
||||
out[j++] = (byte) (0x80 | (0x3F & codePoint));
|
||||
} else {
|
||||
// If we are surrogates and we're not a surrogate pair, always throw an
|
||||
// UnpairedSurrogateException instead of an ArrayOutOfBoundsException.
|
||||
if ((Character.MIN_SURROGATE <= c && c <= Character.MAX_SURROGATE)
|
||||
&& (i + 1 == in.length()
|
||||
|| !Character.isSurrogatePair(c, in.charAt(i + 1)))) {
|
||||
throw new UnpairedSurrogateException(i, utf16Length);
|
||||
}
|
||||
throw new ArrayIndexOutOfBoundsException("Failed writing " + c + " at index " + j);
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the given characters to the target {@link ByteBuffer} using UTF-8 encoding.
|
||||
*
|
||||
* <p>Selects an optimal algorithm based on the type of {@link ByteBuffer} (i.e. heap or direct)
|
||||
* and the capabilities of the platform.
|
||||
*
|
||||
* @param in the source string to be encoded
|
||||
* @param out the target buffer to receive the encoded string.
|
||||
*/
|
||||
@Override
|
||||
public void encodeUtf8(CharSequence in, ByteBuffer out) {
|
||||
if (out.hasArray()) {
|
||||
int start = out.arrayOffset();
|
||||
int end = encodeUtf8Array(in, out.array(), start + out.position(),
|
||||
out.remaining());
|
||||
out.position(end - start);
|
||||
} else {
|
||||
encodeUtf8Buffer(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
// These UTF-8 handling methods are copied from Guava's Utf8Unsafe class with
|
||||
// a modification to throw a local exception. This exception can be caught
|
||||
// to fallback to more lenient behavior.
|
||||
static class UnpairedSurrogateException extends IllegalArgumentException {
|
||||
UnpairedSurrogateException(int index, int length) {
|
||||
super("Unpaired surrogate at index " + index + " of " + length);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
/**
|
||||
* New schema language features that are not supported by old code generators.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public final class AdvancedFeatures {
|
||||
private AdvancedFeatures() { }
|
||||
public static final long AdvancedArrayFeatures = 1L;
|
||||
public static final long AdvancedUnionFeatures = 2L;
|
||||
public static final long OptionalScalars = 4L;
|
||||
public static final long DefaultVectorsAndStrings = 8L;
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class BaseType {
|
||||
private BaseType() { }
|
||||
public static final byte None = 0;
|
||||
public static final byte UType = 1;
|
||||
public static final byte Bool = 2;
|
||||
public static final byte Byte = 3;
|
||||
public static final byte UByte = 4;
|
||||
public static final byte Short = 5;
|
||||
public static final byte UShort = 6;
|
||||
public static final byte Int = 7;
|
||||
public static final byte UInt = 8;
|
||||
public static final byte Long = 9;
|
||||
public static final byte ULong = 10;
|
||||
public static final byte Float = 11;
|
||||
public static final byte Double = 12;
|
||||
public static final byte String = 13;
|
||||
public static final byte Vector = 14;
|
||||
public static final byte Obj = 15;
|
||||
public static final byte Union = 16;
|
||||
public static final byte Array = 17;
|
||||
public static final byte Vector64 = 18;
|
||||
public static final byte MaxBaseType = 19;
|
||||
|
||||
public static final String[] names = { "None", "UType", "Bool", "Byte", "UByte", "Short", "UShort", "Int", "UInt", "Long", "ULong", "Float", "Double", "String", "Vector", "Obj", "Union", "Array", "Vector64", "MaxBaseType", };
|
||||
|
||||
public static String name(int e) { return names[e]; }
|
||||
}
|
||||
|
@ -1,135 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Enum extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb) { return getRootAsEnum(_bb, new Enum()); }
|
||||
public static Enum getRootAsEnum(ByteBuffer _bb, Enum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Enum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.EnumVal values(int j) { return values(new com.google.flatbuffers.reflection.EnumVal(), j); }
|
||||
public com.google.flatbuffers.reflection.EnumVal values(com.google.flatbuffers.reflection.EnumVal obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int valuesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.EnumVal valuesByKey(long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.EnumVal valuesByKey(com.google.flatbuffers.reflection.EnumVal obj, long key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.EnumVal.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector() { return valuesVector(new com.google.flatbuffers.reflection.EnumVal.Vector()); }
|
||||
public com.google.flatbuffers.reflection.EnumVal.Vector valuesVector(com.google.flatbuffers.reflection.EnumVal.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean isUnion() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public com.google.flatbuffers.reflection.Type underlyingType() { return underlyingType(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type underlyingType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(12); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(14); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Enum is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(16, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 16, 1); }
|
||||
|
||||
public static int createEnum(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int valuesOffset,
|
||||
boolean isUnion,
|
||||
int underlyingTypeOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(7);
|
||||
Enum.addDeclarationFile(builder, declarationFileOffset);
|
||||
Enum.addDocumentation(builder, documentationOffset);
|
||||
Enum.addAttributes(builder, attributesOffset);
|
||||
Enum.addUnderlyingType(builder, underlyingTypeOffset);
|
||||
Enum.addValues(builder, valuesOffset);
|
||||
Enum.addName(builder, nameOffset);
|
||||
Enum.addIsUnion(builder, isUnion);
|
||||
return Enum.endEnum(builder);
|
||||
}
|
||||
|
||||
public static void startEnum(FlatBufferBuilder builder) { builder.startTable(7); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addValues(FlatBufferBuilder builder, int valuesOffset) { builder.addOffset(1, valuesOffset, 0); }
|
||||
public static int createValuesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startValuesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addIsUnion(FlatBufferBuilder builder, boolean isUnion) { builder.addBoolean(2, isUnion, false); }
|
||||
public static void addUnderlyingType(FlatBufferBuilder builder, int underlyingTypeOffset) { builder.addOffset(3, underlyingTypeOffset, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(4, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(5, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(6, declarationFileOffset, 0); }
|
||||
public static int endEnum(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // values
|
||||
builder.required(o, 10); // underlying_type
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Enum __lookup_by_key(Enum obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Enum() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Enum get(int j) { return get(new Enum(), j); }
|
||||
public Enum get(Enum obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Enum getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Enum getByKey(Enum obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,116 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EnumVal extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb) { return getRootAsEnumVal(_bb, new EnumVal()); }
|
||||
public static EnumVal getRootAsEnumVal(ByteBuffer _bb, EnumVal obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public EnumVal __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public long value() { int o = __offset(6); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
public com.google.flatbuffers.reflection.Type unionType() { return unionType(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type unionType(com.google.flatbuffers.reflection.Type obj) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createEnumVal(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
long value,
|
||||
int unionTypeOffset,
|
||||
int documentationOffset,
|
||||
int attributesOffset) {
|
||||
builder.startTable(6);
|
||||
EnumVal.addValue(builder, value);
|
||||
EnumVal.addAttributes(builder, attributesOffset);
|
||||
EnumVal.addDocumentation(builder, documentationOffset);
|
||||
EnumVal.addUnionType(builder, unionTypeOffset);
|
||||
EnumVal.addName(builder, nameOffset);
|
||||
return EnumVal.endEnumVal(builder);
|
||||
}
|
||||
|
||||
public static void startEnumVal(FlatBufferBuilder builder) { builder.startTable(6); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(0, nameOffset, 0); }
|
||||
public static void addValue(FlatBufferBuilder builder, long value) { builder.addLong(value); builder.slot(1); }
|
||||
public static void addUnionType(FlatBufferBuilder builder, int unionTypeOffset) { builder.addOffset(3, unionTypeOffset, 0); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endEnumVal(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) {
|
||||
long val_1 = _bb.getLong(__offset(6, o1, _bb));
|
||||
long val_2 = _bb.getLong(__offset(6, o2, _bb));
|
||||
return val_1 > val_2 ? 1 : val_1 < val_2 ? -1 : 0;
|
||||
}
|
||||
|
||||
public static EnumVal __lookup_by_key(EnumVal obj, int vectorLocation, long key, ByteBuffer bb) {
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
long val = bb.getLong(__offset(6, bb.capacity() - tableOffset, bb));
|
||||
int comp = val > key ? 1 : val < key ? -1 : 0;
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new EnumVal() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public EnumVal get(int j) { return get(new EnumVal(), j); }
|
||||
public EnumVal get(EnumVal obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public EnumVal getByKey(long key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public EnumVal getByKey(EnumVal obj, long key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,155 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Field extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Field getRootAsField(ByteBuffer _bb) { return getRootAsField(_bb, new Field()); }
|
||||
public static Field getRootAsField(ByteBuffer _bb, Field obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Field __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Type type() { return type(new com.google.flatbuffers.reflection.Type()); }
|
||||
public com.google.flatbuffers.reflection.Type type(com.google.flatbuffers.reflection.Type obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public int id() { int o = __offset(8); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
public int offset() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
public long defaultInteger() { int o = __offset(12); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
public double defaultReal() { int o = __offset(14); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
|
||||
public boolean deprecated() { int o = __offset(16); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public boolean required() { int o = __offset(18); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public boolean key() { int o = __offset(20); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(22); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(22); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(22); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(22); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(24); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(24); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(24); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean optional() { int o = __offset(26); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
/**
|
||||
* Number of padding octets to always add after this field. Structs only.
|
||||
*/
|
||||
public int padding() { int o = __offset(28); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
/**
|
||||
* If the field uses 64-bit offsets.
|
||||
*/
|
||||
public boolean offset64() { int o = __offset(30); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
|
||||
public static int createField(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int typeOffset,
|
||||
int id,
|
||||
int offset,
|
||||
long defaultInteger,
|
||||
double defaultReal,
|
||||
boolean deprecated,
|
||||
boolean required,
|
||||
boolean key,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
boolean optional,
|
||||
int padding,
|
||||
boolean offset64) {
|
||||
builder.startTable(14);
|
||||
Field.addDefaultReal(builder, defaultReal);
|
||||
Field.addDefaultInteger(builder, defaultInteger);
|
||||
Field.addDocumentation(builder, documentationOffset);
|
||||
Field.addAttributes(builder, attributesOffset);
|
||||
Field.addType(builder, typeOffset);
|
||||
Field.addName(builder, nameOffset);
|
||||
Field.addPadding(builder, padding);
|
||||
Field.addOffset(builder, offset);
|
||||
Field.addId(builder, id);
|
||||
Field.addOffset64(builder, offset64);
|
||||
Field.addOptional(builder, optional);
|
||||
Field.addKey(builder, key);
|
||||
Field.addRequired(builder, required);
|
||||
Field.addDeprecated(builder, deprecated);
|
||||
return Field.endField(builder);
|
||||
}
|
||||
|
||||
public static void startField(FlatBufferBuilder builder) { builder.startTable(14); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addType(FlatBufferBuilder builder, int typeOffset) { builder.addOffset(1, typeOffset, 0); }
|
||||
public static void addId(FlatBufferBuilder builder, int id) { builder.addShort(2, (short) id, (short) 0); }
|
||||
public static void addOffset(FlatBufferBuilder builder, int offset) { builder.addShort(3, (short) offset, (short) 0); }
|
||||
public static void addDefaultInteger(FlatBufferBuilder builder, long defaultInteger) { builder.addLong(4, defaultInteger, 0L); }
|
||||
public static void addDefaultReal(FlatBufferBuilder builder, double defaultReal) { builder.addDouble(5, defaultReal, 0.0); }
|
||||
public static void addDeprecated(FlatBufferBuilder builder, boolean deprecated) { builder.addBoolean(6, deprecated, false); }
|
||||
public static void addRequired(FlatBufferBuilder builder, boolean required) { builder.addBoolean(7, required, false); }
|
||||
public static void addKey(FlatBufferBuilder builder, boolean key) { builder.addBoolean(8, key, false); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(9, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(10, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addOptional(FlatBufferBuilder builder, boolean optional) { builder.addBoolean(11, optional, false); }
|
||||
public static void addPadding(FlatBufferBuilder builder, int padding) { builder.addShort(12, (short) padding, (short) 0); }
|
||||
public static void addOffset64(FlatBufferBuilder builder, boolean offset64) { builder.addBoolean(13, offset64, false); }
|
||||
public static int endField(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // type
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Field __lookup_by_key(Field obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Field() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Field get(int j) { return get(new Field(), j); }
|
||||
public Field get(Field obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Field getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Field getByKey(Field obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class KeyValue extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb) { return getRootAsKeyValue(_bb, new KeyValue()); }
|
||||
public static KeyValue getRootAsKeyValue(ByteBuffer _bb, KeyValue obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public KeyValue __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String key() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer keyAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer keyInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public String value() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer valueAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
|
||||
public ByteBuffer valueInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
|
||||
|
||||
public static int createKeyValue(FlatBufferBuilder builder,
|
||||
int keyOffset,
|
||||
int valueOffset) {
|
||||
builder.startTable(2);
|
||||
KeyValue.addValue(builder, valueOffset);
|
||||
KeyValue.addKey(builder, keyOffset);
|
||||
return KeyValue.endKeyValue(builder);
|
||||
}
|
||||
|
||||
public static void startKeyValue(FlatBufferBuilder builder) { builder.startTable(2); }
|
||||
public static void addKey(FlatBufferBuilder builder, int keyOffset) { builder.addOffset(keyOffset); builder.slot(0); }
|
||||
public static void addValue(FlatBufferBuilder builder, int valueOffset) { builder.addOffset(1, valueOffset, 0); }
|
||||
public static int endKeyValue(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // key
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static KeyValue __lookup_by_key(KeyValue obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new KeyValue() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public KeyValue get(int j) { return get(new KeyValue(), j); }
|
||||
public KeyValue get(KeyValue obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public KeyValue getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public KeyValue getByKey(KeyValue obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,137 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Object extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb) { return getRootAsObject(_bb, new Object()); }
|
||||
public static Object getRootAsObject(ByteBuffer _bb, Object obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Object __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Field fields(int j) { return fields(new com.google.flatbuffers.reflection.Field(), j); }
|
||||
public com.google.flatbuffers.reflection.Field fields(com.google.flatbuffers.reflection.Field obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int fieldsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Field fieldsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Field fieldsByKey(com.google.flatbuffers.reflection.Field obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Field.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Field.Vector fieldsVector() { return fieldsVector(new com.google.flatbuffers.reflection.Field.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Field.Vector fieldsVector(com.google.flatbuffers.reflection.Field.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public boolean isStruct() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public int minalign() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public int bytesize() { int o = __offset(12); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(16); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(16); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(16); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Object is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(18, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 18, 1); }
|
||||
|
||||
public static int createObject(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int fieldsOffset,
|
||||
boolean isStruct,
|
||||
int minalign,
|
||||
int bytesize,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(8);
|
||||
Object.addDeclarationFile(builder, declarationFileOffset);
|
||||
Object.addDocumentation(builder, documentationOffset);
|
||||
Object.addAttributes(builder, attributesOffset);
|
||||
Object.addBytesize(builder, bytesize);
|
||||
Object.addMinalign(builder, minalign);
|
||||
Object.addFields(builder, fieldsOffset);
|
||||
Object.addName(builder, nameOffset);
|
||||
Object.addIsStruct(builder, isStruct);
|
||||
return Object.endObject(builder);
|
||||
}
|
||||
|
||||
public static void startObject(FlatBufferBuilder builder) { builder.startTable(8); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addFields(FlatBufferBuilder builder, int fieldsOffset) { builder.addOffset(1, fieldsOffset, 0); }
|
||||
public static int createFieldsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startFieldsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addIsStruct(FlatBufferBuilder builder, boolean isStruct) { builder.addBoolean(2, isStruct, false); }
|
||||
public static void addMinalign(FlatBufferBuilder builder, int minalign) { builder.addInt(3, minalign, 0); }
|
||||
public static void addBytesize(FlatBufferBuilder builder, int bytesize) { builder.addInt(4, bytesize, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(5, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(6, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(7, declarationFileOffset, 0); }
|
||||
public static int endObject(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // fields
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Object __lookup_by_key(Object obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Object() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Object get(int j) { return get(new Object(), j); }
|
||||
public Object get(Object obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Object getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Object getByKey(Object obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,115 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class RPCCall extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb) { return getRootAsRPCCall(_bb, new RPCCall()); }
|
||||
public static RPCCall getRootAsRPCCall(ByteBuffer _bb, RPCCall obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public RPCCall __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.Object request() { return request(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object request(com.google.flatbuffers.reflection.Object obj) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object response() { return response(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object response(com.google.flatbuffers.reflection.Object obj) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(10); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(10); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(12); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(12); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(12); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createRPCCall(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int requestOffset,
|
||||
int responseOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset) {
|
||||
builder.startTable(5);
|
||||
RPCCall.addDocumentation(builder, documentationOffset);
|
||||
RPCCall.addAttributes(builder, attributesOffset);
|
||||
RPCCall.addResponse(builder, responseOffset);
|
||||
RPCCall.addRequest(builder, requestOffset);
|
||||
RPCCall.addName(builder, nameOffset);
|
||||
return RPCCall.endRPCCall(builder);
|
||||
}
|
||||
|
||||
public static void startRPCCall(FlatBufferBuilder builder) { builder.startTable(5); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addRequest(FlatBufferBuilder builder, int requestOffset) { builder.addOffset(1, requestOffset, 0); }
|
||||
public static void addResponse(FlatBufferBuilder builder, int responseOffset) { builder.addOffset(2, responseOffset, 0); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(3, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(4, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endRPCCall(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
builder.required(o, 6); // request
|
||||
builder.required(o, 8); // response
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static RPCCall __lookup_by_key(RPCCall obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new RPCCall() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public RPCCall get(int j) { return get(new RPCCall(), j); }
|
||||
public RPCCall get(RPCCall obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public RPCCall getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public RPCCall getByKey(RPCCall obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,127 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Schema extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Schema getRootAsSchema(ByteBuffer _bb) { return getRootAsSchema(_bb, new Schema()); }
|
||||
public static Schema getRootAsSchema(ByteBuffer _bb, Schema obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public static boolean SchemaBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "BFBS"); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Schema __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public com.google.flatbuffers.reflection.Object objects(int j) { return objects(new com.google.flatbuffers.reflection.Object(), j); }
|
||||
public com.google.flatbuffers.reflection.Object objects(com.google.flatbuffers.reflection.Object obj, int j) { int o = __offset(4); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int objectsLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Object objectsByKey(String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object objectsByKey(com.google.flatbuffers.reflection.Object obj, String key) { int o = __offset(4); return o != 0 ? com.google.flatbuffers.reflection.Object.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Object.Vector objectsVector() { return objectsVector(new com.google.flatbuffers.reflection.Object.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Object.Vector objectsVector(com.google.flatbuffers.reflection.Object.Vector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum enums(int j) { return enums(new com.google.flatbuffers.reflection.Enum(), j); }
|
||||
public com.google.flatbuffers.reflection.Enum enums(com.google.flatbuffers.reflection.Enum obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int enumsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Enum enumsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum enumsByKey(com.google.flatbuffers.reflection.Enum obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.Enum.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Enum.Vector enumsVector() { return enumsVector(new com.google.flatbuffers.reflection.Enum.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Enum.Vector enumsVector(com.google.flatbuffers.reflection.Enum.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String fileIdent() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer fileIdentAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
|
||||
public ByteBuffer fileIdentInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
|
||||
public String fileExt() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer fileExtAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
|
||||
public ByteBuffer fileExtInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
|
||||
public com.google.flatbuffers.reflection.Object rootTable() { return rootTable(new com.google.flatbuffers.reflection.Object()); }
|
||||
public com.google.flatbuffers.reflection.Object rootTable(com.google.flatbuffers.reflection.Object obj) { int o = __offset(12); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service services(int j) { return services(new com.google.flatbuffers.reflection.Service(), j); }
|
||||
public com.google.flatbuffers.reflection.Service services(com.google.flatbuffers.reflection.Service obj, int j) { int o = __offset(14); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int servicesLength() { int o = __offset(14); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.Service servicesByKey(String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service servicesByKey(com.google.flatbuffers.reflection.Service obj, String key) { int o = __offset(14); return o != 0 ? com.google.flatbuffers.reflection.Service.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.Service.Vector servicesVector() { return servicesVector(new com.google.flatbuffers.reflection.Service.Vector()); }
|
||||
public com.google.flatbuffers.reflection.Service.Vector servicesVector(com.google.flatbuffers.reflection.Service.Vector obj) { int o = __offset(14); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public long advancedFeatures() { int o = __offset(16); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
|
||||
/**
|
||||
* All the files used in this compilation. Files are relative to where
|
||||
* flatc was invoked.
|
||||
*/
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFiles(int j) { return fbsFiles(new com.google.flatbuffers.reflection.SchemaFile(), j); }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFiles(com.google.flatbuffers.reflection.SchemaFile obj, int j) { int o = __offset(18); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int fbsFilesLength() { int o = __offset(18); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile fbsFilesByKey(com.google.flatbuffers.reflection.SchemaFile obj, String key) { int o = __offset(18); return o != 0 ? com.google.flatbuffers.reflection.SchemaFile.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector() { return fbsFilesVector(new com.google.flatbuffers.reflection.SchemaFile.Vector()); }
|
||||
public com.google.flatbuffers.reflection.SchemaFile.Vector fbsFilesVector(com.google.flatbuffers.reflection.SchemaFile.Vector obj) { int o = __offset(18); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createSchema(FlatBufferBuilder builder,
|
||||
int objectsOffset,
|
||||
int enumsOffset,
|
||||
int fileIdentOffset,
|
||||
int fileExtOffset,
|
||||
int rootTableOffset,
|
||||
int servicesOffset,
|
||||
long advancedFeatures,
|
||||
int fbsFilesOffset) {
|
||||
builder.startTable(8);
|
||||
Schema.addAdvancedFeatures(builder, advancedFeatures);
|
||||
Schema.addFbsFiles(builder, fbsFilesOffset);
|
||||
Schema.addServices(builder, servicesOffset);
|
||||
Schema.addRootTable(builder, rootTableOffset);
|
||||
Schema.addFileExt(builder, fileExtOffset);
|
||||
Schema.addFileIdent(builder, fileIdentOffset);
|
||||
Schema.addEnums(builder, enumsOffset);
|
||||
Schema.addObjects(builder, objectsOffset);
|
||||
return Schema.endSchema(builder);
|
||||
}
|
||||
|
||||
public static void startSchema(FlatBufferBuilder builder) { builder.startTable(8); }
|
||||
public static void addObjects(FlatBufferBuilder builder, int objectsOffset) { builder.addOffset(0, objectsOffset, 0); }
|
||||
public static int createObjectsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startObjectsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addEnums(FlatBufferBuilder builder, int enumsOffset) { builder.addOffset(1, enumsOffset, 0); }
|
||||
public static int createEnumsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startEnumsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addFileIdent(FlatBufferBuilder builder, int fileIdentOffset) { builder.addOffset(2, fileIdentOffset, 0); }
|
||||
public static void addFileExt(FlatBufferBuilder builder, int fileExtOffset) { builder.addOffset(3, fileExtOffset, 0); }
|
||||
public static void addRootTable(FlatBufferBuilder builder, int rootTableOffset) { builder.addOffset(4, rootTableOffset, 0); }
|
||||
public static void addServices(FlatBufferBuilder builder, int servicesOffset) { builder.addOffset(5, servicesOffset, 0); }
|
||||
public static int createServicesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startServicesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAdvancedFeatures(FlatBufferBuilder builder, long advancedFeatures) { builder.addLong(6, advancedFeatures, 0L); }
|
||||
public static void addFbsFiles(FlatBufferBuilder builder, int fbsFilesOffset) { builder.addOffset(7, fbsFilesOffset, 0); }
|
||||
public static int createFbsFilesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startFbsFilesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endSchema(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // objects
|
||||
builder.required(o, 6); // enums
|
||||
return o;
|
||||
}
|
||||
public static void finishSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset, "BFBS"); }
|
||||
public static void finishSizePrefixedSchemaBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset, "BFBS"); }
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Schema get(int j) { return get(new Schema(), j); }
|
||||
public Schema get(Schema obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,102 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
* File specific information.
|
||||
* Symbols declared within a file may be recovered by iterating over all
|
||||
* symbols and examining the `declaration_file` field.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public final class SchemaFile extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb) { return getRootAsSchemaFile(_bb, new SchemaFile()); }
|
||||
public static SchemaFile getRootAsSchemaFile(ByteBuffer _bb, SchemaFile obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public SchemaFile __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
/**
|
||||
* Filename, relative to project root.
|
||||
*/
|
||||
public String filename() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer filenameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer filenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
/**
|
||||
* Names of included files, relative to project root.
|
||||
*/
|
||||
public String includedFilenames(int j) { int o = __offset(6); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int includedFilenamesLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector includedFilenamesVector() { return includedFilenamesVector(new StringVector()); }
|
||||
public StringVector includedFilenamesVector(StringVector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
|
||||
public static int createSchemaFile(FlatBufferBuilder builder,
|
||||
int filenameOffset,
|
||||
int includedFilenamesOffset) {
|
||||
builder.startTable(2);
|
||||
SchemaFile.addIncludedFilenames(builder, includedFilenamesOffset);
|
||||
SchemaFile.addFilename(builder, filenameOffset);
|
||||
return SchemaFile.endSchemaFile(builder);
|
||||
}
|
||||
|
||||
public static void startSchemaFile(FlatBufferBuilder builder) { builder.startTable(2); }
|
||||
public static void addFilename(FlatBufferBuilder builder, int filenameOffset) { builder.addOffset(filenameOffset); builder.slot(0); }
|
||||
public static void addIncludedFilenames(FlatBufferBuilder builder, int includedFilenamesOffset) { builder.addOffset(1, includedFilenamesOffset, 0); }
|
||||
public static int createIncludedFilenamesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startIncludedFilenamesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static int endSchemaFile(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // filename
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static SchemaFile __lookup_by_key(SchemaFile obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new SchemaFile() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public SchemaFile get(int j) { return get(new SchemaFile(), j); }
|
||||
public SchemaFile get(SchemaFile obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public SchemaFile getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public SchemaFile getByKey(SchemaFile obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,124 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Service extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Service getRootAsService(ByteBuffer _bb) { return getRootAsService(_bb, new Service()); }
|
||||
public static Service getRootAsService(ByteBuffer _bb, Service obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Service __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public String name() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); }
|
||||
public com.google.flatbuffers.reflection.RPCCall calls(int j) { return calls(new com.google.flatbuffers.reflection.RPCCall(), j); }
|
||||
public com.google.flatbuffers.reflection.RPCCall calls(com.google.flatbuffers.reflection.RPCCall obj, int j) { int o = __offset(6); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int callsLength() { int o = __offset(6); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.RPCCall callsByKey(String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.RPCCall callsByKey(com.google.flatbuffers.reflection.RPCCall obj, String key) { int o = __offset(6); return o != 0 ? com.google.flatbuffers.reflection.RPCCall.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.RPCCall.Vector callsVector() { return callsVector(new com.google.flatbuffers.reflection.RPCCall.Vector()); }
|
||||
public com.google.flatbuffers.reflection.RPCCall.Vector callsVector(com.google.flatbuffers.reflection.RPCCall.Vector obj) { int o = __offset(6); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(int j) { return attributes(new com.google.flatbuffers.reflection.KeyValue(), j); }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributes(com.google.flatbuffers.reflection.KeyValue obj, int j) { int o = __offset(8); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int attributesLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(null, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue attributesByKey(com.google.flatbuffers.reflection.KeyValue obj, String key) { int o = __offset(8); return o != 0 ? com.google.flatbuffers.reflection.KeyValue.__lookup_by_key(obj, __vector(o), key, bb) : null; }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector() { return attributesVector(new com.google.flatbuffers.reflection.KeyValue.Vector()); }
|
||||
public com.google.flatbuffers.reflection.KeyValue.Vector attributesVector(com.google.flatbuffers.reflection.KeyValue.Vector obj) { int o = __offset(8); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
public String documentation(int j) { int o = __offset(10); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int documentationLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
|
||||
public StringVector documentationVector() { return documentationVector(new StringVector()); }
|
||||
public StringVector documentationVector(StringVector obj) { int o = __offset(10); return o != 0 ? obj.__assign(__vector(o), 4, bb) : null; }
|
||||
/**
|
||||
* File that this Service is declared in.
|
||||
*/
|
||||
public String declarationFile() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer declarationFileAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
|
||||
public ByteBuffer declarationFileInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
|
||||
|
||||
public static int createService(FlatBufferBuilder builder,
|
||||
int nameOffset,
|
||||
int callsOffset,
|
||||
int attributesOffset,
|
||||
int documentationOffset,
|
||||
int declarationFileOffset) {
|
||||
builder.startTable(5);
|
||||
Service.addDeclarationFile(builder, declarationFileOffset);
|
||||
Service.addDocumentation(builder, documentationOffset);
|
||||
Service.addAttributes(builder, attributesOffset);
|
||||
Service.addCalls(builder, callsOffset);
|
||||
Service.addName(builder, nameOffset);
|
||||
return Service.endService(builder);
|
||||
}
|
||||
|
||||
public static void startService(FlatBufferBuilder builder) { builder.startTable(5); }
|
||||
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(nameOffset); builder.slot(0); }
|
||||
public static void addCalls(FlatBufferBuilder builder, int callsOffset) { builder.addOffset(1, callsOffset, 0); }
|
||||
public static int createCallsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startCallsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addAttributes(FlatBufferBuilder builder, int attributesOffset) { builder.addOffset(2, attributesOffset, 0); }
|
||||
public static int createAttributesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startAttributesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDocumentation(FlatBufferBuilder builder, int documentationOffset) { builder.addOffset(3, documentationOffset, 0); }
|
||||
public static int createDocumentationVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startDocumentationVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addDeclarationFile(FlatBufferBuilder builder, int declarationFileOffset) { builder.addOffset(4, declarationFileOffset, 0); }
|
||||
public static int endService(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
builder.required(o, 4); // name
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int keysCompare(Integer o1, Integer o2, ByteBuffer _bb) { return compareStrings(__offset(4, o1, _bb), __offset(4, o2, _bb), _bb); }
|
||||
|
||||
public static Service __lookup_by_key(Service obj, int vectorLocation, String key, ByteBuffer bb) {
|
||||
byte[] byteKey = key.getBytes(java.nio.charset.StandardCharsets.UTF_8);
|
||||
int span = bb.getInt(vectorLocation - 4);
|
||||
int start = 0;
|
||||
while (span != 0) {
|
||||
int middle = span / 2;
|
||||
int tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb);
|
||||
int comp = compareStrings(__offset(4, bb.capacity() - tableOffset, bb), byteKey, bb);
|
||||
if (comp > 0) {
|
||||
span = middle;
|
||||
} else if (comp < 0) {
|
||||
middle++;
|
||||
start += middle;
|
||||
span -= middle;
|
||||
} else {
|
||||
return (obj == null ? new Service() : obj).__assign(tableOffset, bb);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Service get(int j) { return get(new Service(), j); }
|
||||
public Service get(Service obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
public Service getByKey(String key) { return __lookup_by_key(null, __vector(), key, bb); }
|
||||
public Service getByKey(Service obj, String key) { return __lookup_by_key(obj, __vector(), key, bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1,79 +0,0 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
package com.google.flatbuffers.reflection;
|
||||
|
||||
import com.google.flatbuffers.BaseVector;
|
||||
import com.google.flatbuffers.BooleanVector;
|
||||
import com.google.flatbuffers.ByteVector;
|
||||
import com.google.flatbuffers.Constants;
|
||||
import com.google.flatbuffers.DoubleVector;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.FloatVector;
|
||||
import com.google.flatbuffers.IntVector;
|
||||
import com.google.flatbuffers.LongVector;
|
||||
import com.google.flatbuffers.ShortVector;
|
||||
import com.google.flatbuffers.StringVector;
|
||||
import com.google.flatbuffers.Struct;
|
||||
import com.google.flatbuffers.Table;
|
||||
import com.google.flatbuffers.UnionVector;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Type extends Table {
|
||||
public static void ValidateVersion() { Constants.FLATBUFFERS_24_3_25(); }
|
||||
public static Type getRootAsType(ByteBuffer _bb) { return getRootAsType(_bb, new Type()); }
|
||||
public static Type getRootAsType(ByteBuffer _bb, Type obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
|
||||
public Type __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
public byte baseType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
|
||||
public byte element() { int o = __offset(6); return o != 0 ? bb.get(o + bb_pos) : 0; }
|
||||
public int index() { int o = __offset(8); return o != 0 ? bb.getInt(o + bb_pos) : -1; }
|
||||
public int fixedLength() { int o = __offset(10); return o != 0 ? bb.getShort(o + bb_pos) & 0xFFFF : 0; }
|
||||
/**
|
||||
* The size (octets) of the `base_type` field.
|
||||
*/
|
||||
public long baseSize() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 4L; }
|
||||
/**
|
||||
* The size (octets) of the `element` field, if present.
|
||||
*/
|
||||
public long elementSize() { int o = __offset(14); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; }
|
||||
|
||||
public static int createType(FlatBufferBuilder builder,
|
||||
byte baseType,
|
||||
byte element,
|
||||
int index,
|
||||
int fixedLength,
|
||||
long baseSize,
|
||||
long elementSize) {
|
||||
builder.startTable(6);
|
||||
Type.addElementSize(builder, elementSize);
|
||||
Type.addBaseSize(builder, baseSize);
|
||||
Type.addIndex(builder, index);
|
||||
Type.addFixedLength(builder, fixedLength);
|
||||
Type.addElement(builder, element);
|
||||
Type.addBaseType(builder, baseType);
|
||||
return Type.endType(builder);
|
||||
}
|
||||
|
||||
public static void startType(FlatBufferBuilder builder) { builder.startTable(6); }
|
||||
public static void addBaseType(FlatBufferBuilder builder, byte baseType) { builder.addByte(0, baseType, 0); }
|
||||
public static void addElement(FlatBufferBuilder builder, byte element) { builder.addByte(1, element, 0); }
|
||||
public static void addIndex(FlatBufferBuilder builder, int index) { builder.addInt(2, index, -1); }
|
||||
public static void addFixedLength(FlatBufferBuilder builder, int fixedLength) { builder.addShort(3, (short) fixedLength, (short) 0); }
|
||||
public static void addBaseSize(FlatBufferBuilder builder, long baseSize) { builder.addInt(4, (int) baseSize, (int) 4L); }
|
||||
public static void addElementSize(FlatBufferBuilder builder, long elementSize) { builder.addInt(5, (int) elementSize, (int) 0L); }
|
||||
public static int endType(FlatBufferBuilder builder) {
|
||||
int o = builder.endTable();
|
||||
return o;
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
|
||||
|
||||
public Type get(int j) { return get(new Type(), j); }
|
||||
public Type get(Type obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
|
||||
}
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
../../../../tests/DictionaryLookup
|
1533
third_party/flatbuffers/java/src/test/java/JavaTest.java
vendored
1533
third_party/flatbuffers/java/src/test/java/JavaTest.java
vendored
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
../../../../tests/MyGame
|
@ -1 +0,0 @@
|
||||
../../../../tests/namespace_test/NamespaceA
|
@ -1 +0,0 @@
|
||||
../../../../tests/namespace_test/NamespaceC
|
@ -1 +0,0 @@
|
||||
../../../../tests/optional_scalars
|
@ -1 +0,0 @@
|
||||
../../../../tests/union_vector
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user