View Javadoc
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 absolute read access to a sequence of bytes.
28   * 
29   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
30   */
31  public interface IoAbsoluteReader {
32  
33      /**
34       * @return the index of the first byte that can be accessed.
35       */
36      int first();
37  
38      /**
39       * @return the index after the last byte that can be accessed.
40       */
41      int last();
42  
43      /**
44       * @return the total number of bytes that can be accessed.
45       */
46      int length();
47  
48      /**
49       * Creates an array with a view of part of this array.
50       * 
51       * @param index The starting position
52       * @param length The number of bytes to copy
53       * @return The ByteArray that is a view on the original array 
54       */
55      ByteArray slice(int index, int length);
56  
57      /**
58       * @return the order of the bytes.
59       */
60      ByteOrder order();
61  
62      /**
63       * @param index The starting position
64       * @return a <tt>byte</tt> from the given index.
65       */
66      byte get(int index);
67  
68      /**
69       * Gets enough bytes to fill the <tt>IoBuffer</tt> from the given index.
70       * 
71       * @param index The starting position
72       * @param bb The IoBuffer that will be filled with the bytes
73       */
74      void get(int index, IoBuffer bb);
75  
76      /**
77       * @param index The starting position
78       * @return a <tt>short</tt> from the given index.
79       */
80      short getShort(int index);
81  
82      /**
83       * @param index The starting position
84       * @return an <tt>int</tt> from the given index.
85       */
86      int getInt(int index);
87  
88      /**
89       * @param index The starting position
90       * @return a <tt>long</tt> from the given index.
91       */
92      long getLong(int index);
93  
94      /**
95       * @param index The starting position
96       * @return a <tt>float</tt> from the given index.
97       */
98      float getFloat(int index);
99  
100     /**
101      * @param index The starting position
102      * @return a <tt>double</tt> from the given index.
103      */
104     double getDouble(int index);
105 
106     /**
107      * @param index The starting position
108      * @return a <tt>char</tt> from the given index.
109      */
110     char getChar(int index);
111 }