Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2019 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.google.flatbuffers; |
| 18 | |
| 19 | import static com.google.flatbuffers.Constants.*; |
| 20 | import java.nio.ByteBuffer; |
| 21 | import java.nio.ByteOrder; |
| 22 | import java.nio.charset.Charset; |
| 23 | |
| 24 | /** |
| 25 | * Helper type for accessing vector of unions. |
| 26 | */ |
| 27 | public final class UnionVector extends BaseVector { |
| 28 | /** |
| 29 | * Assigns vector access object to vector data. |
| 30 | * |
| 31 | * @param _vector Start data of a vector. |
| 32 | * @param _element_size Size of a vector element. |
| 33 | * @param _bb Table's ByteBuffer. |
| 34 | * @return Returns current vector access object assigned to vector data whose offset is stored at |
| 35 | * `vector`. |
| 36 | */ |
| 37 | public UnionVector __assign(int _vector, int _element_size, ByteBuffer _bb) { |
| 38 | __reset(_vector, _element_size, _bb); return this; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Initialize any Table-derived type to point to the union at the given `index`. |
| 44 | * |
| 45 | * @param obj A `Table`-derived type that should point to the union at `index`. |
| 46 | * @param j An `int` index into the union vector. |
| 47 | * @return Returns the Table that points to the union at `index`. |
| 48 | */ |
| 49 | public Table get(Table obj, int j) { |
| 50 | return Table.__union(obj, __element(j), bb); |
| 51 | } |
| 52 | } |