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 absolute read access to a sequence of bytes.
028 * 
029 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
030 */
031public interface IoAbsoluteReader {
032
033    /**
034     * Get the index of the first byte that can be accessed.
035     */
036    int first();
037
038    /**
039     * Gets the index after the last byte that can be accessed.
040     */
041    int last();
042
043    /**
044     * Gets the total number of bytes that can be accessed.
045     */
046    int length();
047
048    /**
049     * Creates an array with a view of part of this array.
050     */
051    ByteArray slice(int index, int length);
052
053    /**
054     * Gets the order of the bytes.
055     */
056    ByteOrder order();
057
058    /**
059     * Gets a <code>byte</code> from the given index.
060     */
061    byte get(int index);
062
063    /**
064     * Gets enough bytes to fill the <code>IoBuffer</code> from the given index.
065     */
066    public void get(int index, IoBuffer bb);
067
068    /**
069     * Gets a <code>short</code> from the given index.
070     */
071    short getShort(int index);
072
073    /**
074     * Gets an <code>int</code> from the given index.
075     */
076    int getInt(int index);
077
078    /**
079     * Gets a <code>long</code> from the given index.
080     */
081    long getLong(int index);
082
083    /**
084     * Gets a <code>float</code> from the given index.
085     */
086    float getFloat(int index);
087
088    /**
089     * Gets a <code>double</code> from the given index.
090     */
091    double getDouble(int index);
092
093    /**
094     * Gets a <code>char</code> from the given index.
095     */
096    char getChar(int index);
097}