ByteBuffered.java revision 2362
2976N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 2976N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2976N/A * This code is free software; you can redistribute it and/or modify it 2976N/A * under the terms of the GNU General Public License version 2 only, as 2976N/A * published by the Free Software Foundation. Oracle designates this 2976N/A * particular file as subject to the "Classpath" exception as provided 2976N/A * by Oracle in the LICENSE file that accompanied this code. 2976N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2976N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2976N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2976N/A * version 2 for more details (a copy is included in the LICENSE file that 2976N/A * You should have received a copy of the GNU General Public License version 2976N/A * 2 along with this work; if not, write to the Free Software Foundation, 2976N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2976N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2976N/A * or visit www.oracle.com if you need additional information or have any 2976N/A/** This is an interface to adapt existing APIs to use {@link java.nio.ByteBuffer 2976N/A * <tt>ByteBuffers</tt>} as the underlying 3824N/A * data format. Only the initial producer and final consumer have to be changed.<p> 3824N/A * For example, the Zip/Jar code supports {@link java.io.InputStream <tt>InputStreams</tt>}. 3824N/A * To make the Zip code use {@link java.nio.MappedByteBuffer <tt>MappedByteBuffers</tt>} as 3824N/A * the underlying data structure, it can create a class of InputStream that wraps the ByteBuffer, 3824N/A * and implements the ByteBuffered interface. A co-operating class several layers 3824N/A * away can ask the InputStream if it is an instance of ByteBuffered, then 3824N/A * call the {@link #getByteBuffer()} method. 2976N/A * Returns the <tt>ByteBuffer</tt> behind this object, if this particular 2976N/A * instance has one. An implementation of <tt>getByteBuffer()</tt> is allowed 2976N/A * to return <tt>null</tt> for any reason. 2976N/A * @return The <tt>ByteBuffer</tt>, if this particular instance has one, 3262N/A * or <tt>null</tt> otherwise. 3262N/A * If the ByteBuffer is no longer valid.