1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package libcore.io; 18 19 /** 20 * Iterates over big- or little-endian bytes. See {@link MemoryMappedFile#bigEndianIterator} and 21 * {@link MemoryMappedFile#littleEndianIterator}. 22 * 23 * @hide don't make this public without adding bounds checking. 24 */ 25 public abstract class BufferIterator { 26 /** 27 * Seeks to the absolute position {@code offset}, measured in bytes from the start. 28 */ 29 public abstract void seek(int offset); 30 31 /** 32 * Skips forwards or backwards {@code byteCount} bytes from the current position. 33 */ 34 public abstract void skip(int byteCount); 35 36 /** 37 * Copies {@code byteCount} bytes from the current position into {@code dst}, starting at 38 * {@code dstOffset}, and advances the current position {@code byteCount} bytes. 39 */ 40 public abstract void readByteArray(byte[] dst, int dstOffset, int byteCount); 41 42 /** 43 * Returns the byte at the current position, and advances the current position one byte. 44 */ 45 public abstract byte readByte(); 46 47 /** 48 * Returns the 32-bit int at the current position, and advances the current position four bytes. 49 */ 50 public abstract int readInt(); 51 52 /** 53 * Copies {@code intCount} 32-bit ints from the current position into {@code dst}, starting at 54 * {@code dstOffset}, and advances the current position {@code 4 * intCount} bytes. 55 */ 56 public abstract void readIntArray(int[] dst, int dstOffset, int intCount); 57 58 /** 59 * Returns the 16-bit short at the current position, and advances the current position two bytes. 60 */ 61 public abstract short readShort(); 62 } 63