BufferIterator.java revision 43a9f774d075e0e441d8b996e3f6c81ea483ec89
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 17package 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 */ 25public abstract class BufferIterator { 26 /** 27 * Skips forwards or backwards {@code byteCount} bytes from the current position. 28 */ 29 public abstract void skip(int byteCount); 30 31 /** 32 * Copies {@code byteCount} bytes from the current position into {@code dst}, starting at 33 * {@code dstOffset}, and advances the current position {@code byteCount} bytes. 34 */ 35 public abstract void readByteArray(byte[] dst, int dstOffset, int byteCount); 36 37 /** 38 * Returns the byte at the current position, and advances the current position one byte. 39 */ 40 public abstract byte readByte(); 41 42 /** 43 * Returns the 32-bit int at the current position, and advances the current position four bytes. 44 */ 45 public abstract int readInt(); 46 47 /** 48 * Copies {@code intCount} 32-bit ints from the current position into {@code dst}, starting at 49 * {@code dstOffset}, and advances the current position {@code 4 * intCount} bytes. 50 */ 51 public abstract void readIntArray(int[] dst, int dstOffset, int intCount); 52 53 /** 54 * Returns the 16-bit short at the current position, and advances the current position two bytes. 55 */ 56 public abstract short readShort(); 57} 58