Holger's
Java API

com.antelmann.cddb
Class CDDBEntry

java.lang.Object
  extended by com.antelmann.cddb.CDDBEntry
All Implemented Interfaces:
CDInfo, Serializable

public class CDDBEntry
extends Object
implements CDInfo

CDDBEntry represents an entry for a CD in a CDDB database that contains all known properties about the associated CD.

CDDBEntry also contains methods to generate Artist and Composition objects to bridge from a CDDB database to a more sophisticated internal CD database.

Author:
Holger Antelmann
See Also:
CDDBXmcdParser, Composition, Artist, Serialized Form

Constructor Summary
CDDBEntry(CDDBRecord record, String fileContent)
          The fileContent must be in xmcd format specified by CDDB and must contain the discID from the record.
 
Method Summary
 Artist extractCDArtist()
          returns the artist defined for the CD or null if none was found
 Composition extractComposition(boolean includeTracks)
          creates a default Composition object from the embedded CDInfo that regards the entire CD as one composition and will contain certain Composition objects as far as applicable.
 Artist extractTrackArtist(int track)
          returns the artist defined for the track or null if none was found
 Track[] extractTracks(boolean addArtist)
          generates default Track objects that - if addArtist is true - contain applicable contributions
 CDDBRecord getCDDBRecord()
          returns the associated CDDBRecord entry.
 CDID getCDID()
          returns the associated CDID object
 Properties getProperties()
          a convenience method that returns a map view of all known properties of this entry.
 String getXmcdContent()
          returns the content in xmcd file format as specified by CDDB.
 void saveToDirectory(File dir)
          saves the content of the entry into a file in the given directory according to standard CDDB conventions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDDBEntry

public CDDBEntry(CDDBRecord record,
                 String fileContent)
          throws ParseException,
                 XmcdFormatException
The fileContent must be in xmcd format specified by CDDB and must contain the discID from the record.

Throws:
ParseException - if the fileContent is not in valid xmcd format or inconsistent with the given record
XmcdFormatException
Method Detail

getXmcdContent

public String getXmcdContent()
Description copied from interface: CDInfo
returns the content in xmcd file format as specified by CDDB. As specified in xmcd CDDB format, there may be multiple discIDs present, and there is no category information. To retrieve that info, use the associated CDDBRecord.

Specified by:
getXmcdContent in interface CDInfo
See Also:
CDInfo.getCDDBRecord(), CDDBXmcdParser

getCDDBRecord

public CDDBRecord getCDDBRecord()
Description copied from interface: CDInfo
returns the associated CDDBRecord entry. Note: as the returned CDDBRecord is not derived directly from a CDDB query, the isExactMatch() value of this returned instance is meaningless. This record (with the embedded category and one discID) allows to identify the CDInfo object as to how it is to be filed.

Specified by:
getCDDBRecord in interface CDInfo
See Also:
CDDB.queryCD(CDID)

getCDID

public CDID getCDID()
Description copied from interface: CDInfo
returns the associated CDID object

Specified by:
getCDID in interface CDInfo

getProperties

public Properties getProperties()
Description copied from interface: CDInfo
a convenience method that returns a map view of all known properties of this entry. Unless otherwise specified by the implementing class, changes in the returned properties are not reflected in the actual properties of this instance. (I.e. it is asumed that the return value is a generated view per call.)

Specified by:
getProperties in interface CDInfo

saveToDirectory

public void saveToDirectory(File dir)
                     throws IOException
saves the content of the entry into a file in the given directory according to standard CDDB conventions.

The file will be saved in a subdirectory specified by the category and the filename will be the discID. The file content is the raw CDDB format. If the file already exists, an IOException will be thrown.

Throws:
IOException

extractComposition

public Composition extractComposition(boolean includeTracks)
                               throws XmcdFormatException
creates a default Composition object from the embedded CDInfo that regards the entire CD as one composition and will contain certain Composition objects as far as applicable.

Parameters:
includeTracks - if true, the generated Composition object will already contain all tracks from the embedded CDInfo
Throws:
XmcdFormatException

extractTracks

public Track[] extractTracks(boolean addArtist)
                      throws XmcdFormatException
generates default Track objects that - if addArtist is true - contain applicable contributions

Throws:
XmcdFormatException

extractCDArtist

public Artist extractCDArtist()
                       throws XmcdFormatException
returns the artist defined for the CD or null if none was found

Throws:
XmcdFormatException

extractTrackArtist

public Artist extractTrackArtist(int track)
                          throws XmcdFormatException
returns the artist defined for the track or null if none was found

Throws:
XmcdFormatException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads