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 IoRelativeWriter {
032
033    /**
034     * @return the number of remaining bytes that can be read.
035     */
036    int getRemaining();
037
038    /**
039     * @return if there are any remaining bytes that can be read.
040     */
041    boolean hasRemaining();
042
043    /**
044     * Advances the writer by the given number of bytes.
045     * 
046     * @param length The number of bytes to skip
047     */
048    void skip(int length);
049
050    /**
051     * @return the bytes' order
052     */
053    ByteOrder order();
054
055    /**
056     * Puts a <code>byte</code> and advances the reader.
057     * 
058     * @param b The byte to put
059     */
060    void put(byte b);
061
062    /**
063     * Puts enough bytes to fill the <code>IoBuffer</code> and advances the reader.
064     * 
065     * @param bb The bytes to put
066     */
067    void put(IoBuffer bb);
068
069    /**
070     * Puts a <code>short</code> and advances the reader.
071     * 
072     * @param s The short to put
073     */
074    void putShort(short s);
075
076    /**
077     * Puts an <code>int</code> and advances the reader.
078     * 
079     * @param i The int to put
080     */
081    void putInt(int i);
082
083    /**
084     * Puts a <code>long</code> and advances the reader.
085     * 
086     * @param l The long to put
087     */
088    void putLong(long l);
089
090    /**
091     * Puts a <code>float</code> and advances the reader.
092     * 
093     * @param f The float to put
094     */
095    void putFloat(float f);
096
097    /**
098     * Puts a <code>double</code> and advances the reader.
099     * 
100     * @param d The double to put
101     */
102    void putDouble(double d);
103
104    /**
105     * Puts a <code>char</code> and advances the reader.
106     * 
107     * @param c The char to put
108     */
109    void putChar(char c);
110}