Path: blob/master/src/java.base/share/classes/sun/nio/ByteBuffered.java
41153 views
/*1* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio;2627import java.nio.ByteBuffer;28import java.io.IOException;2930/**31* This is an interface to adapt existing APIs to use {@link java.nio.ByteBuffer32* ByteBuffers} as the underlying data format. Only the initial producer and33* final consumer have to be changed.34*35* <p>36* For example, the Zip/Jar code supports {@link java.io.InputStream InputStreams}.37* To make the Zip code use {@link java.nio.MappedByteBuffer MappedByteBuffers} as38* the underlying data structure, it can create a class of InputStream that wraps39* the ByteBuffer, and implements the ByteBuffered interface. A co-operating class40* several layers away can ask the InputStream if it is an instance of ByteBuffered,41* then call the {@link #getByteBuffer()} method.42*/43public interface ByteBuffered {4445/**46* Returns the {@code ByteBuffer} behind this object, if this particular47* instance has one. An implementation of {@code getByteBuffer()} is allowed48* to return {@code null} for any reason.49*50* @return The {@code ByteBuffer}, if this particular instance has one,51* or {@code null} otherwise.52*53* @throws IOException54* If the ByteBuffer is no longer valid.55*56* @since 1.557*/58public ByteBuffer getByteBuffer() throws IOException;59}606162