org.qtunes.db
Interface Track


public interface Track

A Track is a single Track. It's created by the Database.create(org.qtunes.db.FieldMap) method, which in turn gets its values from a TrackReader. A Track is made up of a number of AbstractField classes, and it can be converted to audio sample by calling getAudioInputStream(). Some types of TrackReader are also instances of TrackWriter, and if that's the case the Track can be updated by calling Database.updateTrack(int, org.qtunes.db.FieldMap).


Method Summary
 void delete()
          Delete the track from the database
<T> T
get(AbstractField<T> field)
          Get the value of the specified Field.
 javax.sound.sampled.AudioInputStream getAudioInputStream()
          Get the AudioInputStream for this track.
 java.util.Iterator<Field<?>> getFields()
          Get an Iterator that moves over all the Field objects in this Track
 java.io.File getFile()
          Get the File this Track was loaded from
 java.nio.ByteBuffer getImageBuffer()
          Get a ByteBuffer containing the image.
 int getIndex()
          Get the index of this track in the database
 void update(FieldMap changes)
          Update the fields on this Track.
 

Method Detail

getIndex

int getIndex()
Get the index of this track in the database


get

<T> T get(AbstractField<T> field)
Get the value of the specified Field. The return type depends on the Field but should be a String, Integer, Boolean, Float, Long, int[] or byte[], or it may be null. The other get methods can be called to type the return value correctly.


getFile

java.io.File getFile()
Get the File this Track was loaded from


getAudioInputStream

javax.sound.sampled.AudioInputStream getAudioInputStream()
                                                         throws java.io.IOException
Get the AudioInputStream for this track. Don't forget to close the stream once you're done.

Throws:
java.io.IOException

getImageBuffer

java.nio.ByteBuffer getImageBuffer()
                                   throws java.io.IOException
Get a ByteBuffer containing the image. This maps the file into memory, so the returned ByteBuffer should be copied if the return value is not to be discarded immediately.

Throws:
java.io.IOException

getFields

java.util.Iterator<Field<?>> getFields()
Get an Iterator that moves over all the Field objects in this Track


delete

void delete()
Delete the track from the database


update

void update(FieldMap changes)
            throws java.io.IOException
Update the fields on this Track. The track file will be updated immediately, the database only on the next commit

Throws:
java.io.IOException