001    /*
002     * Copyright (c) Andrey Kuznetsov. All Rights Reserved.
003     *
004     * http://uio.imagero.com
005     *
006     * Redistribution and use in source and binary forms, with or without
007     * modification, are permitted provided that the following conditions are met:
008     *
009     *  o Redistributions of source code must retain the above copyright notice,
010     *    this list of conditions and the following disclaimer.
011     *
012     *  o Redistributions in binary form must reproduce the above copyright notice,
013     *    this list of conditions and the following disclaimer in the documentation
014     *    and/or other materials provided with the distribution.
015     *
016     *  o Neither the name of Andrey Kuznetsov nor the names of
017     *    its contributors may be used to endorse or promote products derived
018     *    from this software without specific prior written permission.
019     *
020     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
021     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
022     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
023     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
024     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
027     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
028     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
029     * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
030     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031     */
032    package com.imagero.uio;
033    
034    import java.io.IOException;
035    
036    /**
037     * This interface contains methods useful both for input and output,
038     * but itself cannot be clasified neither as input nor as output.
039     * The name "ISeekable" is rather misleading.
040     *
041     * @author Andrey Kuznetsov
042     */
043    public interface ISeekable {
044    
045        final int BIG_ENDIAN = 0x4D4D;
046        final int LITTLE_ENDIAN = 0x4949;
047    
048        /**
049         * get byte order
050         *
051         * @return #BIG_ENDIAN or #LITTLE_ENDIAN
052         *
053         * @see #BIG_ENDIAN
054         * @see #LITTLE_ENDIAN
055         */
056        int getByteOrder();
057    
058        /**
059         * set byte order
060         *
061         * @param byteOrder
062         *
063         * @see #BIG_ENDIAN
064         * @see #LITTLE_ENDIAN
065         */
066        void setByteOrder(int byteOrder);
067    
068        /**
069         * Since this is an interface and is not restricted to files, "getFilePointer" is wrong name for this method.
070         * But I leaved it so for easier porting from RandomAccessFile
071         *
072         * @return current cursor position
073         *
074         * @throws java.io.IOException
075         */
076        long getFilePointer() throws IOException;
077    
078        /**
079         * get length of data
080         *
081         * @return data length (in bytes)
082         *
083         * @throws java.io.IOException
084         */
085        long length() throws IOException;
086    
087        /**
088         * set current cursor position to specified <code>offset</code>
089         *
090         * @param offset new cursor position
091         *
092         * @throws java.io.IOException
093         */
094        void seek(long offset) throws IOException;
095    
096        void close() throws IOException;
097    
098        boolean isBuffered();
099    
100    }