Methods Summary |
---|
public int | readBE24()Read an unsigned big-endian 24-bit value and returns an int.
int iThree = readUnsignedByte();
int iTwo = readUnsignedByte();
int iOne = readUnsignedByte();
int iVal = (iOne | (iTwo << 8) | (iThree << 16));
return iVal;
|
public int | readBE32()Read a signed big-endian 32-bit value and returns an int.
int iFour = readUnsignedByte();
int iThree = readUnsignedByte();
int iTwo = readUnsignedByte();
int iOne = readUnsignedByte();
int iVal = (iOne | (iTwo << 8) | (iThree << 16) | (iFour << 24));
return iVal;
|
public final int | readBEUnsigned16()Reads an unsigned big-endian 16-bit value and returns an int.
int iHi = readUnsignedByte();
int iLo = readUnsignedByte();
int iVal = iLo | (iHi << 8);
return iVal;
|
public int | readID3Four()Read an encoded four byte value.
The encoding method uses only the lowest seven bits of each byte, to prevent synchronization
errors in the MP3 data stream.
int iValue = 0;
byte[] abyValue = new byte[4];
readFully(abyValue);
if ( ((abyValue[0] & 0x80) != 0) ||
((abyValue[1] & 0x80) != 0) ||
((abyValue[2] & 0x80) != 0) ||
((abyValue[3] & 0x80) != 0) )
{
throw new ID3Exception("High bit cannot be set in encoded values.");
}
iValue |= ((abyValue[0] & 0x7f) << (3 * 7));
iValue |= ((abyValue[1] & 0x7f) << (2 * 7));
iValue |= ((abyValue[2] & 0x7f) << (1 * 7));
iValue |= ((abyValue[3] & 0x7f) << (0 * 7));
return iValue;
|
public java.lang.String | readStringToNull(TextEncoding oTextEncoding, int iMaxLength)Read a string in the specified encoding format to null, not exceeding a predefined length. Note that
Unicode strings must be terminated by a double null (two zero bytes).
if (oTextEncoding == null)
{
throw new NullPointerException("Text encoding cannot be null.");
}
ByteArrayOutputStream oStringBAOS = new ByteArrayOutputStream();
int iStringByte1;
int iStringByte2 = 0;
int iLength = 0;
do
{
iStringByte1 = readUnsignedByte();
if (oTextEncoding.equals(TextEncoding.UNICODE))
{
iStringByte2 = readUnsignedByte();
}
if ((iStringByte1 != 0) || (iStringByte2 != 0))
{
if (iLength == iMaxLength)
{
throw new IOException("String length exceeds set " + iMaxLength + " byte limit.");
}
oStringBAOS.write(iStringByte1);
if (oTextEncoding.equals(TextEncoding.UNICODE))
{
oStringBAOS.write(iStringByte2);
}
iLength++;
}
}
while ((iStringByte1 != 0) || (iStringByte2 != 0)) ;
// return byte array as a string
byte[] abyShortDescription = oStringBAOS.toByteArray();
return new String(abyShortDescription, oTextEncoding.getEncodingString());
|
public java.lang.String | readStringToNull()Read an ISO-8859-1 encoded string to null.
return readStringToNull(Integer.MAX_VALUE);
|
public java.lang.String | readStringToNull(int iMaxLength)Read an ISO-8859-1 string to null, not exceeding a predefined length.
ByteArrayOutputStream oStringBAOS = new ByteArrayOutputStream();
int iStringByte;
do
{
iStringByte = readUnsignedByte();
if (iStringByte != 0)
{
if (oStringBAOS.size() == iMaxLength)
{
throw new IOException("String length exceeds set " + iMaxLength + " byte limit.");
}
oStringBAOS.write(iStringByte);
}
}
while (iStringByte != 0);
// return byte array as a string
byte[] abyShortDescription = oStringBAOS.toByteArray();
return new String(abyShortDescription);
|
public java.lang.String | readStringToNull(TextEncoding oTextEncoding)Read a string in the specified encoding format to null. Note that Unicode strings must be terminated by
a double null (two zero bytes).
return readStringToNull(oTextEncoding, Integer.MAX_VALUE);
|
public long | readUnsignedBE32()Read an unsigned big-endian 32-bit value and returns a long.
long lFour = readUnsignedByte();
long lThree = readUnsignedByte();
long lTwo = readUnsignedByte();
long lOne = readUnsignedByte();
long lVal = (lOne | (lTwo << 8) | (lThree << 16) | (lFour << 24));
return lVal;
|