2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.io
;
20 import java
.io
.IOException
;
21 import java
.nio
.ByteBuffer
;
23 import org
.apache
.yetus
.audience
.InterfaceAudience
;
26 * This interface marks a class to support writing ByteBuffers into it.
27 * @see ByteArrayOutputStream
28 * @see ByteBufferOutputStream
30 @InterfaceAudience.Private
31 public interface ByteBufferWriter
{
34 * Writes <code>len</code> bytes from the specified ByteBuffer starting at offset <code>off</code>
37 * @param off the start offset in the data.
38 * @param len the number of bytes to write.
39 * @exception IOException if an I/O error occurs.
41 void write(ByteBuffer b
, int off
, int len
) throws IOException
;
44 * Writes an <code>int</code> to the underlying output stream as four bytes, high byte first.
45 * @param i the <code>int</code> to write
46 * @throws IOException if an I/O error occurs.
48 // This is pure performance oriented API been added here. It has nothing to do with
49 // ByteBuffer and so not fully belong to here. This allows an int to be written at one go instead
50 // of 4 (4 bytes one by one).
51 // TODO remove it from here?
52 void writeInt(int i
) throws IOException
;