1 /* 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 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.mina.util.byteaccess; 21 22 import java.nio.ByteOrder; 23 24 import org.apache.mina.core.buffer.IoBuffer; 25 26 /** 27 * Provides relative read access to a sequence of bytes. 28 * 29 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 30 */ 31 public interface IoRelativeReader { 32 33 /** 34 * @return the number of remaining bytes that can be read. 35 */ 36 int getRemaining(); 37 38 /** 39 * Checks if there are any remaining bytes that can be read. 40 * 41 * @return <tt>true</tt> if there are some remaining bytes in the buffer 42 */ 43 boolean hasRemaining(); 44 45 /** 46 * Advances the reader by the given number of bytes. 47 * 48 * @param length the number of bytes to skip 49 */ 50 void skip(int length); 51 52 /** 53 * @param length The number of bytes to get 54 * @return an array with a view of part of this array. 55 */ 56 ByteArray slice(int length); 57 58 /** 59 * @return the bytes' order 60 */ 61 ByteOrder order(); 62 63 /** 64 * @return the <code>byte</code> at the current position and advances the reader. 65 */ 66 byte get(); 67 68 /** 69 * Gets enough bytes to fill the <code>IoBuffer</code> and advances the reader. 70 * 71 * @param bb The IoBuffer that will contain the read bytes 72 */ 73 void get(IoBuffer bb); 74 75 /** 76 * @return a <code>short</code> and advances the reader. 77 */ 78 short getShort(); 79 80 /** 81 * @return an <code>int</code> and advances the reader. 82 */ 83 int getInt(); 84 85 /** 86 * @return a <code>long</code> and advances the reader. 87 */ 88 long getLong(); 89 90 /** 91 * @return a <code>float</code> and advances the reader. 92 */ 93 float getFloat(); 94 95 /** 96 * @return a <code>double</code> and advances the reader. 97 */ 98 double getDouble(); 99 100 /** 101 * @return a <code>char</code> and advances the reader. 102 */ 103 char getChar(); 104 }