001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.io; 019 020import java.io.IOException; 021import java.nio.ByteBuffer; 022 023import org.apache.yetus.audience.InterfaceAudience; 024 025/** 026 * This interface marks a class to support writing ByteBuffers into it. 027 * @see ByteArrayOutputStream 028 * @see ByteBufferOutputStream 029 */ 030@InterfaceAudience.Private 031public interface ByteBufferWriter { 032 033 /** 034 * Writes <code>len</code> bytes from the specified ByteBuffer starting at offset <code>off</code> 035 * 036 * @param b the data. 037 * @param off the start offset in the data. 038 * @param len the number of bytes to write. 039 * @exception IOException if an I/O error occurs. 040 */ 041 void write(ByteBuffer b, int off, int len) throws IOException; 042 043 /** 044 * Writes an <code>int</code> to the underlying output stream as four bytes, high byte first. 045 * @param i the <code>int</code> to write 046 * @throws IOException if an I/O error occurs. 047 */ 048 // This is pure performance oriented API been added here. It has nothing to do with 049 // ByteBuffer and so not fully belong to here. This allows an int to be written at one go instead 050 // of 4 (4 bytes one by one). 051 // TODO remove it from here? 052 void writeInt(int i) throws IOException; 053}