Changeset 8243 in josm for trunk/src/com/drew/lang
- Timestamp:
- 2015-04-21T00:42:50+02:00 (9 years ago)
- Location:
- trunk/src/com/drew/lang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/lang/RandomAccessReader.java
r8132 r8243 127 127 128 128 /** 129 * Gets whether a bit at a specific index is set or not. 130 * 131 * @param index the number of bits at which to test 132 * @return true if the bit is set, otherwise false 133 * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative 134 */ 135 public boolean getBit(int index) throws IOException 136 { 137 int byteIndex = index / 8; 138 int bitIndex = index % 8; 139 140 validateIndex(byteIndex, 1); 141 142 byte b = getByte(byteIndex); 143 return ((b >> bitIndex) & 1) == 1; 144 } 145 146 /** 129 147 * Returns an unsigned 8-bit int calculated from one byte of data at the specified index. 130 148 * … … 195 213 return (short) (((short)getByte(index + 1) << 8 & (short)0xFF00) | 196 214 ((short)getByte(index ) & (short)0xFF)); 215 } 216 } 217 218 /** 219 * Get a 24-bit unsigned integer from the buffer, returning it as an int. 220 * 221 * @param index position within the data buffer to read first byte 222 * @return the unsigned 24-bit int value as a long, between 0x00000000 and 0x00FFFFFF 223 * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative 224 */ 225 public int getInt24(int index) throws IOException 226 { 227 validateIndex(index, 3); 228 229 if (_isMotorolaByteOrder) { 230 // Motorola - MSB first (big endian) 231 return (((int)getByte(index )) << 16 & 0xFF0000) | 232 (((int)getByte(index + 1)) << 8 & 0xFF00) | 233 (((int)getByte(index + 2)) & 0xFF); 234 } else { 235 // Intel ordering - LSB first (little endian) 236 return (((int)getByte(index + 2)) << 16 & 0xFF0000) | 237 (((int)getByte(index + 1)) << 8 & 0xFF00) | 238 (((int)getByte(index )) & 0xFF); 197 239 } 198 240 } -
trunk/src/com/drew/lang/SequentialByteArrayReader.java
r8132 r8243 37 37 private int _index; 38 38 39 public SequentialByteArrayReader(@NotNull byte[] bytes) 40 { 41 this(bytes, 0); 42 } 43 39 44 @SuppressWarnings("ConstantConditions") 40 public SequentialByteArrayReader(@NotNull byte[] bytes )45 public SequentialByteArrayReader(@NotNull byte[] bytes, int baseIndex) 41 46 { 42 47 if (bytes == null) … … 44 49 45 50 _bytes = bytes; 46 _index = 0;51 _index = baseIndex; 47 52 } 48 53
Note:
See TracChangeset
for help on using the changeset viewer.