org.jaudiotagger.audio.generic
Class Utils

java.lang.Object
  extended by org.jaudiotagger.audio.generic.Utils

public class Utils
extends java.lang.Object

Contains various frequently used static functions in the different tag formats

Author:
Raphael Slinckx

Constructor Summary
Utils()
           
 
Method Summary
static void copy(byte[] src, byte[] dst, int dstOffset)
          Copies the bytes of srd to dst at the specified offset.
static byte[] getDefaultBytes(java.lang.String s, java.lang.String charSet)
          Returns String.getBytes().
static java.lang.String getExtension(java.io.File f)
           
static long getLongNumberBigEndian(java.nio.ByteBuffer b, int start, int end)
           
static long getLongNumberLittleEndian(java.nio.ByteBuffer b, int start, int end)
           
static int getNumberBigEndian(byte[] b, int start, int end)
           
static int getNumberBigEndian(java.nio.ByteBuffer b, int start, int end)
           
static int getNumberLittleEndian(byte[] b)
           
static int getNumberLittleEndian(byte[] b, int start, int end)
           
static short getShortNumberBigEndian(java.nio.ByteBuffer b, int start, int end)
           
static byte[] getShortSizeBigEndian(short size)
          Convert short to byte representation - Big Endian (as used by mp4)
static byte[] getSizeBigEndian(int size)
          Convert int to byte representation - Big Endian (as used by mp4)
static byte[] getSizeLittleEndian(int size)
          Convert int to byte representation - Little Endian (as used by ogg vorbis)
static java.lang.String getString(byte[] b, int offset, int length, java.lang.String encoding)
          Create String starting from offset upto length using encoding
static java.lang.String getString(java.nio.ByteBuffer buffer, int offset, int length, java.lang.String encoding)
          Create String offset from position by offset upto length using encoding, and position of buffer is moved to after position + offset + length
static byte[] getUTF8Bytes(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

copy

public static void copy(byte[] src,
                        byte[] dst,
                        int dstOffset)
Copies the bytes of srd to dst at the specified offset.

Parameters:
src - The byte to be copied.
dst - The array to copy to
dstOffset - The start offset for the bytes to be copied.

getDefaultBytes

public static byte[] getDefaultBytes(java.lang.String s,
                                     java.lang.String charSet)
Returns String.getBytes().

Parameters:
s - The String to call, decode bytes using the specfied charset
Returns:
The bytes.

getExtension

public static java.lang.String getExtension(java.io.File f)

getLongNumberLittleEndian

public static long getLongNumberLittleEndian(java.nio.ByteBuffer b,
                                             int start,
                                             int end)

getLongNumberBigEndian

public static long getLongNumberBigEndian(java.nio.ByteBuffer b,
                                          int start,
                                          int end)

getNumberLittleEndian

public static int getNumberLittleEndian(byte[] b)

getNumberLittleEndian

public static int getNumberLittleEndian(byte[] b,
                                        int start,
                                        int end)

getNumberBigEndian

public static int getNumberBigEndian(byte[] b,
                                     int start,
                                     int end)

getNumberBigEndian

public static int getNumberBigEndian(java.nio.ByteBuffer b,
                                     int start,
                                     int end)

getShortNumberBigEndian

public static short getShortNumberBigEndian(java.nio.ByteBuffer b,
                                            int start,
                                            int end)

getSizeBigEndian

public static byte[] getSizeBigEndian(int size)
Convert int to byte representation - Big Endian (as used by mp4)

Parameters:
size -
Returns:
byte represenetation

getShortSizeBigEndian

public static byte[] getShortSizeBigEndian(short size)
Convert short to byte representation - Big Endian (as used by mp4)

Parameters:
size -
Returns:
byte represenetation

getSizeLittleEndian

public static byte[] getSizeLittleEndian(int size)
Convert int to byte representation - Little Endian (as used by ogg vorbis)

Parameters:
size -
Returns:
byte represenetation

getString

public static java.lang.String getString(byte[] b,
                                         int offset,
                                         int length,
                                         java.lang.String encoding)
Create String starting from offset upto length using encoding

Parameters:
b -
offset -
length -
encoding -
Returns:
Throws:
java.io.UnsupportedEncodingException

getString

public static java.lang.String getString(java.nio.ByteBuffer buffer,
                                         int offset,
                                         int length,
                                         java.lang.String encoding)
Create String offset from position by offset upto length using encoding, and position of buffer is moved to after position + offset + length

Parameters:
buffer -
offset -
length -
encoding -
Returns:

getUTF8Bytes

public static byte[] getUTF8Bytes(java.lang.String s)
                           throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException