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 String. 26 */ 27 public final class StringVector extends BaseVector { 28 private Utf8 utf8 = Utf8.getDefault(); 29 30 /** 31 * Assigns vector access object to vector data. 32 * 33 * @param _vector Start data of a vector. 34 * @param _element_size Size of a vector element. 35 * @param _bb Table's ByteBuffer. 36 * @return Returns current vector access object assigned to vector data whose offset is stored at 37 * `vector`. 38 */ __assign(int _vector, int _element_size, ByteBuffer _bb)39 public StringVector __assign(int _vector, int _element_size, ByteBuffer _bb) { 40 __reset(_vector, _element_size, _bb); return this; 41 } 42 43 /** 44 * Reads the String at the given index. 45 * 46 * @param j The index from which the String value will be read. 47 * @return the String at the given index. 48 */ get(int j)49 public String get(int j) { 50 return Table.__string(__element(j), bb, utf8); 51 } 52 } 53