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, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.util.byteaccess; 021 022import java.nio.ByteOrder; 023 024import org.apache.mina.core.buffer.IoBuffer; 025 026/** 027 * Provides relative read access to a sequence of bytes. 028 * 029 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 030 */ 031public interface IoRelativeReader { 032 033 /** 034 * @return the number of remaining bytes that can be read. 035 */ 036 int getRemaining(); 037 038 /** 039 * Checks if there are any remaining bytes that can be read. 040 * 041 * @return <tt>true</tt> if there are some remaining bytes in the buffer 042 */ 043 boolean hasRemaining(); 044 045 /** 046 * Advances the reader by the given number of bytes. 047 * 048 * @param length the number of bytes to skip 049 */ 050 void skip(int length); 051 052 /** 053 * @param length The number of bytes to get 054 * @return an array with a view of part of this array. 055 */ 056 ByteArray slice(int length); 057 058 /** 059 * @return the bytes' order 060 */ 061 ByteOrder order(); 062 063 /** 064 * @return the <code>byte</code> at the current position and advances the reader. 065 */ 066 byte get(); 067 068 /** 069 * Gets enough bytes to fill the <code>IoBuffer</code> and advances the reader. 070 * 071 * @param bb The IoBuffer that will contain the read bytes 072 */ 073 void get(IoBuffer bb); 074 075 /** 076 * @return a <code>short</code> and advances the reader. 077 */ 078 short getShort(); 079 080 /** 081 * @return an <code>int</code> and advances the reader. 082 */ 083 int getInt(); 084 085 /** 086 * @return a <code>long</code> and advances the reader. 087 */ 088 long getLong(); 089 090 /** 091 * @return a <code>float</code> and advances the reader. 092 */ 093 float getFloat(); 094 095 /** 096 * @return a <code>double</code> and advances the reader. 097 */ 098 double getDouble(); 099 100 /** 101 * @return a <code>char</code> and advances the reader. 102 */ 103 char getChar(); 104}