All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.store.storage.restadapter.types.ValueReaderStringList Maven / Gradle / Ivy

package org.eclipse.store.storage.restadapter.types;

/*-
 * #%L
 * EclipseStore Storage REST Adapter
 * %%
 * Copyright (C) 2023 MicroStream Software
 * %%
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 * 
 * SPDX-License-Identifier: EPL-2.0
 * #L%
 */

import org.eclipse.serializer.persistence.binary.types.Binary;
import org.eclipse.serializer.persistence.types.PersistenceTypeDefinitionMember;

public class ValueReaderStringList extends ValueReaderVariableLength
{
	///////////////////////////////////////////////////////////////////////////
	// constructors //
	/////////////////

	public ValueReaderStringList(final PersistenceTypeDefinitionMember member)
	{
		super(member);
	}

	///////////////////////////////////////////////////////////////////////////
	// methods //
	////////////

	@Override
	public Object readValue(final Binary binary, final long offset)
	{
		long listOffset = Binary.toBinaryListElementsOffset(offset);
		final int elementCount = (int) binary.getBinaryListElementCountUnvalidating(offset);

		final String strings[] = new String[elementCount];

		for(int i = 0; i < elementCount; i++)
		{
			final long stringLength = binary.getBinaryListTotalByteLength(listOffset);
			final char[] array = binary.build_chars(listOffset);

			listOffset += stringLength;
			strings[i] = new String(array);
		}

		return strings;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy