return new byte[length]; byte[] result = readValue(EMPTY_BYTE_ARRAY, byte[].class, /* allowNull= */ false); if (result.length != length) {
/** * Reads a long from the byte buffer based on the current data position */ public long readLong() { return readValue(0L); }
/** * Reads a String from the byte buffer based on the current data position */ public String readString() { return readValue(null); }
/** * Reads a float from the byte buffer based on the current data position */ public float readFloat() { return readValue(0f); }
/** * Reads a int from the byte buffer based on the current data position */ public int readInt() { return readValue(0); }
/** * Reads a int from the byte buffer based on the current data position */ public int readInt() { return readValue(0); }
/** * Reads a byte from the byte buffer based on the current data position */ public byte readByte() { return readValue((byte) 0); }
/** * Reads an IBinder from the byte buffer based on the current data position */ public IBinder readStrongBinder() { return readValue(null); }
/** * Reads a float from the byte buffer based on the current data position */ public float readFloat() { return readValue(0f); }
/** * Reads a long from the byte buffer based on the current data position */ public long readLong() { return readValue(0l); }
/** * Reads a byte from the byte buffer based on the current data position */ public byte readByte() { return readValue((byte) 0); }
/** * Reads a double from the byte buffer based on the current data position */ public double readDouble() { return readValue(0d); }
/** * Reads a double from the byte buffer based on the current data position */ public double readDouble() { return readValue(0d); }
/** * Reads a float from the byte buffer based on the current data position */ public float readFloat() { return readValue(0f); }
/** * Reads a String from the byte buffer based on the current data position */ public String readString() { return readValue(null); }
/** * Reads a byte from the byte buffer based on the current data position */ public byte readByte() { return readValue((byte) 0); }
/** * Reads a double from the byte buffer based on the current data position */ public double readDouble() { return readValue(0d); }
/** * Reads a primitive, which may reinterpret zeros of other types. * * @param defaultSizeBytes if reinterpreting zeros, the number of bytes to consume * @param defaultValue the default value for zeros or reading past the end * @param clazz this is the type that is being read, but not checked in this method */ private <T> T readPrimitive(int defaultSizeBytes, T defaultValue, Class<T> clazz) { // Check for zeroes first, since partially-overwritten values are not an error for zeroes. if (readZeroes(defaultSizeBytes)) { return defaultValue; } return readValue(defaultValue, clazz, /* allowNull= */ false); }
/** * Reads an IBinder from the byte buffer based on the current data position */ public IBinder readStrongBinder() { return readValue(null, IBinder.class, /* allowNull= */ true); }
/** * Reads a String from the byte buffer based on the current data position */ public String readString() { if (readZeroes(INT_SIZE_BYTES * 2)) { // Empty string is 4 bytes for length of 0, and 4 bytes for null terminator and padding. return ""; } return readValue(null, String.class, /* allowNull= */ true); }