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

org.hibernate.engine.jdbc.internal.BinaryStreamImpl Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.engine.jdbc.internal;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.hibernate.engine.jdbc.BinaryStream;

/**
 * Implementation of {@link BinaryStream}
 *
 * @author Steve Ebersole
 */
public final class BinaryStreamImpl extends ByteArrayInputStream implements BinaryStream {
	private final int length;

	/**
	 * Constructs a BinaryStreamImpl
	 *
	 * @param bytes The bytes to use backing the stream
	 */
	public BinaryStreamImpl(byte[] bytes) {
		super( bytes );
		this.length = bytes.length;
	}

	public InputStream getInputStream() {
		return this;
	}

	public byte[] getBytes() {
		// from ByteArrayInputStream
		return buf;
	}

	public long getLength() {
		return length;
	}

	@Override
	public void release() {
		try {
			super.close();
		}
		catch (IOException ignore) {
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy