Changeset 8243 in josm for trunk/src/com/drew/lang


Ignore:
Timestamp:
2015-04-21T00:42:50+02:00 (9 years ago)
Author:
Don-vip
Message:

fix #11359 - update to metadata-extractor 2.8.1

Location:
trunk/src/com/drew/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/lang/RandomAccessReader.java

    r8132 r8243  
    127127
    128128    /**
     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    /**
    129147     * Returns an unsigned 8-bit int calculated from one byte of data at the specified index.
    130148     *
     
    195213            return (short) (((short)getByte(index + 1) << 8 & (short)0xFF00) |
    196214                            ((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);
    197239        }
    198240    }
  • trunk/src/com/drew/lang/SequentialByteArrayReader.java

    r8132 r8243  
    3737    private int _index;
    3838
     39    public SequentialByteArrayReader(@NotNull byte[] bytes)
     40    {
     41        this(bytes, 0);
     42    }
     43
    3944    @SuppressWarnings("ConstantConditions")
    40     public SequentialByteArrayReader(@NotNull byte[] bytes)
     45    public SequentialByteArrayReader(@NotNull byte[] bytes, int baseIndex)
    4146    {
    4247        if (bytes == null)
     
    4449
    4550        _bytes = bytes;
    46         _index = 0;
     51        _index = baseIndex;
    4752    }
    4853
Note: See TracChangeset for help on using the changeset viewer.