1 package com.tapina.robe.runtime; 2 3 import java.awt.*; 4 5 /*** 6 * Created by IntelliJ IDEA. User: gareth Date: Jul 8, 2005 Time: 11:59:38 AM To change this template use File | 7 * Settings | File Templates. 8 */ 9 public abstract class BinaryDataSource { 10 abstract byte getByte(int offset); 11 12 abstract int getWord(int offset); 13 14 /*** 15 * Load a zero-terminated string from memory. Encoding is assumed to be ISO-8859-1. 16 * 17 * @param address 18 * @return String loaded 19 */ 20 public final String getString0(int address) { 21 return getTerminatedString(address, StringTerminator.TERMINATE_0); 22 } 23 24 final String getTerminatedString(int address, StringTerminator terminator) { 25 return getTerminatedString(address, terminator, Integer.MAX_VALUE); 26 } 27 28 abstract String getTerminatedString(int address, StringTerminator stringTerminator, int maxLength); 29 30 public final String getString0_10_13(int address) { 31 return getTerminatedString(address, StringTerminator.TERMINATE_0_10_13); 32 } 33 34 public final String getStringControlTerminated(int offset) { 35 return getTerminatedString(offset, StringTerminator.TERMINATE_CONTROL); 36 } 37 38 public final String getStringControlTerminated(int offset, int length) { 39 return getTerminatedString(offset, StringTerminator.TERMINATE_CONTROL, length); 40 } 41 42 abstract Rectangle getRectangle(int offset); 43 44 abstract Point getPoint(int offset); 45 46 public final String getStringN(int offset, int maxLength) { 47 return getTerminatedString(offset, StringTerminator.TERMINATE_0, maxLength); 48 } 49 50 51 /*** 52 * Get an object which allows direct access to the underlying data block for the specified byte range. 53 * 54 * @param address address for which to find bytes 55 * @param count size of byte block to allow access to 56 * @param create 57 * @return ByteArray which reads/writes through to underlying data block. 58 */ 59 public abstract ByteArray getByteArray(int address, int count, boolean create); 60 61 /*** 62 * Take a copy of a set of bytes from the memory map. 63 * Use {@link #getByteArray(int,int,boolean)} instead for efficiency. 64 * 65 * @param address address at which to load bytes 66 * @param count number of bytes to load 67 * @return array containing bytes loaded from specified address 68 */ 69 public abstract byte[] getBytes(int address, int count); 70 71 public abstract long get5ByteValue(int address); 72 73 public abstract int[] getWords(int address, int count); 74 }