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 write access to a sequence of bytes.
028 * 
029 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
030 */
031public interface IoAbsoluteWriter {
032
033    /**
034     * @return the index of the first byte that can be accessed.
035     */
036    int first();
037
038    /**
039     * @return the index after the last byte that can be accessed.
040     */
041    int last();
042
043    /**
044     * @return the order of the bytes.
045     */
046    ByteOrder order();
047
048    /**
049     * Puts a <code>byte</code> at the given index.
050     * 
051     * @param index The position
052     * @param b The byte to put
053     */
054    void put(int index, byte b);
055
056    /**
057     * Puts bytes from the <code>IoBuffer</code> at the given index.
058     * 
059     * @param index The position
060     * @param bb The bytes to put
061     */
062    void put(int index, IoBuffer bb);
063
064    /**
065     * Puts a <code>short</code> at the given index.
066     * 
067     * @param index The position
068     * @param s The short to put
069     */
070    void putShort(int index, short s);
071
072    /**
073     * Puts an <code>int</code> at the given index.
074     * 
075     * @param index The position
076     * @param i The int to put
077     */
078    void putInt(int index, int i);
079
080    /**
081     * Puts a <code>long</code> at the given index.
082     * 
083     * @param index The position
084     * @param l The long to put
085     */
086    void putLong(int index, long l);
087
088    /**
089     * Puts a <code>float</code> at the given index.
090     * 
091     * @param index The position
092     * @param f The float to put
093     */
094    void putFloat(int index, float f);
095
096    /**
097     * Puts a <code>double</code> at the given index.
098     * 
099     * @param index The position
100     * @param d The doubvle to put
101     */
102    void putDouble(int index, double d);
103
104    /**
105     * Puts a <code>char</code> at the given index.
106     * 
107     * @param index The position
108     * @param c The char to put
109     */
110    void putChar(int index, char c);
111}