Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## helliker.id3
Class BinaryParser

    java.lang.Object
      |
      +--helliker.id3.BinaryParser

public final class BinaryParser
extends java.lang.Object

Constructor Summary
`BinaryParser()`

Method Summary
`static boolean` | `bitSet(byte b, int pos)` Tests to see if the bit at postion pos is set in byte b
`static byte[]` | `convertToBytes(int num)` Convert the integer passed to a array of 4 bytes (32-bits).
`static int` | `convertToDecimal(byte b, int start, int end)` Convert a portion of a byte to an integer.
`static int` | `convertToInt(byte[] b)` Convert an array of bytes into an integer.
`static byte[]` | `convertToSynchsafeBytes(int num)` Converts the integer passed to an array of bytes as specified in section 6.2 of the id3v2 specification.
`static int` | `convertToSynchsafeInt(byte[] b)` Converts the byte array to a synchsafe integer as specified in section 6.2 of the id3v2 specification.
`static boolean` | `matchPattern(byte b, java.lang.String pattern)` This function takes an 8 character string representation of a byte in binary mode.
`static byte` | `setBit(byte b, int location)` Sets the bit at the specified location in the byte given.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BinaryParser

    public BinaryParser()

Method Detail

### bitSet

    public static boolean bitSet(byte b,
                                 int pos)

  Tests to see if the bit at postion pos is set in byte b

  Parameters:
    `b` - the byte to test
    `pos` - a value between 0 (least significant bit) and 7 (most significant bit) indicating the position to test
  Returns:
    true if the bit at the location is set

### matchPattern

    public static boolean matchPattern(byte b,
                                       java.lang.String pattern)

  This function takes an 8 character string representation of a byte in binary mode. It will match 0's and 1's at the locations specified and skip other characters (x is the standard wildcard). If the values of the bits at the locations where a 0 is set is 0 and values of the bits at the locations where 1 is set is 1, then the function will return true.

  Parameters:
    `b` - the byte to test
    `pattern` - the 8 character long pattern to test the byte
  Returns:
    true if the bits at the locations specified are set

### convertToDecimal

    public static int convertToDecimal(byte b,
                                       int start,
                                       int end)

  Convert a portion of a byte to an integer. This assumes that the length of the byte is end - start bits long with end being the most significant bit. The start and end values must be between 0 and 7. If the start and end values are incorrect, it will set start to 0 and end to 7.

  Parameters:
    `b` - the byte to convert from
    `start` - the starting bit
    `end` - the ending bit
  Returns:
    the converted value (unsigned)

### convertToInt

    public static int convertToInt(byte[] b)

  Convert an array of bytes into an integer. The array must not contain more than 4 bytes (32 bits). This assumes that the most significant byte is in the first index of the array. If an array is not 4 bytes long, then it will assume that the bytes are preceded by leading 0's.

  Parameters:
    `b` - the array of bytes
  Returns:
    the converted integer in decimal

### convertToSynchsafeInt

    public static int convertToSynchsafeInt(byte[] b)

  Converts the byte array to a synchsafe integer as specified in section 6.2 of the id3v2 specification. Works exactly same as the covnertToInt method except that it only calculates using the first 7 bits of each byte.

  Parameters:
    `b` - the array of bytes
  Returns:
    the converted integer in decimal

### convertToBytes

    public static byte[] convertToBytes(int num)

  Convert the integer passed to a array of 4 bytes (32-bits). Does the opposite of the convertToInt method.

  Parameters:
    `num` - the integer to convert
  Returns:
    the integer converted to a byte array

### convertToSynchsafeBytes

    public static byte[] convertToSynchsafeBytes(int num)

  Converts the integer passed to an array of bytes as specified in section 6.2 of the id3v2 specification. Works the same as the convertToBytes method except the most significant bit of each byte is zeroed.

  Parameters:
    `num` - the integer to convert
  Returns:
    the integer converted to a byte array

### setBit

    public static byte setBit(byte b,
                              int location)

  Sets the bit at the specified location in the byte given. Location should be between 0 and 7. If an invalid location is specified, 0 will be returned.

  Parameters:
    `b` - the byte to set the index in
    `location` - the index to set in b
  Returns:
    b with the bit at location set to 1

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD