org.blinkenlights.jid3.util
Class ID3Util

java.lang.Object
  extended byorg.blinkenlights.jid3.util.ID3Util

public class ID3Util
extends java.lang.Object


Constructor Summary
ID3Util()
           
 
Method Summary
static void compare(java.lang.String sFileOne, java.lang.String sFileTwo)
          Compare two files.
static void compareFilePrefix(java.io.File oFile, byte[] abyExpected)
          Compare the starting bytes of a file against a given byte array.
static java.lang.String convertBytesToHexString(byte[] abyRawBytes, boolean bIncludeColons)
          A utility method which, given an array of bytes, will return a character string containing the hex values of the bytes, optionally separated by colons (ie. 2F:01:A9:3C:etc.), which may be useful in debugging output or elsewhere.
static byte[] convertFrhedToByteArray(java.lang.String sInput)
          Convert a clipboard buffer copied from the frhed hex editor, to an array of bytes.
static void copy(java.lang.String sSource, java.lang.String sDestination)
          Copy a file.
static byte[] deunsynchronize(byte[] abySource)
          De-unsynchronize an array of bytes.
static java.lang.String getLicense()
          Get the license for this library.
static java.lang.String getVersion()
          Get the version of this library.
static void main(java.lang.String[] args)
           
static void printTags(ID3Tag[] aoID3Tag)
          Utility method to report all tags found by printing them to stdout.
static boolean requiresUnsynchronization(byte[] abySource)
          Check if a byte array will require unsynchronization before being written as a tag.
static byte[] unsynchronize(byte[] abySource)
          Unsynchronize an array of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ID3Util

public ID3Util()
Method Detail

getVersion

public static java.lang.String getVersion()
Get the version of this library.


getLicense

public static java.lang.String getLicense()
Get the license for this library.


main

public static void main(java.lang.String[] args)

printTags

public static void printTags(ID3Tag[] aoID3Tag)
                      throws java.lang.Exception
Utility method to report all tags found by printing them to stdout.

Parameters:
aoID3Tag - an array of ID3Tag objects
Throws:
java.lang.Exception

requiresUnsynchronization

public static boolean requiresUnsynchronization(byte[] abySource)
Check if a byte array will require unsynchronization before being written as a tag. If the byte array contains any $FF bytes, then it will require unsynchronization.

Parameters:
abySource - the byte array to be examined
Returns:
true if unsynchronization is required, false otherwise

unsynchronize

public static byte[] unsynchronize(byte[] abySource)
Unsynchronize an array of bytes. In order to prevent a media player from incorrectly interpreting the contents of a tag, all $FF bytes followed by a byte with value >=224 must be followed by a $00 byte (thus, $FF $F0 sequences become $FF $00 $F0). NOTE: Unsynchronization is not always necessary, if no false sync patterns exist in the data. Only if the length of the returned byte array is greater than that of the source array, was an unsynchronization modification applied.

Parameters:
abySource - a byte array to be unsynchronized
Returns:
a unsynchronized representation of the source

deunsynchronize

public static byte[] deunsynchronize(byte[] abySource)
De-unsynchronize an array of bytes. This method takes an array of bytes which has already been unsynchronized, and it reverses this process, returning the original unencoded array of bytes. NOTE: De-unsynchronizing a byte array which was not unsynchronized can cause data corruption.

Parameters:
abySource - a byte array to be unencoded
Returns:
the original byte array

convertBytesToHexString

public static java.lang.String convertBytesToHexString(byte[] abyRawBytes,
                                                       boolean bIncludeColons)
A utility method which, given an array of bytes, will return a character string containing the hex values of the bytes, optionally separated by colons (ie. 2F:01:A9:3C:etc.), which may be useful in debugging output or elsewhere.

Parameters:
abyRawBytes - the byte array to be converted
bIncludeColons - whether to include colons in output string or not
Returns:
a string containing a hex representation of the byte array

copy

public static void copy(java.lang.String sSource,
                        java.lang.String sDestination)
                 throws java.lang.Exception
Copy a file.

Parameters:
sSource - source filename
sDestination - destination filename
Throws:
java.lang.Exception

compare

public static void compare(java.lang.String sFileOne,
                           java.lang.String sFileTwo)
                    throws java.lang.Exception
Compare two files.

Parameters:
sFileOne - filename
sFileTwo - filename
Returns:
true if identical, false otherwise
Throws:
java.lang.Exception

convertFrhedToByteArray

public static byte[] convertFrhedToByteArray(java.lang.String sInput)
                                      throws java.lang.Exception
Convert a clipboard buffer copied from the frhed hex editor, to an array of bytes. This method is used in test cases, to compare the results of the test with the expected values (as verified in frhed).

Parameters:
sInput - the content of the clipboard buffer (in frhed format)
Returns:
a byte array representing the input string
Throws:
java.lang.Exception - if there is either an error parsing the input string

compareFilePrefix

public static void compareFilePrefix(java.io.File oFile,
                                     byte[] abyExpected)
                              throws java.lang.Exception
Compare the starting bytes of a file against a given byte array. Used for testing. This method returning nothing if successful.

Parameters:
oFile - the file to verify
abyExpected - an array of bytes which are expected to start the specified file
Throws:
java.lang.Exception - if the contents do not match
java.io.IOException - if there was an error reading the file